mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-04 08:46:09 +00:00
Fix SpriteEvents destruction (fix #3162)
Classic "static initialization order fiasco" but in the destruction phase.
This commit is contained in:
parent
1630416991
commit
99c0d5b743
@ -369,6 +369,19 @@ void push_app_events(lua_State* L)
|
||||
|
||||
void push_sprite_events(lua_State* L, Sprite* sprite)
|
||||
{
|
||||
// Clear the g_spriteEvents map on Exit() signal because if the dtor
|
||||
// is called in the normal C++ order destruction sequence by
|
||||
// compilation units, it could crash because each ~SpriteEvents()
|
||||
// needs the doc::get() function, which uses the "objects"
|
||||
// collection from "src/doc/objects.cpp" (so we cannot garantize
|
||||
// that that "objects" collection will be destroyed after
|
||||
// "g_spriteEvents")
|
||||
static bool atExit = false;
|
||||
if (!atExit) {
|
||||
atExit = true;
|
||||
App::instance()->Exit.connect([]{ g_spriteEvents.clear(); });
|
||||
}
|
||||
|
||||
ASSERT(sprite);
|
||||
|
||||
SpriteEvents* spriteEvents;
|
||||
|
Loading…
Reference in New Issue
Block a user