From 7548e058a5c396951362f3df696fb1d6d9d70556 Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Sun, 7 Jan 2024 19:41:15 +0100 Subject: [PATCH] Overlay: ProfileSessionListener - fix crash in finializeSession --- .../Overlay/src/OgreOverlayProfileSessionListener.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Components/Overlay/src/OgreOverlayProfileSessionListener.cpp b/Components/Overlay/src/OgreOverlayProfileSessionListener.cpp index 8b210c1f0b9..81b94a45609 100644 --- a/Components/Overlay/src/OgreOverlayProfileSessionListener.cpp +++ b/Components/Overlay/src/OgreOverlayProfileSessionListener.cpp @@ -110,11 +110,10 @@ namespace Ogre OverlayContainer* container = dynamic_cast(mProfileGui); if (container) { - for (const auto& p : container->getChildren()) + while (!container->getChildren().empty()) { - OverlayElement* element = p.second; - OverlayContainer* parent = element->getParent(); - if (parent) parent->removeChild(element->getName()); + OverlayElement* element = container->getChildren().cbegin()->second; + container->removeChild(element->getName()); OverlayManager::getSingleton().destroyOverlayElement(element); } }