summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2016-10-10 17:52:15 +0200
committerJani Heikkinen <jani.heikkinen@qt.io>2016-10-25 04:09:38 +0000
commite522b44dd3ba6a15d9bd0c9c7396027facff0d8f (patch)
tree7dbc624b452f14e2e6035b9cfc785fc4cdc49a3e
parentf42acb26fba9660c1bc441385709431771fe46c0 (diff)
Client: Remove windows from keyboard focus list when destroyed
This fixes the undefined behavior in tst_WaylandClient::touchDrag and mouseDrag Note: The test still fails if run twice in a row, but it appears to be deterministic. Task-number: QTBUG-56187 Change-Id: Ib45d82224f004d1324f2ce4d6b7df05ee36c04f5 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> (cherry picked from commit 0049240a2b7d8691f09224e1542919ddbbb0d864) Reviewed-by: Johan Helsing <johan.helsing@qt.io>
-rw-r--r--src/client/qwaylanddisplay.cpp6
-rw-r--r--src/client/qwaylanddisplay_p.h3
-rw-r--r--src/client/qwaylandwindow.cpp2
3 files changed, 10 insertions, 1 deletions
diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp
index a5e61e28a..6e167f303 100644
--- a/src/client/qwaylanddisplay.cpp
+++ b/src/client/qwaylanddisplay.cpp
@@ -421,6 +421,12 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
mLastKeyboardFocus = keyboardFocus;
}
+void QWaylandDisplay::handleWindowDestroyed(QWaylandWindow *window)
+{
+ if (mActiveWindows.contains(window))
+ handleWindowDeactivated(window);
+}
+
void QWaylandDisplay::handleWaylandSync()
{
// This callback is used to set the window activation because we may get an activate/deactivate
diff --git a/src/client/qwaylanddisplay_p.h b/src/client/qwaylanddisplay_p.h
index f4fb3fa56..2864b357d 100644
--- a/src/client/qwaylanddisplay_p.h
+++ b/src/client/qwaylanddisplay_p.h
@@ -176,6 +176,7 @@ public:
void handleWindowActivated(QWaylandWindow *window);
void handleWindowDeactivated(QWaylandWindow *window);
void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+ void handleWindowDestroyed(QWaylandWindow *window);
public slots:
void blockingReadEvents();
@@ -217,7 +218,7 @@ private:
uint32_t mLastInputSerial;
QWaylandInputDevice *mLastInputDevice;
QPointer<QWaylandWindow> mLastInputWindow;
- QWaylandWindow *mLastKeyboardFocus;
+ QPointer<QWaylandWindow> mLastKeyboardFocus;
QVector<QWaylandWindow *> mActiveWindows;
struct wl_callback *mSyncCallback;
static const wl_callback_listener syncCallbackListener;
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index eb9c14094..725645191 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -102,6 +102,8 @@ QWaylandWindow::QWaylandWindow(QWindow *window)
QWaylandWindow::~QWaylandWindow()
{
+ mDisplay->handleWindowDestroyed(this);
+
delete mWindowDecoration;
if (isInitialized())