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(); };