From 5a3e4abb18711e50078d73ccb0c8f301d479ad06 Mon Sep 17 00:00:00 2001 From: Andrew <159703254+andrewsoonqn@users.noreply.github.com> Date: Mon, 13 Jul 2026 16:00:25 +0800 Subject: [PATCH] Catch plugin actions loaded during startup --- src/slic3r/GUI/GUI_App.cpp | 14 +++++++++++--- src/slic3r/GUI/ScriptActionSource.cpp | 10 +--------- src/slic3r/GUI/ScriptActionSource.hpp | 1 - 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 27d000657c..ee254c6ade 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -3172,6 +3172,17 @@ bool GUI_App::on_init_inner() refresh_plugins_dialog(); }); + // Register all AppAction sources + m_action_registry.add_source(std::make_unique()); + // m_action_registry.add_source(std::make_unique()); + // m_action_registry.add_source(std::make_unique()); + // ... + + // Initialize with all added sources + // - register callbacks, + // - then enumerate: upsert all actions into registry + m_action_registry.init(); + for (const std::string& plugin_key : plugin_mgr.get_catalog().get_enabled_plugin_keys()) { if (!plugin_mgr.get_loader().is_plugin_loaded(plugin_key)) { plugin_mgr.get_loader().load_plugin(plugin_mgr.get_catalog(), plugin_key, false); @@ -3179,9 +3190,6 @@ bool GUI_App::on_init_inner() } } - m_action_registry.add_source(std::make_unique()); - m_action_registry.init(); - if (m_agent) plugin_mgr.set_cloud_agent(std::dynamic_pointer_cast(m_agent->get_cloud_agent())); diff --git a/src/slic3r/GUI/ScriptActionSource.cpp b/src/slic3r/GUI/ScriptActionSource.cpp index 8f5887b698..64c33f7044 100644 --- a/src/slic3r/GUI/ScriptActionSource.cpp +++ b/src/slic3r/GUI/ScriptActionSource.cpp @@ -91,15 +91,7 @@ void ScriptActionSource::start(ActionRegistry& sink) refresh_capability(capability, ActionChange::Removed); }); - enumerate(); -} - -void ScriptActionSource::enumerate() -{ - assert(wxThread::IsMain()); - assert(m_sink != nullptr); - - PluginLoader& loader = PluginManager::instance().get_loader(); + // enumerate std::unordered_map source_names; for (const PluginDescriptor& desc : loader.get_all_loaded_plugin_descriptors()) if (!desc.name.empty()) diff --git a/src/slic3r/GUI/ScriptActionSource.hpp b/src/slic3r/GUI/ScriptActionSource.hpp index 85949f601d..06e5f09d66 100644 --- a/src/slic3r/GUI/ScriptActionSource.hpp +++ b/src/slic3r/GUI/ScriptActionSource.hpp @@ -26,7 +26,6 @@ public: void start(ActionRegistry& sink) override; private: - void enumerate(); void refresh_source(const std::string& plugin_key, ActionChange change); void refresh_capability(const std::string& plugin_key, const std::string& capability, ActionChange change); std::shared_ptr make_action(const std::string& plugin_key, const std::string& capability,