Commit c793dd93 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

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
parent fd3a7c3c
......@@ -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;
......
......@@ -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))
{
}
......
......@@ -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;
......
Supports Markdown
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