[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
This commit is contained in:
Martin Gräßlin 2016-10-24 11:17:36 +02:00
parent be04b54827
commit 80d45c4c21
2 changed files with 5 additions and 1 deletions

View file

@ -1680,6 +1680,10 @@ void TestWaylandSeat::testDataDeviceForKeyboardSurface()
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();

View file

@ -929,7 +929,7 @@ void SeatInterface::setFocusedKeyboardSurface(SurfaceInterface *surface)
// 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();