core/systems/ExtensionSys.cpp
changeset 1112 152ceef17866
parent 1089 275107f9ca95
child 1121 92222625d14c
     1.1 --- a/core/systems/ExtensionSys.cpp	Sat Jul 14 17:36:11 2007 +0000
     1.2 +++ b/core/systems/ExtensionSys.cpp	Sun Jul 15 01:04:34 2007 +0000
     1.3 @@ -18,7 +18,6 @@
     1.4  #include "ShareSys.h"
     1.5  #include "Logger.h"
     1.6  #include "sourcemm_api.h"
     1.7 -#include "PluginSys.h"
     1.8  #include "sm_srvcmds.h"
     1.9  #include "sm_stringutil.h"
    1.10  
    1.11 @@ -126,6 +125,13 @@
    1.12  	{
    1.13  		m_pLib->CloseLibrary();
    1.14  	}
    1.15 +
    1.16 +	List<WeakNative *>::iterator iter;
    1.17 +	for (iter=m_WeakNatives.begin(); iter!=m_WeakNatives.end(); iter++)
    1.18 +	{
    1.19 +		delete (*iter);
    1.20 +	}
    1.21 +	m_WeakNatives.clear();
    1.22  }
    1.23  
    1.24  void CExtension::MarkAllLoaded()
    1.25 @@ -539,6 +545,9 @@
    1.26  					if (!(pContext->GetContext()->natives[idx].flags & SP_NTVFLAG_OPTIONAL))
    1.27  					{
    1.28  						set = true;
    1.29 +					} else {
    1.30 +						WeakNative *wkn = new WeakNative((CPlugin *)pPlugin, idx);
    1.31 +						pExt->m_WeakNatives.push_back(wkn);
    1.32  					}
    1.33  				}
    1.34  				i++;
    1.35 @@ -584,6 +593,16 @@
    1.36  			p_iter = pExt->m_Plugins.erase(p_iter);
    1.37  		}
    1.38  
    1.39 +		/* Unbound weak natives */
    1.40 +		WeakNative *wkn;
    1.41 +		List<WeakNative *>::iterator wkn_iter;
    1.42 +		for (wkn_iter=pExt->m_WeakNatives.begin(); wkn_iter!=pExt->m_WeakNatives.end(); wkn_iter++)
    1.43 +		{
    1.44 +			wkn = (*wkn_iter);
    1.45 +			sp_context_t *ctx = wkn->pl->GetContext();
    1.46 +			ctx->natives[wkn->idx].status = SP_NATIVE_UNBOUND;
    1.47 +		}
    1.48 +
    1.49  		/* Notify and/or unload all dependencies */
    1.50  		List<CExtension *>::iterator c_iter;
    1.51  		CExtension *pDep;