]> git.sesse.net Git - nageru/commitdiff
Work around a crash caused by GC.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 7 Oct 2015 23:41:34 +0000 (01:41 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 7 Oct 2015 23:41:34 +0000 (01:41 +0200)
theme.cpp

index 09797a65ed7bcec0c7799743f3489128a28feacc..acfb27cf0f85de6a625d9d60ec7388edf7b19c7e 100644 (file)
--- a/theme.cpp
+++ b/theme.cpp
@@ -103,6 +103,11 @@ int EffectChain_add_effect(lua_State* L)
        }
 
        lua_settop(L, 2);  // Return the effect itself.
+
+       // Make sure Lua doesn't garbage-collect it away.
+       lua_pushvalue(L, -1);
+       luaL_ref(L, LUA_REGISTRYINDEX);  // TODO: leak?
+
        return 1;
 }