From c793dd93d254977f3b5adb4ce1051785282da123 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 25 Jan 2022 09:59:59 +0200 Subject: [PATCH] Make data source objects "parentless" The SeatInterface cleans up currentSelection and currentPrimarySelection when the AbstractDataSource::aboutToBeDestroyed() signal is emitted, but since the data source and primary data source have parent objects, they can be potentially destroyed without emitting the aboutToBeDestroyed() signal and thus leaving dangling pointers in SeatInterface. CCBUG: 449101 --- src/wayland/datasource_interface.cpp | 3 +-- src/wayland/primaryselectionsource_v1_interface.cpp | 3 +-- src/wayland/seat_interface.cpp | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/wayland/datasource_interface.cpp b/src/wayland/datasource_interface.cpp index 445765a064..7789027d26 100644 --- a/src/wayland/datasource_interface.cpp +++ b/src/wayland/datasource_interface.cpp @@ -94,8 +94,7 @@ void DataSourceInterfacePrivate::data_source_set_actions(Resource *resource, uin } DataSourceInterface::DataSourceInterface(DataDeviceManagerInterface *parent, wl_resource *resource) - : AbstractDataSource(parent) - , d(new DataSourceInterfacePrivate(this, resource)) + : d(new DataSourceInterfacePrivate(this, resource)) { if (d->resource()->version() < WL_DATA_SOURCE_ACTION_SINCE_VERSION) { d->supportedDnDActions = DataDeviceManagerInterface::DnDAction::Copy; diff --git a/src/wayland/primaryselectionsource_v1_interface.cpp b/src/wayland/primaryselectionsource_v1_interface.cpp index 396f0f9abf..38ceb55b21 100644 --- a/src/wayland/primaryselectionsource_v1_interface.cpp +++ b/src/wayland/primaryselectionsource_v1_interface.cpp @@ -56,8 +56,7 @@ void PrimarySelectionSourceV1InterfacePrivate::zwp_primary_selection_source_v1_d } PrimarySelectionSourceV1Interface::PrimarySelectionSourceV1Interface(PrimarySelectionDeviceManagerV1Interface *parent, ::wl_resource *resource) - : AbstractDataSource(parent) - , d(new PrimarySelectionSourceV1InterfacePrivate(this, resource)) + : d(new PrimarySelectionSourceV1InterfacePrivate(this, resource)) { } diff --git a/src/wayland/seat_interface.cpp b/src/wayland/seat_interface.cpp index a883d963e3..0d75828131 100644 --- a/src/wayland/seat_interface.cpp +++ b/src/wayland/seat_interface.cpp @@ -1239,7 +1239,7 @@ void SeatInterface::setSelection(AbstractDataSource *selection) auto cleanup = [this]() { setSelection(nullptr); }; - connect(selection, &DataSourceInterface::aboutToBeDestroyed, this, cleanup); + connect(selection, &AbstractDataSource::aboutToBeDestroyed, this, cleanup); } d->currentSelection = selection; @@ -1282,7 +1282,7 @@ void SeatInterface::setPrimarySelection(AbstractDataSource *selection) auto cleanup = [this]() { setPrimarySelection(nullptr); }; - connect(selection, &DataSourceInterface::aboutToBeDestroyed, this, cleanup); + connect(selection, &AbstractDataSource::aboutToBeDestroyed, this, cleanup); } d->currentPrimarySelection = selection;