1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-20 23:11:36 +00:00

Merge branch 'editor-crash' into 'master'

Clamp widgets coordinates to avoid editor crashes

See merge request OpenMW/openmw!4043
This commit is contained in:
psi29a 2024-04-23 07:04:09 +00:00
commit 9662586947
2 changed files with 19 additions and 2 deletions

View file

@ -1110,7 +1110,16 @@ void CSVDoc::View::updateWidth(bool isGrowLimit, int minSubViewWidth)
{ {
QRect rect; QRect rect;
if (isGrowLimit) if (isGrowLimit)
rect = QApplication::screenAt(pos())->geometry(); {
// Widget position can be negative, we should clamp it.
QPoint position = pos();
if (position.x() <= 0)
position.setX(0);
if (position.y() <= 0)
position.setY(0);
rect = QApplication::screenAt(position)->geometry();
}
else else
rect = desktopRect(); rect = desktopRect();

View file

@ -78,8 +78,16 @@ CSVWorld::TableSubView::TableSubView(
widget->setLayout(layout); widget->setLayout(layout);
setWidget(widget); setWidget(widget);
// Widget position can be negative, we should clamp it.
QPoint position = pos();
if (position.x() <= 0)
position.setX(0);
if (position.y() <= 0)
position.setY(0);
// prefer height of the screen and full width of the table // prefer height of the screen and full width of the table
const QRect rect = QApplication::screenAt(pos())->geometry(); const QRect rect = QApplication::screenAt(position)->geometry();
int frameHeight = 40; // set a reasonable default int frameHeight = 40; // set a reasonable default
QWidget* topLevel = QApplication::topLevelAt(pos()); QWidget* topLevel = QApplication::topLevelAt(pos());
if (topLevel) if (topLevel)