From 3a2ece17c3ddcfba584cfdf90482a260d7e9c3ee Mon Sep 17 00:00:00 2001 From: Tomasz Olszak Date: Tue, 14 Jan 2014 21:29:08 +0100 Subject: [PATCH] Don't flushWindowSystemEvents in QWaylandWindow ctor. tests/auto/gui/kernel/qbackingstore test crashed because the flush in QWaylandWindow::setWindowState invoked backing store expose event handling which in turn tried to use related (not yet created) QWaylandWindow. Change-Id: Ic9f29cc3433e6e671deb756aebe26530ebc72042 Reviewed-by: Laszlo Agocs --- .../platforms/wayland/qwaylandwindow.cpp | 58 ++++++++++--------- .../platforms/wayland/qwaylandwindow_p.h | 2 + 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 810239a7b7a..3c7b2eac165 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -119,7 +119,7 @@ QWaylandWindow::QWaylandWindow(QWindow *window) setWindowFlags(window->flags()); setGeometry(window->geometry()); - setWindowState(window->windowState()); + setWindowStateInternal(window->windowState()); } QWaylandWindow::~QWaylandWindow() @@ -409,31 +409,8 @@ void QWaylandWindow::handleContentOrientationChange(Qt::ScreenOrientation orient void QWaylandWindow::setWindowState(Qt::WindowState state) { - if (mState == state) { - return; - } - - // As of february 2013 QWindow::setWindowState sets the new state value after - // QPlatformWindow::setWindowState returns, so we cannot rely on QWindow::windowState - // here. We use then this mState variable. - mState = state; - createDecoration(); - switch (state) { - case Qt::WindowFullScreen: - mShellSurface->setFullscreen(); - break; - case Qt::WindowMaximized: - mShellSurface->setMaximized(); - break; - case Qt::WindowMinimized: - mShellSurface->setMinimized(); - break; - default: - mShellSurface->setNormal(); - } - - QWindowSystemInterface::handleWindowStateChanged(window(), mState); - QWindowSystemInterface::flushWindowSystemEvents(); // Required for oldState to work on WindowStateChanged + if (setWindowStateInternal(state)) + QWindowSystemInterface::flushWindowSystemEvents(); // Required for oldState to work on WindowStateChanged } void QWaylandWindow::setWindowFlags(Qt::WindowFlags flags) @@ -605,4 +582,33 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab) return true; } +bool QWaylandWindow::setWindowStateInternal(Qt::WindowState state) +{ + if (mState == state) { + return false; + } + + // As of february 2013 QWindow::setWindowState sets the new state value after + // QPlatformWindow::setWindowState returns, so we cannot rely on QWindow::windowState + // here. We use then this mState variable. + mState = state; + createDecoration(); + switch (state) { + case Qt::WindowFullScreen: + mShellSurface->setFullscreen(); + break; + case Qt::WindowMaximized: + mShellSurface->setMaximized(); + break; + case Qt::WindowMinimized: + mShellSurface->setMinimized(); + break; + default: + mShellSurface->setNormal(); + } + + QWindowSystemInterface::handleWindowStateChanged(window(), mState); + return true; +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/wayland/qwaylandwindow_p.h b/src/plugins/platforms/wayland/qwaylandwindow_p.h index 6078dab7f6e..e99e31bdf63 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow_p.h +++ b/src/plugins/platforms/wayland/qwaylandwindow_p.h @@ -204,6 +204,8 @@ protected: Qt::WindowState mState; private: + bool setWindowStateInternal(Qt::WindowState flags); + void handleMouseEventWithDecoration(QWaylandInputDevice *inputDevice, ulong timestamp, const QPointF & local,