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 a33cc547055eb12c5efa82a6612cbf8793988b72)
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
This commit is contained in:
Johan Klokkhammer Helsing 2016-10-10 17:52:15 +02:00 committed by Giulio Camuffo
parent 0f8195c08e
commit e8a4ffff20
3 changed files with 10 additions and 1 deletions

View File

@ -411,6 +411,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

View File

@ -170,6 +170,7 @@ public:
void handleWindowActivated(QWaylandWindow *window);
void handleWindowDeactivated(QWaylandWindow *window);
void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
void handleWindowDestroyed(QWaylandWindow *window);
public slots:
void blockingReadEvents();
@ -211,7 +212,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;

View File

@ -93,6 +93,8 @@ QWaylandWindow::QWaylandWindow(QWindow *window)
QWaylandWindow::~QWaylandWindow()
{
mDisplay->handleWindowDestroyed(this);
delete mWindowDecoration;
if (isInitialized())