Don't use server commands to flush plugin unloads.
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
#include "common_logic.h"
|
||||
#include "Translator.h"
|
||||
#include "Logger.h"
|
||||
#include "frame_tasks.h"
|
||||
#include <am-string.h>
|
||||
#include <bridge/include/IVEngineServerBridge.h>
|
||||
#include <bridge/include/CoreProvider.h>
|
||||
@@ -54,6 +55,7 @@ IdentityType_t g_PluginIdent = 0;
|
||||
CPlugin::CPlugin(const char *file)
|
||||
: m_serial(0),
|
||||
m_status(Plugin_Uncompiled),
|
||||
m_WaitingToUnload(false),
|
||||
m_SilentFailure(false),
|
||||
m_FakeNativesMissing(false),
|
||||
m_LibraryMissing(false),
|
||||
@@ -1422,7 +1424,13 @@ void CPluginManager::TryRefreshDependencies(CPlugin *pPlugin)
|
||||
|
||||
bool CPluginManager::UnloadPlugin(IPlugin *plugin)
|
||||
{
|
||||
return ScheduleUnload((CPlugin *)plugin);
|
||||
CPlugin *pPlugin = (CPlugin *)plugin;
|
||||
|
||||
// If we're already in the unload queue, just wait.
|
||||
if (pPlugin->WaitingToUnload())
|
||||
return false;
|
||||
|
||||
return ScheduleUnload(pPlugin);
|
||||
}
|
||||
|
||||
bool CPluginManager::ScheduleUnload(CPlugin *pPlugin)
|
||||
@@ -1431,11 +1439,12 @@ bool CPluginManager::ScheduleUnload(CPlugin *pPlugin)
|
||||
assert(m_plugins.find(pPlugin) != m_plugins.end());
|
||||
|
||||
IPluginContext *pContext = pPlugin->GetBaseContext();
|
||||
if (pContext && pContext->IsInExec())
|
||||
{
|
||||
char buffer[255];
|
||||
ke::SafeSprintf(buffer, sizeof(buffer), "sm plugins unload %s\n", pPlugin->GetFilename());
|
||||
engine->ServerCommand(buffer);
|
||||
if (pContext && pContext->IsInExec()) {
|
||||
ke::Lambda<void()> callback = [this, pPlugin]() {
|
||||
this->ScheduleUnload(pPlugin);
|
||||
};
|
||||
pPlugin->SetWaitingToUnload();
|
||||
ScheduleTaskForNextFrame(ke::Move(callback));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user