diff options
-rw-r--r-- | src/gui/kernel/qplatformwindow.cpp | 15 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 27 |
2 files changed, 34 insertions, 8 deletions
diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index 954d47f18c..fe29627c5a 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -521,14 +521,13 @@ QRect QPlatformWindow::initialGeometry(const QWindow *w, const QRect &initialGeometry, int defaultWidth, int defaultHeight) { QRect rect(initialGeometry); - if (rect.isNull()) { - QSize minimumSize = w->minimumSize(); - if (minimumSize.width() > 0 || minimumSize.height() > 0) { - rect.setSize(minimumSize); - } else { - rect.setWidth(defaultWidth); - rect.setHeight(defaultHeight); - } + if (rect.width() == 0) { + const int minWidth = w->minimumWidth(); + rect.setWidth(minWidth > 0 ? minWidth : defaultWidth); + } + if (rect.height() == 0) { + const int minHeight = w->minimumHeight(); + rect.setHeight(minHeight > 0 ? minHeight : defaultHeight); } if (w->isTopLevel() && qt_window_private(const_cast<QWindow*>(w))->positionAutomatic && w->type() != Qt::Popup) { diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 76b3a4f6cc..7e6313295b 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -82,6 +82,7 @@ private slots: void windowModality_QTBUG27039(); void visibility(); void mask(); + void initialSize(); void initTestCase() { @@ -1186,6 +1187,32 @@ void tst_QWindow::mask() QCOMPARE(window.mask(), mask); } +void tst_QWindow::initialSize() +{ + QSize defaultSize(0,0); + { + Window w; + w.show(); + QTRY_VERIFY(w.width() > 0); + QTRY_VERIFY(w.height() > 0); + defaultSize = QSize(w.width(), w.height()); + } + { + Window w; + w.setWidth(200); + w.show(); + QTRY_COMPARE(w.width(), 200); + QTRY_VERIFY(w.height() > 0); + } + { + Window w; + w.resize(200, 42); + w.show(); + QTRY_COMPARE(w.width(), 200); + QTRY_COMPARE(w.height(), 42); + } +} + #include <tst_qwindow.moc> QTEST_MAIN(tst_QWindow) |