Closed vdweller84 closed 1 year ago
Usually this kind of error occurs when you store objects in wrong order in classes or you store multiple things in global variables or manually destroy the state while still holding references somewhere.
You need to destroy any references to lua before you destroy the sol::state
.
This means any sol::function
, sol::object
, sol::table
and so on that you might have stored. All of them must be destroyed before sol::state
.
Thank you. A simple cleanup was all that was needed.
Hello,
This is most likely a mistake on my part rather than a bug.
I am using an extern global variable
sol::state lua
. Then I callInitLua()
, which resides in another .cpp file, where that variable is initialized,open_libraries()
is called, and other lua-related stuff is set up. Then the program loops (using SDL) and each frame lua events run. There are lua tables and functions stored in containers (std::vector).The program runs normally and all events run OK. But when the program quits (ie the loop breaks and main() returns), for instance when users click the Close icon on the window, I get an exception right here in reference.hpp :
My question is, what am I doing wrong and what is a "good practice" to avoid it? I encountered a topic some time ago discussing something similar but for the life of me I can't find it again.
Thanks a lot in advance.