diff --git a/src/Export.cpp b/src/Export.cpp index c61668b..49a6afd 100644 --- a/src/Export.cpp +++ b/src/Export.cpp @@ -36,6 +36,17 @@ namespace Echoion::Core { return "Echoion"; } + + // Void::Plugin::PluginLoader calls on_load() once after create + // (first load and after a reload swap). Self-initialize from the + // default config path so the plugin is ready without host-provided + // wiring; idempotent via isInitialized(). + void on_load() override + { + if (!isInitialized()) { + (void)initialize(ConfigLoader::getDefaultConfigPath()); + } + } }; } // namespace Echoion::Core @@ -103,6 +114,16 @@ extern "C" if (!core || !json) { return -1; } + // reload() transfers state before on_load(), so the freshly-created + // instance is not yet initialized — bring it up first, then restore. + // Idempotent: a no-op once initialized. + if (!core->isInitialized()) { + auto initResult = + core->initialize(Echoion::Core::ConfigLoader::getDefaultConfigPath()); + if (!initResult) { + return -1; + } + } auto result = core->restoreAfterHotReload(std::string(json)); return result ? 0 : -1; }