1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Don't call ScreenHandler::onScreenResize() when the window has been (un)maximized to avoid creating a huge texture and crashing

This commit is contained in:
Alexander Wilms
2024-02-03 15:14:59 +01:00
parent caa22ad9d8
commit 0495c52cf4
5 changed files with 13 additions and 9 deletions

View File

@@ -145,7 +145,7 @@ void InputHandler::preprocessEvent(const SDL_Event & ev)
Settings full = settings.write["video"]["fullscreen"]; Settings full = settings.write["video"]["fullscreen"];
full->Bool() = !full->Bool(); full->Bool() = !full->Bool();
GH.onScreenResize(); GH.onScreenResize(false);
return; return;
} }
} }
@@ -163,7 +163,7 @@ void InputHandler::preprocessEvent(const SDL_Event & ev)
#ifndef VCMI_IOS #ifndef VCMI_IOS
{ {
boost::mutex::scoped_lock interfaceLock(GH.interfaceMutex); boost::mutex::scoped_lock interfaceLock(GH.interfaceMutex);
GH.onScreenResize(); GH.onScreenResize(false);
} }
#endif #endif
break; break;

View File

@@ -251,8 +251,11 @@ void CGuiHandler::setStatusbar(std::shared_ptr<IStatusBar> newStatusBar)
currentStatusBar = newStatusBar; currentStatusBar = newStatusBar;
} }
void CGuiHandler::onScreenResize() void CGuiHandler::onScreenResize(bool resolutionChanged)
{
if(resolutionChanged)
{ {
screenHandler().onScreenResize(); screenHandler().onScreenResize();
}
windows().onScreenResize(); windows().onScreenResize();
} }

View File

@@ -92,8 +92,8 @@ public:
void init(); void init();
void renderFrame(); void renderFrame();
/// called whenever user selects different resolution, requiring to center/resize all windows /// called whenever SDL_WINDOWEVENT_RESTORED is reported or the user selects a different resolution, requiring to center/resize all windows
void onScreenResize(); void onScreenResize(bool resolutionChanged);
void handleEvents(); //takes events from queue and calls interested objects void handleEvents(); //takes events from queue and calls interested objects
void fakeMouseMove(); void fakeMouseMove();

View File

@@ -397,6 +397,7 @@ SDL_Window * ScreenHandler::createWindow()
void ScreenHandler::onScreenResize() void ScreenHandler::onScreenResize()
{ {
recreateWindowAndScreenBuffers();
} }
void ScreenHandler::validateSettings() void ScreenHandler::validateSettings()

View File

@@ -317,7 +317,7 @@ void GeneralOptionsTab::setGameResolution(int index)
widget<CLabel>("resolutionLabel")->setText(resolutionToLabelString(resolution.x, resolution.y)); widget<CLabel>("resolutionLabel")->setText(resolutionToLabelString(resolution.x, resolution.y));
GH.dispatchMainThread([](){ GH.dispatchMainThread([](){
GH.onScreenResize(); GH.onScreenResize(true);
}); });
} }
@@ -341,7 +341,7 @@ void GeneralOptionsTab::setFullscreenMode(bool on, bool exclusive)
updateResolutionSelector(); updateResolutionSelector();
GH.dispatchMainThread([](){ GH.dispatchMainThread([](){
GH.onScreenResize(); GH.onScreenResize(true);
}); });
} }
@@ -400,7 +400,7 @@ void GeneralOptionsTab::setGameScaling(int index)
widget<CLabel>("scalingLabel")->setText(scalingToLabelString(scaling)); widget<CLabel>("scalingLabel")->setText(scalingToLabelString(scaling));
GH.dispatchMainThread([](){ GH.dispatchMainThread([](){
GH.onScreenResize(); GH.onScreenResize(true);
}); });
} }