[DataOffer] Avoid calls on null DataSource

A DataOffer can slightly outlive a DataSource; a client will still be
told it's deleted but could call a method in a race.

DataOfferInterface correctly checks for source being still valid, but
nothing updates it when it gets deleted.

BUG: 396308
This commit is contained in:
David Edmundson 2020-09-18 16:48:16 +01:00
parent 456106d749
commit 0b3cca4ae0

View file

@ -8,6 +8,9 @@
#include "dataoffer_interface.h"
#include "datasource_interface.h"
#include "resource_p.h"
#include <QPointer>
#include <wayland-server.h>
namespace KWaylandServer
@ -18,7 +21,7 @@ class Q_DECL_HIDDEN DataOfferInterface::Private : public Resource::Private
public:
Private(AbstractDataSource *source, DataDeviceInterface *parentInterface, DataOfferInterface *q, wl_resource *parentResource);
~Private();
AbstractDataSource *source;
QPointer<AbstractDataSource> source;
DataDeviceInterface *dataDevice;
// defaults are set to sensible values for < version 3 interfaces
DataDeviceManagerInterface::DnDActions supportedDnDActions = DataDeviceManagerInterface::DnDAction::Copy | DataDeviceManagerInterface::DnDAction::Move;