Fix infinite recursion when changing geometry on Mac
Some complex widgets might get a negatively sized rectangle when calling QWidgetPrivate:setGeometry_sys_helper(), triggering a infinite recursion. Normalizing the rectangle size before checking for size change is enough to break this infinite recursion. Task-number: QTBUG-17333 Change-Id: I4682c3088ea53fb9f28f746c8264f573b5284825 Reviewed-on: http://codereview.qt.nokia.com/156 Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com>bb10
parent
bbbea1fa96
commit
d49973f834
|
|
@ -4541,6 +4541,11 @@ void QWidgetPrivate::setGeometry_sys_helper(int x, int y, int w, int h, bool isM
|
|||
|
||||
QPoint oldp = q->pos();
|
||||
QSize olds = q->size();
|
||||
// Apply size restrictions, applicable for Windows & Widgets.
|
||||
if (QWExtra *extra = extraData()) {
|
||||
w = qBound(extra->minw, w, extra->maxw);
|
||||
h = qBound(extra->minh, h, extra->maxh);
|
||||
}
|
||||
const bool isResize = (olds != QSize(w, h));
|
||||
|
||||
if (!realWindow && !isResize && QPoint(x, y) == oldp)
|
||||
|
|
@ -4550,13 +4555,6 @@ void QWidgetPrivate::setGeometry_sys_helper(int x, int y, int w, int h, bool isM
|
|||
data.window_state = data.window_state & ~Qt::WindowMaximized;
|
||||
|
||||
const bool visible = q->isVisible();
|
||||
// Apply size restrictions, applicable for Windows & Widgets.
|
||||
if (QWExtra *extra = extraData()) {
|
||||
w = qMin(w, extra->maxw);
|
||||
h = qMin(h, extra->maxh);
|
||||
w = qMax(w, extra->minw);
|
||||
h = qMax(h, extra->minh);
|
||||
}
|
||||
data.crect = QRect(x, y, w, h);
|
||||
|
||||
if (realWindow) {
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@
|
|||
#include <QtGui/qpaintengine.h>
|
||||
#include <private/qbackingstore_p.h>
|
||||
#include <qmenubar.h>
|
||||
#include <qtableview.h>
|
||||
|
||||
#include <QtGui/QGraphicsView>
|
||||
#include <QtGui/QGraphicsProxyWidget>
|
||||
|
|
@ -403,6 +404,7 @@ private slots:
|
|||
void taskQTBUG_11373();
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
#endif
|
||||
void taskQTBUG_17333_ResizeInfiniteRecursion();
|
||||
|
||||
void nativeChildFocus();
|
||||
|
||||
|
|
@ -10464,6 +10466,18 @@ void tst_QWidget::taskQTBUG_11373()
|
|||
#endif // QT_MAC_USE_COCOA
|
||||
#endif
|
||||
|
||||
void tst_QWidget::taskQTBUG_17333_ResizeInfiniteRecursion()
|
||||
{
|
||||
QTableView tb;
|
||||
const char *s = "border: 1px solid;";
|
||||
tb.setStyleSheet(s);
|
||||
tb.show();
|
||||
|
||||
QTest::qWaitForWindowShown(&tb);
|
||||
tb.setGeometry(QRect(100, 100, 0, 100));
|
||||
// No crash, it works.
|
||||
}
|
||||
|
||||
void tst_QWidget::nativeChildFocus()
|
||||
{
|
||||
QWidget w;
|
||||
|
|
|
|||
Loading…
Reference in New Issue