@@ -255,16 +255,18 @@ ll::Expected<> PluginManager::unload(std::string_view name) {
255255 return ll::makeStringError (" Plugin {0} not found" _tr (name));
256256 }
257257
258+ {
259+ EngineScope scope (scriptEngine);
258260#ifndef LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS
259- LLSERemoveTimeTaskData (scriptEngine);
261+ LLSERemoveTimeTaskData (scriptEngine);
260262#endif
261- LLSECallEventsOnUnload (scriptEngine);
262- LLSERemoveAllEventListeners (scriptEngine);
263- LLSERemoveCmdRegister (scriptEngine);
264- LLSERemoveCmdCallback (scriptEngine);
265- LLSERemoveAllExportedFuncs (scriptEngine);
266-
267- EngineOwnData::clearEngineObjects (scriptEngine);
263+ LLSECallEventsOnUnload (scriptEngine);
264+ LLSERemoveAllEventListeners (scriptEngine);
265+ LLSERemoveCmdRegister (scriptEngine);
266+ LLSERemoveCmdCallback (scriptEngine);
267+ LLSERemoveAllExportedFuncs (scriptEngine);
268+ EngineOwnData::clearEngineObjects (scriptEngine);
269+ }
268270 EngineManager::unregisterEngine (scriptEngine);
269271
270272 if (auto plugin = std::static_pointer_cast<Plugin>(getMod (name))) {
@@ -292,7 +294,7 @@ ll::Expected<> PluginManager::unload(std::string_view name) {
292294 }
293295
294296 return {};
295- } catch (const script::Exception& e ) {
297+ } catch (const script::Exception&) {
296298 return ll::makeStringError (" Failed to unload plugin {0}: {1}" _tr (name, " Unknown script exception" ));
297299 } catch (const std::exception& e) {
298300 return ll::makeStringError (" Failed to unload plugin {0}: {1}" _tr (name, e.what ()));
0 commit comments