Commit 4f100d2a authored by Martin Flöser's avatar Martin Flöser
Browse files

[server] Fix crash on updating focused keyboard surface

Summary:
In case the current selection does not have a DataSourceInterface
updating the focused keyboard surface resulted in a crash. The current
selection is sent to the DataDeviceInterface of the newly focused
client and thus a DataOfferInterface would be created for a null
DataSourceInterface.

This is a similar fix as D3148 and D3149.

Test Plan: Test case added which used to crash before

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D3150
parent b03cda2b
...@@ -1680,6 +1680,10 @@ void TestWaylandSeat::testDataDeviceForKeyboardSurface() ...@@ -1680,6 +1680,10 @@ void TestWaylandSeat::testDataDeviceForKeyboardSurface()
QVERIFY(dd->isValid()); QVERIFY(dd->isValid());
QVERIFY(ddiCreatedSpy.wait()); QVERIFY(ddiCreatedSpy.wait());
// unset surface and set again
m_seatInterface->setFocusedKeyboardSurface(nullptr);
m_seatInterface->setFocusedKeyboardSurface(serverSurface);
// and delete the connection thread again // and delete the connection thread again
dd1.reset(); dd1.reset();
ddm1.reset(); ddm1.reset();
......
...@@ -929,7 +929,7 @@ void SeatInterface::setFocusedKeyboardSurface(SurfaceInterface *surface) ...@@ -929,7 +929,7 @@ void SeatInterface::setFocusedKeyboardSurface(SurfaceInterface *surface)
// selection? // selection?
d->keys.focus.selection = d->dataDeviceForSurface(surface); d->keys.focus.selection = d->dataDeviceForSurface(surface);
if (d->keys.focus.selection) { if (d->keys.focus.selection) {
if (d->currentSelection) { if (d->currentSelection && d->currentSelection->selection()) {
d->keys.focus.selection->sendSelection(d->currentSelection); d->keys.focus.selection->sendSelection(d->currentSelection);
} else { } else {
d->keys.focus.selection->sendClearSelection(); d->keys.focus.selection->sendClearSelection();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment