1.1 --- a/core/systems/PluginSys.cpp Sun Jul 15 20:27:11 2007 +0000
1.2 +++ b/core/systems/PluginSys.cpp Sun Jul 15 21:29:49 2007 +0000
1.3 @@ -92,13 +92,6 @@
1.4 delete m_configs[i];
1.5 }
1.6 m_configs.clear();
1.7 -
1.8 - List<WeakNative *>::iterator iter;
1.9 - for (iter=m_WeakNatives.begin(); iter!=m_WeakNatives.end(); iter++)
1.10 - {
1.11 - delete (*iter);
1.12 - }
1.13 - m_WeakNatives.clear();
1.14 }
1.15
1.16 void CPlugin::InitIdentity()
1.17 @@ -1242,7 +1235,7 @@
1.18 pPlugin->Call_OnPluginStart();
1.19
1.20 /* Now, if we have fake natives, go through all plugins that might need rebinding */
1.21 - if (pPlugin->GetStatus() >= Plugin_Paused && pPlugin->m_fakeNatives.size())
1.22 + if (pPlugin->GetStatus() <= Plugin_Paused && pPlugin->m_fakeNatives.size())
1.23 {
1.24 List<CPlugin *>::iterator pl_iter;
1.25 CPlugin *pOther;
1.26 @@ -1251,8 +1244,9 @@
1.27 pl_iter++)
1.28 {
1.29 pOther = (*pl_iter);
1.30 - if (pOther->GetStatus() == Plugin_Error
1.31 + if ((pOther->GetStatus() == Plugin_Error
1.32 && (pOther->m_FakeNativesMissing || pOther->m_LibraryMissing))
1.33 + || pOther->m_FakeNativesMissing)
1.34 {
1.35 TryRefreshDependencies(pOther);
1.36 }
1.37 @@ -1329,12 +1323,15 @@
1.38 }
1.39 }
1.40
1.41 - /* If we got here, all natives are okay again! */
1.42 - pPlugin->m_status = Plugin_Running;
1.43 - if ((pPlugin->m_ctx.ctx->flags & SPFLAG_PLUGIN_PAUSED) == SPFLAG_PLUGIN_PAUSED)
1.44 + if (pPlugin->GetStatus() == Plugin_Error)
1.45 {
1.46 - pPlugin->m_ctx.ctx->flags &= ~SPFLAG_PLUGIN_PAUSED;
1.47 - _SetPauseState(pPlugin, false);
1.48 + /* If we got here, all natives are okay again! */
1.49 + pPlugin->m_status = Plugin_Running;
1.50 + if ((pPlugin->m_ctx.ctx->flags & SPFLAG_PLUGIN_PAUSED) == SPFLAG_PLUGIN_PAUSED)
1.51 + {
1.52 + pPlugin->m_ctx.ctx->flags &= ~SPFLAG_PLUGIN_PAUSED;
1.53 + _SetPauseState(pPlugin, false);
1.54 + }
1.55 }
1.56 }
1.57
1.58 @@ -1363,7 +1360,7 @@
1.59 pContext->FindNativeByName(native.name, &idx);
1.60 if (pPlugin->GetContext()->natives[idx].flags & SP_NTVFLAG_OPTIONAL)
1.61 {
1.62 - WeakNative *wkn = new WeakNative(pPlugin, idx);
1.63 + WeakNative wkn(pPlugin, idx);
1.64 GetPluginByCtx(ctx)->m_WeakNatives.push_back(wkn);
1.65 continue;
1.66 }
1.67 @@ -1418,6 +1415,24 @@
1.68 pOther->m_dependents.remove(pPlugin);
1.69 }
1.70
1.71 + /* Remove weak references to us */
1.72 + for (pl_iter = m_plugins.begin();
1.73 + pl_iter != m_plugins.end();
1.74 + pl_iter++)
1.75 + {
1.76 + pOther = (*pl_iter);
1.77 + List<WeakNative>::iterator wk_iter = pOther->m_WeakNatives.begin();
1.78 + while (wk_iter != pOther->m_WeakNatives.end())
1.79 + {
1.80 + if ((*wk_iter).pl == pPlugin)
1.81 + {
1.82 + wk_iter = pOther->m_WeakNatives.erase(wk_iter);
1.83 + } else {
1.84 + wk_iter++;
1.85 + }
1.86 + }
1.87 + }
1.88 +
1.89 List<IPluginsListener *>::iterator iter;
1.90 IPluginsListener *pListener;
1.91
1.92 @@ -1433,6 +1448,16 @@
1.93 pPlugin->Call_OnPluginEnd();
1.94 }
1.95
1.96 + /* Unbound weak natives */
1.97 + List<WeakNative>::iterator wk_iter;
1.98 + for (wk_iter=pPlugin->m_WeakNatives.begin(); wk_iter!=pPlugin->m_WeakNatives.end(); wk_iter++)
1.99 + {
1.100 + WeakNative & wkn = (*wk_iter);
1.101 + sp_context_t *ctx = wkn.pl->GetContext();
1.102 + ctx->natives[wkn.idx].status = SP_NATIVE_UNBOUND;
1.103 + wkn.pl->m_FakeNativesMissing = true;
1.104 + }
1.105 +
1.106 /* Remove all of our native functions */
1.107 List<FakeNative *>::iterator fn_iter;
1.108 FakeNative *pNative;
1.109 @@ -1447,16 +1472,6 @@
1.110 delete pNative;
1.111 }
1.112
1.113 - /* Unbound weak natives */
1.114 - WeakNative *wkn;
1.115 - List<WeakNative *>::iterator wk_iter;
1.116 - for (wk_iter=pPlugin->m_WeakNatives.begin(); wk_iter!=pPlugin->m_WeakNatives.end(); wk_iter++)
1.117 - {
1.118 - wkn = (*wk_iter);
1.119 - sp_context_t *ctx = wkn->pl->GetContext();
1.120 - ctx->natives[wkn->idx].status = SP_NATIVE_UNBOUND;
1.121 - }
1.122 -
1.123 for (iter=m_listeners.begin(); iter!=m_listeners.end(); iter++)
1.124 {
1.125 /* Notify listeners of destruction */