mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-21 18:40:01 +00:00
Clamp widgets coordinates to avoid crashes
This commit is contained in:
parent
2438fb4c98
commit
2264d067fc
@ -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();
|
||||||
|
|
||||||
|
@ -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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user