Avoid integer overflow when positioning a dialog

Thanks to @fosnola for spotting
This commit is contained in:
2023-01-18 21:35:29 -05:00
parent 1bf079af5e
commit 03342627ec

View File

@@ -525,8 +525,8 @@ void cDialog::run(std::function<void(cDialog&)> onopen){
win.create(sf::VideoMode(1,1),"");
win.close();
win.create(sf::VideoMode(winRect.width(), winRect.height()), "Dialog", sf::Style::Titlebar);
winLastX = parentPos.x + int(parentSz.x - winRect.width()) / 2;
winLastY = parentPos.y + int(parentSz.y - winRect.height()) / 2;
winLastX = parentPos.x + (int(parentSz.x) - winRect.width()) / 2;
winLastY = parentPos.y + (int(parentSz.y) - winRect.height()) / 2;
win.setPosition({winLastX, winLastY});
draw();
makeFrontWindow(parent ? parent-> win : mainPtr);