Skip to content

Commit

Permalink
fix accessing obsolete memory in gui scrollbars in emit, after its co…
Browse files Browse the repository at this point in the history
…rresponding entity has been removed (skip entire emit)
  • Loading branch information
malytomas committed Sep 25, 2023
1 parent dc5bbaa commit af7856c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions sources/libengine/gui/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ namespace cage
if (!assetMgr->get<AssetSchemeIndexPack, AssetPack>(HashString("cage/cage.pack")))
return {};

if (!eventsEnabled)
return {}; // gui entities have been modified, invalidating any data cached in our hierarchy

GraphicsDataCleaner graphicsDataCleaner(this);

for (auto &s : skins)
Expand Down
1 change: 1 addition & 0 deletions sources/libengine/gui/layouts/scrollbars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ namespace cage

void emit() override
{
CAGE_ASSERT(data.scroll.valid());
hierarchy->childrenEmit();
for (uint32 a = 0; a < 2; a++)
{
Expand Down
2 changes: 1 addition & 1 deletion sources/libengine/gui/tooltips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace cage
return nullptr;
}

// test of B is descendant of A
// test if B is descendant of A
bool isDescendantOf(const HierarchyItem *a, const HierarchyItem *b)
{
if (a == b)
Expand Down

0 comments on commit af7856c

Please sign in to comment.