core/systems/ExtensionSys.cpp
changeset 1121 92222625d14c
parent 1112 152ceef17866
child 1150 2d97459b4972
     1.1 --- a/core/systems/ExtensionSys.cpp	Sun Jul 15 18:55:13 2007 +0000
     1.2 +++ b/core/systems/ExtensionSys.cpp	Sun Jul 15 20:27:11 2007 +0000
     1.3 @@ -125,13 +125,6 @@
     1.4  	{
     1.5  		m_pLib->CloseLibrary();
     1.6  	}
     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 CExtension::MarkAllLoaded()
    1.17 @@ -156,6 +149,17 @@
    1.18  void CExtension::RemovePlugin(IPlugin *pPlugin)
    1.19  {
    1.20  	m_Plugins.remove(pPlugin);
    1.21 +
    1.22 +	List<WeakNative>::iterator iter = m_WeakNatives.begin();
    1.23 +	while (iter != m_WeakNatives.end())
    1.24 +	{
    1.25 +		if ((*iter).pl == pPlugin)
    1.26 +		{
    1.27 +			iter = m_WeakNatives.erase(iter);
    1.28 +		} else {
    1.29 +			iter++;
    1.30 +		}
    1.31 +	}
    1.32  }
    1.33  
    1.34  void CExtension::SetError(const char *error)
    1.35 @@ -546,7 +550,7 @@
    1.36  					{
    1.37  						set = true;
    1.38  					} else {
    1.39 -						WeakNative *wkn = new WeakNative((CPlugin *)pPlugin, idx);
    1.40 +						WeakNative wkn = WeakNative((CPlugin *)pPlugin, idx);
    1.41  						pExt->m_WeakNatives.push_back(wkn);
    1.42  					}
    1.43  				}
    1.44 @@ -594,13 +598,12 @@
    1.45  		}
    1.46  
    1.47  		/* Unbound weak natives */
    1.48 -		WeakNative *wkn;
    1.49 -		List<WeakNative *>::iterator wkn_iter;
    1.50 +		List<WeakNative>::iterator wkn_iter;
    1.51  		for (wkn_iter=pExt->m_WeakNatives.begin(); wkn_iter!=pExt->m_WeakNatives.end(); wkn_iter++)
    1.52  		{
    1.53 -			wkn = (*wkn_iter);
    1.54 -			sp_context_t *ctx = wkn->pl->GetContext();
    1.55 -			ctx->natives[wkn->idx].status = SP_NATIVE_UNBOUND;
    1.56 +			WeakNative & wkn = (*wkn_iter);
    1.57 +			sp_context_t *ctx = wkn.pl->GetContext();
    1.58 +			ctx->natives[wkn.idx].status = SP_NATIVE_UNBOUND;
    1.59  		}
    1.60  
    1.61  		/* Notify and/or unload all dependencies */