diff options
author | Jan Arve Saether <jan-arve.saether@digia.com> | 2014-01-09 12:45:14 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-09 19:27:32 +0100 |
commit | 0efc6e92d8008127c162e3c2721e6f4364aae8ab (patch) | |
tree | ae73227a332cecb0b97b10d39c8d727d4cdbfb66 /src/gui/kernel/qplatformwindow.cpp | |
parent | 097b0a531642f79d8b240f89ca1eacca2ee59a5e (diff) |
Use the default height (not 0) if only width is specified
If width was specified, but not height (or vice versa) the actual
window size was not as expected:
* The window width was not the width specified.
* The window height became 0.
This was unexpected, since if both width and height was not specified
it would fallback to becoming 160x160 (on Windows).
However, with the advent of https://codereview.qt-project.org/71999
both width and height might receive sensible defaults based on the
content of the ApplicationWindow, which would mean that it might be
reasonable to expect that you only need to specify one size component
of the window.
This also fixes an assertion in file
..\..\..\3rdparty\angle\src\libGLESv2\renderer\SwapChain9.cpp, line 81
The assertion happened when a window was created with 0 height (but
valid width), and then its height got increased, causing it to become
visible.
Change-Id: Ia9e730418e35d679907bdcc59b00c3c988216c32
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'src/gui/kernel/qplatformwindow.cpp')
-rw-r--r-- | src/gui/kernel/qplatformwindow.cpp | 15 |
1 files changed, 7 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) { |