summaryrefslogtreecommitdiffstats
path: root/src/Bindings/PluginManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Bindings/PluginManager.cpp67
1 files changed, 48 insertions, 19 deletions
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index 6593097dd..310a3968b 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -165,35 +165,54 @@ void cPluginManager::InsertDefaultPlugins(cSettingsRepositoryInterface & a_Setti
void cPluginManager::Tick(float a_Dt)
{
- // Unload plugins that have been scheduled for unloading:
- AStringVector PluginsToUnload;
+ decltype(m_PluginsNeedAction) PluginsNeedAction;
{
- cCSLock Lock(m_CSPluginsToUnload);
- std::swap(m_PluginsToUnload, PluginsToUnload);
+ cCSLock Lock(m_CSPluginsNeedAction);
+ std::swap(m_PluginsNeedAction, PluginsNeedAction);
}
- for (auto & folder: PluginsToUnload)
+
+ // Process deferred actions:
+ for (auto & CurrentPlugin : PluginsNeedAction)
{
- bool HasUnloaded = false;
- bool HasFound = false;
- for (auto & plugin: m_Plugins)
+ auto & Action = CurrentPlugin.first;
+ auto & Folder = CurrentPlugin.second;
+
+ bool WasLoaded = false;
+ bool WasFound = false;
+ for (auto & Plugin: m_Plugins)
{
- if (plugin->GetFolderName() == folder)
+ if (Plugin->GetFolderName() == Folder)
{
- HasFound = true;
- if (plugin->IsLoaded())
+ WasFound = true;
+ if (Plugin->IsLoaded())
{
- plugin->Unload();
- HasUnloaded = true;
+ switch (Action)
+ {
+ case PluginAction::Reload :
+ {
+ // Reload plugins by unloading, then loading:
+ Plugin->Unload();
+ Plugin->Load();
+ break;
+ }
+ case PluginAction::Unload :
+ {
+ // Unload plugins that have been scheduled for unloading:
+ Plugin->Unload();
+ break;
+ }
+ }
+ WasLoaded = true;
}
}
}
- if (!HasFound)
+ if (!WasFound)
{
- LOG("Cannot unload plugin in folder \"%s\", there's no such plugin folder", folder.c_str());
+ LOG("Cannot act on plugin in folder \"%s\", there's no such plugin folder", Folder.c_str());
}
- else if (!HasUnloaded)
+ else if (!WasLoaded)
{
- LOG("Cannot unload plugin in folder \"%s\", it has not been loaded.", folder.c_str());
+ LOG("Cannot act on plugin in folder \"%s\", it has not been loaded.", Folder.c_str());
}
} // for plugin - m_Plugins[]
@@ -1317,8 +1336,18 @@ void cPluginManager::UnloadPluginsNow()
void cPluginManager::UnloadPlugin(const AString & a_PluginFolder)
{
- cCSLock Lock(m_CSPluginsToUnload);
- m_PluginsToUnload.push_back(a_PluginFolder);
+ cCSLock Lock(m_CSPluginsNeedAction);
+ m_PluginsNeedAction.emplace_back(PluginAction::Unload, a_PluginFolder);
+}
+
+
+
+
+
+void cPluginManager::ReloadPlugin(const AString & a_PluginFolder)
+{
+ cCSLock Lock(m_CSPluginsNeedAction);
+ m_PluginsNeedAction.emplace_back(PluginAction::Reload, a_PluginFolder);
}