diff -r 92222625d14c -r f07d8e10433b core/systems/PluginSys.cpp --- a/core/systems/PluginSys.cpp Sun Jul 15 20:27:11 2007 +0000 +++ b/core/systems/PluginSys.cpp Sun Jul 15 21:29:49 2007 +0000 @@ -92,13 +92,6 @@ delete m_configs[i]; } m_configs.clear(); - - List::iterator iter; - for (iter=m_WeakNatives.begin(); iter!=m_WeakNatives.end(); iter++) - { - delete (*iter); - } - m_WeakNatives.clear(); } void CPlugin::InitIdentity() @@ -1242,7 +1235,7 @@ pPlugin->Call_OnPluginStart(); /* 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::iterator pl_iter; CPlugin *pOther; @@ -1251,8 +1244,9 @@ pl_iter++) { pOther = (*pl_iter); - if (pOther->GetStatus() == Plugin_Error + if ((pOther->GetStatus() == Plugin_Error && (pOther->m_FakeNativesMissing || pOther->m_LibraryMissing)) + || pOther->m_FakeNativesMissing) { TryRefreshDependencies(pOther); } @@ -1329,12 +1323,15 @@ } } - /* If we got here, all natives are okay again! */ - pPlugin->m_status = Plugin_Running; - if ((pPlugin->m_ctx.ctx->flags & SPFLAG_PLUGIN_PAUSED) == SPFLAG_PLUGIN_PAUSED) + if (pPlugin->GetStatus() == Plugin_Error) { - pPlugin->m_ctx.ctx->flags &= ~SPFLAG_PLUGIN_PAUSED; - _SetPauseState(pPlugin, false); + /* If we got here, all natives are okay again! */ + 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 @@ pContext->FindNativeByName(native.name, &idx); 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); continue; } @@ -1418,6 +1415,24 @@ 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::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::iterator iter; IPluginsListener *pListener; @@ -1433,6 +1448,16 @@ pPlugin->Call_OnPluginEnd(); } + /* Unbound weak natives */ + List::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 */ List::iterator fn_iter; FakeNative *pNative; @@ -1447,16 +1472,6 @@ delete pNative; } - /* Unbound weak natives */ - WeakNative *wkn; - List::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++) { /* Notify listeners of destruction */