Skip to content

Commit 2d0b4e8

Browse files
committed
fix: add missing enter scope on mods unload
1 parent 74bc2e8 commit 2d0b4e8

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

src/lse/Plugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace lse {
99

10-
Plugin::Plugin(const ll::mod::Manifest& manifest) : ll::mod::Mod(std::move(manifest)) {}
10+
Plugin::Plugin(ll::mod::Manifest manifest) : ll::mod::Mod(std::move(manifest)) {}
1111

1212
Plugin::~Plugin() { release(); }
1313

src/lse/Plugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Plugin : public ll::mod::Mod {
2222

2323
std::unordered_map<std::string, std::vector<ParamInfo>> registeredCommands;
2424

25-
Plugin(const ll::mod::Manifest& manifest);
25+
explicit Plugin(ll::mod::Manifest manifest);
2626
~Plugin();
2727

2828
static std::shared_ptr<ll::mod::Mod> current();

src/lse/PluginManager.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)