mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-19 21:10:12 +02:00
Fix crash on accepting turn in MP with settings window open
This commit is contained in:
parent
386679294f
commit
cf44186a11
@ -62,6 +62,7 @@
|
|||||||
#include "windows/CTutorialWindow.h"
|
#include "windows/CTutorialWindow.h"
|
||||||
#include "windows/GUIClasses.h"
|
#include "windows/GUIClasses.h"
|
||||||
#include "windows/InfoWindows.h"
|
#include "windows/InfoWindows.h"
|
||||||
|
#include "windows/settings/SettingsMainWindow.h"
|
||||||
|
|
||||||
#include "../CCallback.h"
|
#include "../CCallback.h"
|
||||||
|
|
||||||
@ -187,6 +188,7 @@ void CPlayerInterface::closeAllDialogs()
|
|||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
auto adventureWindow = GH.windows().topWindow<AdventureMapInterface>();
|
auto adventureWindow = GH.windows().topWindow<AdventureMapInterface>();
|
||||||
|
auto settingsWindow = GH.windows().topWindow<SettingsMainWindow>();
|
||||||
auto infoWindow = GH.windows().topWindow<CInfoWindow>();
|
auto infoWindow = GH.windows().topWindow<CInfoWindow>();
|
||||||
auto topWindow = GH.windows().topWindow<WindowBase>();
|
auto topWindow = GH.windows().topWindow<WindowBase>();
|
||||||
|
|
||||||
@ -196,10 +198,16 @@ void CPlayerInterface::closeAllDialogs()
|
|||||||
if(infoWindow && infoWindow->ID != QueryID::NONE)
|
if(infoWindow && infoWindow->ID != QueryID::NONE)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (topWindow == nullptr)
|
if (settingsWindow)
|
||||||
throw std::runtime_error("Invalid or non-existing top window! Total windows: " + std::to_string(GH.windows().count()));
|
{
|
||||||
|
settingsWindow->close();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (topWindow)
|
||||||
topWindow->close();
|
topWindow->close();
|
||||||
|
else
|
||||||
|
GH.windows().popWindows(1); // does not inherits from WindowBase, e.g. settings dialog
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ void WindowBase::close()
|
|||||||
if(!GH.windows().isTopWindow(this))
|
if(!GH.windows().isTopWindow(this))
|
||||||
{
|
{
|
||||||
auto topWindow = GH.windows().topWindow<IShowActivatable>().get();
|
auto topWindow = GH.windows().topWindow<IShowActivatable>().get();
|
||||||
throw std::runtime_error(std::string("Only top interface can be closed! Top window is ") + typeid(*this).name() + " but attempted to close " + typeid(*topWindow).name());
|
throw std::runtime_error(std::string("Only top interface can be closed! Top window is ") + typeid(*topWindow).name() + " but attempted to close " + typeid(*this).name());
|
||||||
}
|
}
|
||||||
GH.windows().popWindows(1);
|
GH.windows().popWindows(1);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ private:
|
|||||||
std::shared_ptr<CIntObject> createTab(size_t index);
|
std::shared_ptr<CIntObject> createTab(size_t index);
|
||||||
void openTab(size_t index);
|
void openTab(size_t index);
|
||||||
|
|
||||||
void close(); //TODO: copypaste of WindowBase::close(), consider changing Windowbase to IWindowbase with default close() implementation and changing WindowBase inheritance to CIntObject + IWindowBase
|
|
||||||
|
|
||||||
void loadGameButtonCallback();
|
void loadGameButtonCallback();
|
||||||
void saveGameButtonCallback();
|
void saveGameButtonCallback();
|
||||||
@ -40,6 +39,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
SettingsMainWindow(BattleInterface * parentBattleInterface = nullptr);
|
SettingsMainWindow(BattleInterface * parentBattleInterface = nullptr);
|
||||||
|
|
||||||
|
void close(); //TODO: copypaste of WindowBase::close(), consider changing Windowbase to IWindowbase with default close() implementation and changing WindowBase inheritance to CIntObject + IWindowBase
|
||||||
void showAll(Canvas & to) override;
|
void showAll(Canvas & to) override;
|
||||||
void onScreenResize() override;
|
void onScreenResize() override;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user