mirror of
https://github.com/rive-app/rive-cpp.git
synced 2026-01-18 21:21:17 +01:00
No double deref luau (#11448) 62fcec60de
Co-authored-by: Luigi Rosso <luigi-rosso@users.noreply.github.com>
This commit is contained in:
@@ -513,7 +513,7 @@ end
|
||||
ScriptedDrawable drawable;
|
||||
|
||||
// Create LuaState from ScriptingTest's VM state
|
||||
LuaState luaState(L);
|
||||
lua_State* luaState = L;
|
||||
|
||||
// Manually set the inits flag since we're not using ScriptAsset
|
||||
// The inits flag indicates that the script has an init function
|
||||
@@ -524,7 +524,7 @@ end
|
||||
// ScriptingTest already left it there, so we can call scriptInit directly
|
||||
// Call ScriptedObject::scriptInit directly to avoid addDirt which requires
|
||||
// an artboard
|
||||
CHECK(drawable.ScriptedObject::scriptInit(&luaState));
|
||||
CHECK(drawable.ScriptedObject::scriptInit(luaState));
|
||||
|
||||
// Manually set implemented methods flags since we're not using ScriptAsset
|
||||
// Check if advance function exists and set the flag
|
||||
@@ -597,7 +597,7 @@ end
|
||||
ScriptedLayout layout;
|
||||
|
||||
// Create LuaState from ScriptingTest's VM state
|
||||
LuaState luaState(L);
|
||||
lua_State* luaState = L;
|
||||
|
||||
// Manually set the inits flag since we're not using ScriptAsset
|
||||
layout.implementedMethods(layout.implementedMethods() |
|
||||
@@ -606,7 +606,7 @@ end
|
||||
// scriptInit expects the factory function on the stack
|
||||
// Call ScriptedObject::scriptInit directly to avoid addDirt which requires
|
||||
// an artboard
|
||||
CHECK(layout.ScriptedObject::scriptInit(&luaState));
|
||||
CHECK(layout.ScriptedObject::scriptInit(luaState));
|
||||
|
||||
// Manually set implemented methods flags
|
||||
// After scriptInit, the self table is stored in m_self
|
||||
@@ -708,22 +708,22 @@ end
|
||||
// Create LuaState from ScriptingTest's VM state
|
||||
// Keep it in scope for the entire test since converter stores a pointer to
|
||||
// it
|
||||
LuaState luaState(L);
|
||||
lua_State* luaState = L;
|
||||
|
||||
// Manually set the inits flag since we're not using ScriptAsset
|
||||
converter->implementedMethods(converter->implementedMethods() |
|
||||
(1 << 9)); // m_initsBit
|
||||
|
||||
// Verify LuaState is valid before using it
|
||||
REQUIRE(luaState.state != nullptr);
|
||||
REQUIRE(luaState.state == L);
|
||||
REQUIRE(luaState != nullptr);
|
||||
REQUIRE(luaState == L);
|
||||
|
||||
// scriptInit expects the factory function on the stack
|
||||
// Verify stack state before calling scriptInit
|
||||
REQUIRE(lua_gettop(L) == stackTop);
|
||||
REQUIRE(lua_type(L, -1) == LUA_TFUNCTION);
|
||||
|
||||
REQUIRE(converter->ScriptedObject::scriptInit(&luaState));
|
||||
REQUIRE(converter->ScriptedObject::scriptInit(luaState));
|
||||
converter->addScriptedDirt(ComponentDirt::Bindings);
|
||||
|
||||
// Verify self() is valid before using it
|
||||
|
||||
Reference in New Issue
Block a user