From e843af24bf4524b971825d7691b1b07276ab941b Mon Sep 17 00:00:00 2001 From: Dydzio Date: Wed, 11 Sep 2024 23:00:06 +0200 Subject: [PATCH] Fix broken popping of top interfaces when town was opened during multiplayer game --- client/CPlayerInterface.cpp | 13 +++---------- client/gui/CIntObject.cpp | 2 +- client/gui/CIntObject.h | 1 - 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 9a690d502..e88caf65d 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -172,10 +172,11 @@ void CPlayerInterface::initGameInterface(std::shared_ptr ENV, std:: void CPlayerInterface::closeAllDialogs() { // remove all active dialogs that do not expect query answer - for (;;) + while(true) { auto adventureWindow = GH.windows().topWindow(); auto infoWindow = GH.windows().topWindow(); + auto topWindow = GH.windows().topWindow(); if(adventureWindow != nullptr) break; @@ -183,16 +184,8 @@ void CPlayerInterface::closeAllDialogs() if(infoWindow && infoWindow->ID != QueryID::NONE) break; - if (infoWindow) - infoWindow->close(); - else - GH.windows().popWindows(1); + topWindow->close(); } - - if(castleInt) - castleInt->close(); - - castleInt = nullptr; } void CPlayerInterface::playerEndsTurn(PlayerColor player) diff --git a/client/gui/CIntObject.cpp b/client/gui/CIntObject.cpp index 3f136151e..e2fa75409 100644 --- a/client/gui/CIntObject.cpp +++ b/client/gui/CIntObject.cpp @@ -341,6 +341,6 @@ WindowBase::WindowBase(int used_, Point pos_) void WindowBase::close() { if(!GH.windows().isTopWindow(this)) - logGlobal->error("Only top interface must be closed"); + throw std::runtime_error("Only top interface can be closed"); GH.windows().popWindows(1); } diff --git a/client/gui/CIntObject.h b/client/gui/CIntObject.h index bde3c1f81..336297227 100644 --- a/client/gui/CIntObject.h +++ b/client/gui/CIntObject.h @@ -146,7 +146,6 @@ class WindowBase : public CIntObject { public: WindowBase(int used_ = 0, Point pos_ = Point()); -protected: virtual void close(); };