I'm using Lua & luabind for the first time, and I've been wondering about the following issue. If I declare a singleton class in C++, and bind it to Lua, where I get its instance and call some methods, which language actually owns the instance?
The reason I'm wondering is because at the moment my program will occasionally segfault in the destructor of my singleton class. Is Lua trying to garbage collect it after the instance has already been destructed? If so, how do I prevent it from doing so? Here is the declaration:
public:
static App* GetInstance();
~App();
void Execute();
private:
App();
In Lua I call
app = App.getInstance()
app:execute()
and after everything has finished, it crashes. What exactly is happening here?
The luabind looks like this (lots of properties have been omitted)
module(L, "nge")
[
class_<App>("App")
.scope
[
def("getInstance", &App::GetInstance)
]
.def("execute", &App::Execute)
]