Skip to content

Commit

Permalink
Fix the lack of unregistering interval functions at screen destruction
Browse files Browse the repository at this point in the history
im fairly sure this is the right thing to do
not doing this seemed to let creating and deleting interval functions then restarting screens do very very very weird things in lua (such as hardcoded strings being referred to as arbitrary classes such as "315" and "ActorFrame" thus breaking very tiny things that you didnt notice until it crashed the game)
quite a funny consequence
  • Loading branch information
poco0317 committed Sep 21, 2021
1 parent de97a7f commit 8f10cf0
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Etterna/Screen/Others/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,19 @@ Screen::InitScreen(Screen* pScreen)
pScreen->Init();
}

Screen::~Screen() = default;
Screen::~Screen()
{
// unregister the periodic functions
auto* L = LUA->Get();
for (auto& dfunc : delayedPeriodicFunctions) {
auto id = std::get<3>(dfunc);
luaL_unref(L, LUA_REGISTRYINDEX, id);
}
delayedFunctions.clear();
delayedPeriodicFunctions.clear();
delayedPeriodicFunctionIdsToDelete.clear();
LUA->Release(L);
};

bool
Screen::SortMessagesByDelayRemaining(const Screen::QueuedScreenMessage& m1,
Expand Down

0 comments on commit 8f10cf0

Please sign in to comment.