From b2d648df5d8f1739d8930617d9db3da172f2d1d2 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Wed, 21 Apr 2021 01:22:28 +0200 Subject: [PATCH] datadevice: do not call a null dragSource Fixes the following backtrace: *0 KWaylandServer::DataDeviceInterface::dragSource() const (this=0x0) at ./src/server/datadevice_interface.cpp:199 *1 0x00007f10d67b0c71 in KWaylandServer::DataDeviceInterface::updateDragTarget(KWaylandServer::SurfaceInterface*, unsigned int) (this=0x55c42e3ee9a0, surface=surface@entry=0x55c42e4b3170, serial=serial@entry=3104) at ./src/server/datadevice_interface.cpp:278 *2 0x00007f10d67d8e52 in KWaylandServer::SeatInterface::setDragTarget(KWaylandServer::SurfaceInterface*, QPointF const&, QMatrix4x4 const&) (this=this@entry=0x55c42d422ed0, surface=0x55c42e4b3170, globalPosition=..., inputTransformation=...) at /usr/include/c++/9/bits/atomic_base.h:413 *3 0x00007f10d67d9209 in KWaylandServer::SeatInterface::setDragTarget(KWaylandServer::SurfaceInterface*, QMatrix4x4 const&) (this=this@entry=0x55c42d422ed0, surface=, inputTransformation=...) at ./src/server/seat_interface.cpp:578 *4 0x000055c42cb4563a in KWin::Xwl::XToWlDrag::setDragTarget() (this=this@entry=0x55c42ea07a00) at ./src/toplevel.h:990 *5 0x000055c42cb47a68 in KWin::Xwl::XToWlDrag::offerCallback(QString const&) (mime=..., this=0x55c42ea07a00) at ./src/xwl/drag_x.cpp:242 *6 KWin::Xwl::XToWlDrag::offerCallback(QString const&) (this=0x55c42ea07a00, mime=...) at ./src/xwl/drag_x.cpp:237 *7 0x00007f10d5dc06fe in () at /lib/x86_64-linux-gnu/libQt5Core.so.5 --- src/wayland/datadevice_interface.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/wayland/datadevice_interface.cpp b/src/wayland/datadevice_interface.cpp index 9947063ba2..8c0f17e140 100644 --- a/src/wayland/datadevice_interface.cpp +++ b/src/wayland/datadevice_interface.cpp @@ -264,8 +264,9 @@ void DataDeviceInterface::updateDragTarget(SurfaceInterface *surface, quint32 se } // don't update serial, we need it } - if (!surface) { - if (auto s = d->seat->dragSource()->dragSource()) { + auto dragSourceDevice = d->seat->dragSource(); + if (!surface || !dragSourceDevice) { + if (auto s = dragSourceDevice->dragSource()) { s->dndAction(DataDeviceManagerInterface::DnDAction::None); } return; @@ -275,7 +276,7 @@ void DataDeviceInterface::updateDragTarget(SurfaceInterface *surface, quint32 se // TODO: do this for all client's surfaces? return; } - auto *source = d->seat->dragSource()->dragSource(); + auto *source = dragSourceDevice->dragSource(); if (source) { source->setAccepted(false); }