From e087a3666bca1cc6516accc632e8e28e0fc5f9e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= Date: Tue, 26 Dec 2017 21:55:11 +0100 Subject: [PATCH] Fix regression caused by backward compatibility support in data source We should only enforce the check whether a data source has set the actions for drag on drop on a selection if it's at least version 3. For backward compatibility we used to set a default action which would ensure that a version <3 and >3 client can interact with each other. But due to that the action was set to a default value which breaks any selection. Sorry about that. This change ensures the backward compatibility behavior does not break selection. As the regression causes all clients to quit it is a severe regression which requires fast action. Due to that I'm doing a maintainer push without review. I encourage everyone to do a post commit review. Sorry for not noticing the regression before. The backward compatibility was the last thing I added in that patch set and apparently I did not run all tests again. --- src/wayland/autotests/client/test_datadevice.cpp | 1 + src/wayland/autotests/client/test_datasource.cpp | 1 + src/wayland/datadevice_interface.cpp | 2 +- src/wayland/datasource_interface.cpp | 7 +++++-- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/wayland/autotests/client/test_datadevice.cpp b/src/wayland/autotests/client/test_datadevice.cpp index bcdf1d94e4..eca1cdb9d6 100644 --- a/src/wayland/autotests/client/test_datadevice.cpp +++ b/src/wayland/autotests/client/test_datadevice.cpp @@ -73,6 +73,7 @@ static const QString s_socketName = QStringLiteral("kwayland-test-wayland-datade void TestDataDevice::init() { + qRegisterMetaType(); using namespace KWayland::Server; delete m_display; m_display = new Display(this); diff --git a/src/wayland/autotests/client/test_datasource.cpp b/src/wayland/autotests/client/test_datasource.cpp index ab4c9c6072..bd8b0811d5 100644 --- a/src/wayland/autotests/client/test_datasource.cpp +++ b/src/wayland/autotests/client/test_datasource.cpp @@ -132,6 +132,7 @@ void TestDataSource::testOffer() using namespace KWayland::Client; using namespace KWayland::Server; + qRegisterMetaType(); QSignalSpy dataSourceCreatedSpy(m_dataDeviceManagerInterface, SIGNAL(dataSourceCreated(KWayland::Server::DataSourceInterface*))); QVERIFY(dataSourceCreatedSpy.isValid()); diff --git a/src/wayland/datadevice_interface.cpp b/src/wayland/datadevice_interface.cpp index e7af140590..8ba19ba878 100644 --- a/src/wayland/datadevice_interface.cpp +++ b/src/wayland/datadevice_interface.cpp @@ -123,7 +123,7 @@ void DataDeviceInterface::Private::setSelectionCallback(wl_client *client, wl_re void DataDeviceInterface::Private::setSelection(DataSourceInterface *dataSource) { - if (dataSource->supportedDragAndDropActions()) { + if (dataSource && dataSource->supportedDragAndDropActions() && wl_resource_get_version(dataSource->resource()) >= WL_DATA_SOURCE_ACTION_SINCE_VERSION) { wl_resource_post_error(dataSource->resource(), WL_DATA_SOURCE_ERROR_INVALID_SOURCE, "Data source is for drag and drop"); return; } diff --git a/src/wayland/datasource_interface.cpp b/src/wayland/datasource_interface.cpp index 96f277ffb0..8ebb240909 100644 --- a/src/wayland/datasource_interface.cpp +++ b/src/wayland/datasource_interface.cpp @@ -40,8 +40,7 @@ public: ~Private(); QStringList mimeTypes; - // sensible default for < version 3 - DataDeviceManagerInterface::DnDActions supportedDnDActions = DataDeviceManagerInterface::DnDAction::Copy; + DataDeviceManagerInterface::DnDActions supportedDnDActions = DataDeviceManagerInterface::DnDAction::None; private: DataSourceInterface *q_func() { @@ -111,6 +110,10 @@ void DataSourceInterface::Private::setActionsCallback(wl_client *client, wl_reso DataSourceInterface::DataSourceInterface(DataDeviceManagerInterface *parent, wl_resource *parentResource) : Resource(new Private(this, parent, parentResource)) { + if (wl_resource_get_version(parentResource) < WL_DATA_SOURCE_ACTION_SINCE_VERSION) { + Q_D(); + d->supportedDnDActions = DataDeviceManagerInterface::DnDAction::Copy; + } } DataSourceInterface::~DataSourceInterface() = default;