1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-23 00:28:08 +02:00

Fix crash on accepting turn in MP with settings window open

This commit is contained in:
Ivan Savenko
2025-02-01 12:17:17 +00:00
parent 386679294f
commit cf44186a11
3 changed files with 13 additions and 5 deletions

@ -62,6 +62,7 @@
#include "windows/CTutorialWindow.h"
#include "windows/GUIClasses.h"
#include "windows/InfoWindows.h"
#include "windows/settings/SettingsMainWindow.h"
#include "../CCallback.h"
@ -187,6 +188,7 @@ void CPlayerInterface::closeAllDialogs()
while(true)
{
auto adventureWindow = GH.windows().topWindow<AdventureMapInterface>();
auto settingsWindow = GH.windows().topWindow<SettingsMainWindow>();
auto infoWindow = GH.windows().topWindow<CInfoWindow>();
auto topWindow = GH.windows().topWindow<WindowBase>();
@ -196,10 +198,16 @@ void CPlayerInterface::closeAllDialogs()
if(infoWindow && infoWindow->ID != QueryID::NONE)
break;
if (topWindow == nullptr)
throw std::runtime_error("Invalid or non-existing top window! Total windows: " + std::to_string(GH.windows().count()));
if (settingsWindow)
{
settingsWindow->close();
continue;
}
topWindow->close();
if (topWindow)
topWindow->close();
else
GH.windows().popWindows(1); // does not inherits from WindowBase, e.g. settings dialog
}
}