- reloading now refreshes weak native binds
- fixed a crash bug when unloading a plugin being pointed to by weak ntvrefs in another plugin --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401128
This commit is contained in:
parent
430e63d6cd
commit
a80d38f799
@ -92,13 +92,6 @@ CPlugin::~CPlugin()
|
|||||||
delete m_configs[i];
|
delete m_configs[i];
|
||||||
}
|
}
|
||||||
m_configs.clear();
|
m_configs.clear();
|
||||||
|
|
||||||
List<WeakNative *>::iterator iter;
|
|
||||||
for (iter=m_WeakNatives.begin(); iter!=m_WeakNatives.end(); iter++)
|
|
||||||
{
|
|
||||||
delete (*iter);
|
|
||||||
}
|
|
||||||
m_WeakNatives.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlugin::InitIdentity()
|
void CPlugin::InitIdentity()
|
||||||
@ -1242,7 +1235,7 @@ bool CPluginManager::RunSecondPass(CPlugin *pPlugin, char *error, size_t maxleng
|
|||||||
pPlugin->Call_OnPluginStart();
|
pPlugin->Call_OnPluginStart();
|
||||||
|
|
||||||
/* Now, if we have fake natives, go through all plugins that might need rebinding */
|
/* Now, if we have fake natives, go through all plugins that might need rebinding */
|
||||||
if (pPlugin->GetStatus() >= Plugin_Paused && pPlugin->m_fakeNatives.size())
|
if (pPlugin->GetStatus() <= Plugin_Paused && pPlugin->m_fakeNatives.size())
|
||||||
{
|
{
|
||||||
List<CPlugin *>::iterator pl_iter;
|
List<CPlugin *>::iterator pl_iter;
|
||||||
CPlugin *pOther;
|
CPlugin *pOther;
|
||||||
@ -1251,8 +1244,9 @@ bool CPluginManager::RunSecondPass(CPlugin *pPlugin, char *error, size_t maxleng
|
|||||||
pl_iter++)
|
pl_iter++)
|
||||||
{
|
{
|
||||||
pOther = (*pl_iter);
|
pOther = (*pl_iter);
|
||||||
if (pOther->GetStatus() == Plugin_Error
|
if ((pOther->GetStatus() == Plugin_Error
|
||||||
&& (pOther->m_FakeNativesMissing || pOther->m_LibraryMissing))
|
&& (pOther->m_FakeNativesMissing || pOther->m_LibraryMissing))
|
||||||
|
|| pOther->m_FakeNativesMissing)
|
||||||
{
|
{
|
||||||
TryRefreshDependencies(pOther);
|
TryRefreshDependencies(pOther);
|
||||||
}
|
}
|
||||||
@ -1329,12 +1323,15 @@ void CPluginManager::TryRefreshDependencies(CPlugin *pPlugin)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we got here, all natives are okay again! */
|
if (pPlugin->GetStatus() == Plugin_Error)
|
||||||
pPlugin->m_status = Plugin_Running;
|
|
||||||
if ((pPlugin->m_ctx.ctx->flags & SPFLAG_PLUGIN_PAUSED) == SPFLAG_PLUGIN_PAUSED)
|
|
||||||
{
|
{
|
||||||
pPlugin->m_ctx.ctx->flags &= ~SPFLAG_PLUGIN_PAUSED;
|
/* If we got here, all natives are okay again! */
|
||||||
_SetPauseState(pPlugin, false);
|
pPlugin->m_status = Plugin_Running;
|
||||||
|
if ((pPlugin->m_ctx.ctx->flags & SPFLAG_PLUGIN_PAUSED) == SPFLAG_PLUGIN_PAUSED)
|
||||||
|
{
|
||||||
|
pPlugin->m_ctx.ctx->flags &= ~SPFLAG_PLUGIN_PAUSED;
|
||||||
|
_SetPauseState(pPlugin, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1363,7 +1360,7 @@ void CPluginManager::AddFakeNativesToPlugin(CPlugin *pPlugin)
|
|||||||
pContext->FindNativeByName(native.name, &idx);
|
pContext->FindNativeByName(native.name, &idx);
|
||||||
if (pPlugin->GetContext()->natives[idx].flags & SP_NTVFLAG_OPTIONAL)
|
if (pPlugin->GetContext()->natives[idx].flags & SP_NTVFLAG_OPTIONAL)
|
||||||
{
|
{
|
||||||
WeakNative *wkn = new WeakNative(pPlugin, idx);
|
WeakNative wkn(pPlugin, idx);
|
||||||
GetPluginByCtx(ctx)->m_WeakNatives.push_back(wkn);
|
GetPluginByCtx(ctx)->m_WeakNatives.push_back(wkn);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1418,6 +1415,24 @@ bool CPluginManager::UnloadPlugin(IPlugin *plugin)
|
|||||||
pOther->m_dependents.remove(pPlugin);
|
pOther->m_dependents.remove(pPlugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Remove weak references to us */
|
||||||
|
for (pl_iter = m_plugins.begin();
|
||||||
|
pl_iter != m_plugins.end();
|
||||||
|
pl_iter++)
|
||||||
|
{
|
||||||
|
pOther = (*pl_iter);
|
||||||
|
List<WeakNative>::iterator wk_iter = pOther->m_WeakNatives.begin();
|
||||||
|
while (wk_iter != pOther->m_WeakNatives.end())
|
||||||
|
{
|
||||||
|
if ((*wk_iter).pl == pPlugin)
|
||||||
|
{
|
||||||
|
wk_iter = pOther->m_WeakNatives.erase(wk_iter);
|
||||||
|
} else {
|
||||||
|
wk_iter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<IPluginsListener *>::iterator iter;
|
List<IPluginsListener *>::iterator iter;
|
||||||
IPluginsListener *pListener;
|
IPluginsListener *pListener;
|
||||||
|
|
||||||
@ -1433,6 +1448,16 @@ bool CPluginManager::UnloadPlugin(IPlugin *plugin)
|
|||||||
pPlugin->Call_OnPluginEnd();
|
pPlugin->Call_OnPluginEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Unbound weak natives */
|
||||||
|
List<WeakNative>::iterator wk_iter;
|
||||||
|
for (wk_iter=pPlugin->m_WeakNatives.begin(); wk_iter!=pPlugin->m_WeakNatives.end(); wk_iter++)
|
||||||
|
{
|
||||||
|
WeakNative & wkn = (*wk_iter);
|
||||||
|
sp_context_t *ctx = wkn.pl->GetContext();
|
||||||
|
ctx->natives[wkn.idx].status = SP_NATIVE_UNBOUND;
|
||||||
|
wkn.pl->m_FakeNativesMissing = true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Remove all of our native functions */
|
/* Remove all of our native functions */
|
||||||
List<FakeNative *>::iterator fn_iter;
|
List<FakeNative *>::iterator fn_iter;
|
||||||
FakeNative *pNative;
|
FakeNative *pNative;
|
||||||
@ -1447,16 +1472,6 @@ bool CPluginManager::UnloadPlugin(IPlugin *plugin)
|
|||||||
delete pNative;
|
delete pNative;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unbound weak natives */
|
|
||||||
WeakNative *wkn;
|
|
||||||
List<WeakNative *>::iterator wk_iter;
|
|
||||||
for (wk_iter=pPlugin->m_WeakNatives.begin(); wk_iter!=pPlugin->m_WeakNatives.end(); wk_iter++)
|
|
||||||
{
|
|
||||||
wkn = (*wk_iter);
|
|
||||||
sp_context_t *ctx = wkn->pl->GetContext();
|
|
||||||
ctx->natives[wkn->idx].status = SP_NATIVE_UNBOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (iter=m_listeners.begin(); iter!=m_listeners.end(); iter++)
|
for (iter=m_listeners.begin(); iter!=m_listeners.end(); iter++)
|
||||||
{
|
{
|
||||||
/* Notify listeners of destruction */
|
/* Notify listeners of destruction */
|
||||||
|
@ -271,7 +271,7 @@ private:
|
|||||||
List<CPlugin *> m_dependents;
|
List<CPlugin *> m_dependents;
|
||||||
List<CPlugin *> m_dependsOn;
|
List<CPlugin *> m_dependsOn;
|
||||||
List<FakeNative *> m_fakeNatives;
|
List<FakeNative *> m_fakeNatives;
|
||||||
List<WeakNative *> m_WeakNatives;
|
List<WeakNative> m_WeakNatives;
|
||||||
List<String> m_RequiredLibs;
|
List<String> m_RequiredLibs;
|
||||||
List<String> m_Libraries;
|
List<String> m_Libraries;
|
||||||
Trie *m_pProps;
|
Trie *m_pProps;
|
||||||
|
Loading…
Reference in New Issue
Block a user