Replaced every use of lua_call with RunScriptOnStack. Modified RunScriptOnStack to report an error to log and system message using a passed in context string. Modified every use of RunScriptOnStack to avoid crashing so that the reported error can be seen.
This commit is contained in:
+6
-7
@@ -242,9 +242,8 @@ void ActorFrame::DrawPrimitives()
|
||||
return;
|
||||
}
|
||||
this->PushSelf( L );
|
||||
RString sError;
|
||||
if( !LuaHelpers::RunScriptOnStack(L, sError, 1, 0) ) // 1 arg, 0 results
|
||||
LOG->Warn( "Error running DrawFunction: %s", sError.c_str() );
|
||||
RString Error= "Error running DrawFunction: ";
|
||||
LuaHelpers::RunScriptOnStack(L, Error, 1, 0, true); // 1 arg, 0 results
|
||||
LUA->Release(L);
|
||||
return;
|
||||
}
|
||||
@@ -302,6 +301,8 @@ static int IdenticalChildrenSingleApplier(lua_State* L)
|
||||
lua_pushvalue(L, lua_upvalueindex(1)); // stack: table, obj, args, func
|
||||
lua_insert(L, 2); // stack: table, func, obj, args
|
||||
int args_count= lua_gettop(L) - 2;
|
||||
// Not using RunScriptOnStack because we're inside a lua call already and
|
||||
// we want an error to propagate up.
|
||||
lua_call(L, args_count, LUA_MULTRET); // stack: table, return_values
|
||||
return lua_gettop(L) - 1;
|
||||
}
|
||||
@@ -482,10 +483,8 @@ void ActorFrame::UpdateInternal( float fDeltaTime )
|
||||
}
|
||||
this->PushSelf( L );
|
||||
lua_pushnumber( L, fDeltaTime );
|
||||
RString sError;
|
||||
|
||||
if( !LuaHelpers::RunScriptOnStack(L, sError, 2, 0) ) // 1 args, 0 results
|
||||
LOG->Warn( "Error running m_UpdateFunction: %s", sError.c_str() );
|
||||
RString Error= "Error running UpdateFunction: ";
|
||||
LuaHelpers::RunScriptOnStack(L, Error, 2, 0, true); // 1 args, 0 results
|
||||
LUA->Release(L);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user