Added cPluginManager:IsPluginLoaded() API, better load error msgs.
This commit is contained in:
parent
288d2280fa
commit
4a946aa8c4
@ -181,11 +181,29 @@ void cPluginManager::Tick(float a_Dt)
|
|||||||
cCSLock Lock(m_CSPluginsToUnload);
|
cCSLock Lock(m_CSPluginsToUnload);
|
||||||
std::swap(m_PluginsToUnload, PluginsToUnload);
|
std::swap(m_PluginsToUnload, PluginsToUnload);
|
||||||
}
|
}
|
||||||
|
for (auto & folder: PluginsToUnload)
|
||||||
|
{
|
||||||
|
bool HasUnloaded = false;
|
||||||
|
bool HasFound = false;
|
||||||
for (auto & plugin: m_Plugins)
|
for (auto & plugin: m_Plugins)
|
||||||
{
|
{
|
||||||
if (std::find(PluginsToUnload.cbegin(), PluginsToUnload.cend(), plugin->GetFolderName()) != PluginsToUnload.cend())
|
if (plugin->GetFolderName() == folder)
|
||||||
|
{
|
||||||
|
HasFound = true;
|
||||||
|
if (plugin->IsLoaded())
|
||||||
{
|
{
|
||||||
plugin->Unload();
|
plugin->Unload();
|
||||||
|
HasUnloaded = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!HasFound)
|
||||||
|
{
|
||||||
|
LOG("Cannot unload plugin in folder \"%s\", there's no such plugin folder", folder.c_str());
|
||||||
|
}
|
||||||
|
else if (!HasUnloaded)
|
||||||
|
{
|
||||||
|
LOG("Cannot unload plugin in folder \"%s\", it has not been loaded.", folder.c_str());
|
||||||
}
|
}
|
||||||
} // for plugin - m_Plugins[]
|
} // for plugin - m_Plugins[]
|
||||||
|
|
||||||
@ -1510,7 +1528,7 @@ bool cPluginManager::LoadPlugin(const AString & a_FolderName)
|
|||||||
} // for plugin - m_Plugins[]
|
} // for plugin - m_Plugins[]
|
||||||
|
|
||||||
// Plugin not found
|
// Plugin not found
|
||||||
LOGD("%s: Plugin folder %s not found in the list of plugins.", __FUNCTION__, a_FolderName.c_str());
|
LOG("Cannot load plugin, folder \"%s\" not found.", a_FolderName.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1556,6 +1574,22 @@ void cPluginManager::RemovePluginCommands(cPlugin * a_Plugin)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool cPluginManager::IsPluginLoaded(const AString & a_PluginName)
|
||||||
|
{
|
||||||
|
for (auto & plugin: m_Plugins)
|
||||||
|
{
|
||||||
|
if (plugin->GetName() == a_PluginName)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cPluginManager::BindCommand(const AString & a_Command, cPlugin * a_Plugin, const AString & a_Permission, const AString & a_HelpString)
|
bool cPluginManager::BindCommand(const AString & a_Command, cPlugin * a_Plugin, const AString & a_Permission, const AString & a_HelpString)
|
||||||
{
|
{
|
||||||
CommandMap::iterator cmd = m_Commands.find(a_Command);
|
CommandMap::iterator cmd = m_Commands.find(a_Command);
|
||||||
|
@ -266,6 +266,9 @@ public:
|
|||||||
/** Removes all command bindings that the specified plugin has made */
|
/** Removes all command bindings that the specified plugin has made */
|
||||||
void RemovePluginCommands(cPlugin * a_Plugin);
|
void RemovePluginCommands(cPlugin * a_Plugin);
|
||||||
|
|
||||||
|
/** Returns true if the specified plugin is loaded. */
|
||||||
|
bool IsPluginLoaded(const AString & a_PluginName); // tolua_export
|
||||||
|
|
||||||
/** Binds a command to the specified plugin. Returns true if successful, false if command already bound. */
|
/** Binds a command to the specified plugin. Returns true if successful, false if command already bound. */
|
||||||
bool BindCommand(const AString & a_Command, cPlugin * a_Plugin, const AString & a_Permission, const AString & a_HelpString); // Exported in ManualBindings.cpp, without the a_Plugin param
|
bool BindCommand(const AString & a_Command, cPlugin * a_Plugin, const AString & a_Permission, const AString & a_HelpString); // Exported in ManualBindings.cpp, without the a_Plugin param
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user