diff --git a/autotests/client/test_wayland_seat.cpp b/autotests/client/test_wayland_seat.cpp --- a/autotests/client/test_wayland_seat.cpp +++ b/autotests/client/test_wayland_seat.cpp @@ -1680,6 +1680,10 @@ QVERIFY(dd->isValid()); QVERIFY(ddiCreatedSpy.wait()); + // unset surface and set again + m_seatInterface->setFocusedKeyboardSurface(nullptr); + m_seatInterface->setFocusedKeyboardSurface(serverSurface); + // and delete the connection thread again dd1.reset(); ddm1.reset(); diff --git a/src/server/seat_interface.cpp b/src/server/seat_interface.cpp --- a/src/server/seat_interface.cpp +++ b/src/server/seat_interface.cpp @@ -929,7 +929,7 @@ // selection? d->keys.focus.selection = d->dataDeviceForSurface(surface); if (d->keys.focus.selection) { - if (d->currentSelection) { + if (d->currentSelection && d->currentSelection->selection()) { d->keys.focus.selection->sendSelection(d->currentSelection); } else { d->keys.focus.selection->sendClearSelection();