From a55d86be87c559ff971975baffe84148cc53e21a Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Thu, 2 Mar 2023 16:05:05 +0000 Subject: [PATCH] tests: Only track one data offer during a drag A drag consists of one data source which in turn will be represented by one data device sent to each client. We don't need to manage a list Change-Id: Icd2aba3ced1d8254d15400b0b687888b0872cc35 Pick-to: 6.7 Reviewed-by: David Edmundson --- tests/auto/wayland/shared/datadevice.cpp | 11 ++++------- tests/auto/wayland/shared/datadevice.h | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/auto/wayland/shared/datadevice.cpp b/tests/auto/wayland/shared/datadevice.cpp index 26ebec6bd2e..2a874a77faf 100644 --- a/tests/auto/wayland/shared/datadevice.cpp +++ b/tests/auto/wayland/shared/datadevice.cpp @@ -51,7 +51,7 @@ DataOffer *DataDevice::sendDataOffer(wl_client *client, const QStringList &mimeT { Q_ASSERT(client); auto *offer = new DataOffer(this, client, m_manager->m_version); - m_offers << offer; + m_offer = offer; for (auto *resource : resourceMap().values(client)) wl_data_device::send_data_offer(resource->handle, offer->resource()->handle); for (const auto &mimeType : mimeTypes) @@ -71,8 +71,8 @@ void DataDevice::sendEnter(Surface *surface, const QPoint &position) { uint serial = m_manager->m_compositor->nextSerial(); Resource *resource = resourceMap().value(surface->resource()->client()); - for (DataOffer *offer: m_offers) - wl_data_device::send_enter(resource->handle, serial, surface->resource()->handle, position.x(), position.y(), offer->resource()->handle); + if (m_offer) + wl_data_device::send_enter(resource->handle, serial, surface->resource()->handle, position.x(), position.y(), m_offer->resource()->handle); } void DataDevice::sendMotion(Surface *surface, const QPoint &position) @@ -108,10 +108,7 @@ void DataOffer::data_offer_receive(Resource *resource, const QString &mime_type, void DataOffer::data_offer_destroy(QtWaylandServer::wl_data_offer::Resource *resource) { - bool removed = m_dataDevice->m_sentSelectionOffers.removeOne(this); - if (!removed) - removed = m_dataDevice->m_offers.removeOne(this); - QVERIFY(removed); + m_dataDevice->m_sentSelectionOffers.removeOne(this); wl_resource_destroy(resource->handle); } diff --git a/tests/auto/wayland/shared/datadevice.h b/tests/auto/wayland/shared/datadevice.h index ee1e57d655d..792a3e4bb3a 100644 --- a/tests/auto/wayland/shared/datadevice.h +++ b/tests/auto/wayland/shared/datadevice.h @@ -63,7 +63,7 @@ public: DataDeviceManager *m_manager = nullptr; Seat *m_seat = nullptr; QList m_sentSelectionOffers; - QList m_offers; + QPointer m_offer; signals: void dragStarted();