[server] Wrap proxyRemoveSurface in smart pointer

Summary:
proxyRemoteSurface is a fake wayland surface created for the drag and
drop between X and wayland clients.

The lifespan is not guaranteed to outlive the DataDevice.

Kwin closes Xwl before the other wayland client connections so it's
technically dangling for a bit when events could be dispatched.

Probably will never happen, but better to guard and be safe.

Test Plan: Compiles

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D22862
This commit is contained in:
David Edmundson 2019-08-28 18:38:25 +01:00
parent b8c28c8a85
commit 6568802c95

View file

@ -61,7 +61,7 @@ public:
};
Drag drag;
SurfaceInterface *proxyRemoteSurface = nullptr;
QPointer<SurfaceInterface> proxyRemoteSurface;
private:
DataDeviceInterface *q_func() {
@ -104,7 +104,7 @@ void DataDeviceInterface::Private::startDrag(DataSourceInterface *dataSource, Su
SurfaceInterface *focusSurface = origin;
if (proxyRemoteSurface) {
// origin is a proxy surface
focusSurface = proxyRemoteSurface;
focusSurface = proxyRemoteSurface.data();
}
const bool pointerGrab = seat->hasImplicitPointerGrab(serial) && seat->focusedPointerSurface() == focusSurface;
if (!pointerGrab) {
@ -216,7 +216,7 @@ SurfaceInterface *DataDeviceInterface::icon() const
SurfaceInterface *DataDeviceInterface::origin() const
{
Q_D();
return d->proxyRemoteSurface ? d->proxyRemoteSurface : d->surface;
return d->proxyRemoteSurface ? d->proxyRemoteSurface.data() : d->surface;
}
DataSourceInterface *DataDeviceInterface::selection() const