Separate the top of UnloadPlugin into a precursor function.
This commit is contained in:
parent
44bacdc067
commit
9ef8cc7064
@ -1478,23 +1478,30 @@ void CPluginManager::TryRefreshDependencies(CPlugin *pPlugin)
|
|||||||
|
|
||||||
bool CPluginManager::UnloadPlugin(IPlugin *plugin)
|
bool CPluginManager::UnloadPlugin(IPlugin *plugin)
|
||||||
{
|
{
|
||||||
CPlugin *pPlugin = (CPlugin *)plugin;
|
return ScheduleUnload((CPlugin *)plugin);
|
||||||
|
}
|
||||||
|
|
||||||
/* This prevents removal during insertion or anything else weird */
|
bool CPluginManager::ScheduleUnload(CPlugin *pPlugin)
|
||||||
if (m_plugins.find(pPlugin) == m_plugins.end())
|
{
|
||||||
{
|
// Should not be recursively removing.
|
||||||
return false;
|
assert(m_plugins.find(pPlugin) != m_plugins.end());
|
||||||
}
|
|
||||||
|
|
||||||
IPluginContext *pContext = plugin->GetBaseContext();
|
IPluginContext *pContext = pPlugin->GetBaseContext();
|
||||||
if (pContext != NULL && pContext->IsInExec())
|
if (pContext && pContext->IsInExec())
|
||||||
{
|
{
|
||||||
char buffer[255];
|
char buffer[255];
|
||||||
ke::SafeSprintf(buffer, sizeof(buffer), "sm plugins unload %s\n", plugin->GetFilename());
|
ke::SafeSprintf(buffer, sizeof(buffer), "sm plugins unload %s\n", pPlugin->GetFilename());
|
||||||
engine->ServerCommand(buffer);
|
engine->ServerCommand(buffer);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No need to schedule an unload, we can unload immediately.
|
||||||
|
UnloadPluginImpl(pPlugin);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPluginManager::UnloadPluginImpl(CPlugin *pPlugin)
|
||||||
|
{
|
||||||
/* Remove us from the lookup table and linked list */
|
/* Remove us from the lookup table and linked list */
|
||||||
m_plugins.remove(pPlugin);
|
m_plugins.remove(pPlugin);
|
||||||
m_LoadLookup.remove(pPlugin->m_filename);
|
m_LoadLookup.remove(pPlugin->m_filename);
|
||||||
@ -1535,8 +1542,6 @@ bool CPluginManager::UnloadPlugin(IPlugin *plugin)
|
|||||||
|
|
||||||
/* Tell the plugin to delete itself */
|
/* Tell the plugin to delete itself */
|
||||||
delete pPlugin;
|
delete pPlugin;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IPlugin *CPluginManager::FindPluginByContext(const sp_context_t *ctx)
|
IPlugin *CPluginManager::FindPluginByContext(const sp_context_t *ctx)
|
||||||
|
@ -455,6 +455,9 @@ private:
|
|||||||
bool FindOrRequirePluginDeps(CPlugin *pPlugin, char *error, size_t maxlength);
|
bool FindOrRequirePluginDeps(CPlugin *pPlugin, char *error, size_t maxlength);
|
||||||
|
|
||||||
void _SetPauseState(CPlugin *pPlugin, bool pause);
|
void _SetPauseState(CPlugin *pPlugin, bool pause);
|
||||||
|
|
||||||
|
bool ScheduleUnload(CPlugin *plugin);
|
||||||
|
void UnloadPluginImpl(CPlugin *plugin);
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Caching internal objects
|
* Caching internal objects
|
||||||
|
@ -392,7 +392,6 @@ static cell_t FormatNativeString(IPluginContext *pContext, const cell_t *params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get buffer information */
|
/* Get buffer information */
|
||||||
int err;
|
|
||||||
char *output_buffer;
|
char *output_buffer;
|
||||||
char *format_buffer;
|
char *format_buffer;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user