r = asScriptEngine->RegisterGlobalProperty("CTE3GameProcessGUI@ g_TE3GameProcGUICurrent", &g_TE3GameProcGUICurrent); assert( r >= 0);
r = asScriptEngine->RegisterGlobalFunction("CTE3GameProcessGUI@ GetGUIProcContext()", asFUNCTION(GetGUIProcContext), asCALL_CDECL ); assert( r >= 0);
and singleton
class CTE3ScriptManager
{
protected:
static CTE3ScriptManager m_ScriptManager;
The script is giving a null pointer access at line 6, column 2. But which line in the script is this actually referring to?
The [color="#660066"]GetGUIProcContext function doesn't increase the reference counter of the returned handle. If the object is really reference counted, then this would cause the code to release the object before you actually wanted it.
The global variable [color="#000000"]g_TE3GameProcGUICurrent can obviously be null at times. What would these times be?
As for the error, I just gave an example of the type of error. It is always the same, and it happens in a situation calling ScriptManager or g_TE3GameProcGUICurrent or GetGUIProcContext ()
// now error is here
strButtonName = ScriptManager.GetScriptContextValuesLocal().GetValueNameString(string("_lv_ButtonName"));
CTE3CIIScreen @pMainScreen = null;
// but it may happen here
@pMainScreen = GetGUIProcContext().GetMainScreen();
// and here
@pMainScreen = g_TE3GameProcGUICurrent.GetMainScreen();
if( pMainScreen is null )
return;
The problem was that I register the static variables in Angel Script, then in C + +, I changed their meaning. But the script remained the initial value obtained at registration.
Singleton case differs only in that I register the final value of the variable in the script.