Crash early before trying to create a window many times larger than the screen

Note: This could make certain larger dialogs always crash with a high enough pixel scale. Needs testing.
This commit is contained in:
2025-03-02 00:18:43 -05:00
committed by Celtic Minstrel
parent 9b05c23d15
commit 35b2ca4e3f

View File

@@ -505,6 +505,11 @@ void cDialog::run(std::function<void(cDialog&)> onopen){
currentFocus = iter->first;
}
}
// Make sure the requested size isn't insane.
auto desktop = sf::VideoMode::getDesktopMode();
if(winRect.width() > desktop.width || winRect.height() > desktop.height) {
throw std::string("Dialog ") + fname + std::string(" requested a crazy window size of ") + std::to_string(winRect.width()) + "x" + std::to_string(winRect.height());
}
// Sometimes it seems like the Cocoa menu handling clobbers the active rendering context.
// For whatever reason, delaying 100 milliseconds appears to fix this.
sf::sleep(sf::milliseconds(100));