Skip to content

Commit 4739114

Browse files
committed
fix: fix error in unload
1 parent 2ebfdd8 commit 4739114

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/lse/Plugin.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#include "PluginManager.h"
4+
35
#include <ll/api/plugin/Manifest.h>
46
#include <ll/api/plugin/Plugin.h>
57

@@ -8,6 +10,8 @@ namespace lse {
810
class Plugin : public ll::plugin::Plugin {
911
public:
1012
Plugin(const ll::plugin::Manifest& manifest);
11-
};
1213

14+
private:
15+
friend PluginManager;
16+
};
1317
} // namespace lse

src/lse/PluginManager.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ auto PluginManager::load(ll::plugin::Manifest manifest) -> bool {
5151
}
5252

5353
auto& scriptEngine = *EngineManager::newEngine(manifest.name);
54+
auto plugin = std::make_shared<Plugin>(manifest);
5455

5556
try {
5657
script::EngineScope engineScope(scriptEngine);
@@ -81,7 +82,10 @@ auto PluginManager::load(ll::plugin::Manifest manifest) -> bool {
8182
return false;
8283
}
8384
scriptEngine.eval(pluginEntryContent.value());
84-
85+
plugin->onLoad([](ll::plugin::Plugin& plugin) { return true; });
86+
plugin->onUnload([](ll::plugin::Plugin& plugin) { return true; });
87+
plugin->onEnable([](ll::plugin::Plugin& plugin) { return true; });
88+
plugin->onDisable([](ll::plugin::Plugin& plugin) { return true; });
8589
} catch (const std::exception& e) {
8690
LLSERemoveTimeTaskData(&scriptEngine);
8791
LLSERemoveAllEventListeners(&scriptEngine);
@@ -93,10 +97,9 @@ auto PluginManager::load(ll::plugin::Manifest manifest) -> bool {
9397

9498
EngineManager::unregisterEngine(&scriptEngine);
9599

96-
// throw;
100+
return false;
97101
}
98102

99-
auto plugin = std::make_shared<Plugin>(manifest);
100103
if (!addPlugin(manifest.name, plugin)) {
101104
logger.error("failed to register plugin {}", manifest.name);
102105
return false;

0 commit comments

Comments
 (0)