From 26ce4869a09e0061061c3f1e2cf2333a4ab1eb02 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Mon, 6 Apr 2020 18:10:03 +0100 Subject: [PATCH] [xwl] Fix crash if same data is requested twice Summary: m_dataRequests is a list of transfers for a given selection. It exists primarily as a ref counting mechanism that matches up transfers with selections. If the same data is requested twice we would insert two items into the list with matching timestamps for the original selection. This then confuses the callback handling. BUG: 417936 Test Plan: kwin_wayland + chromium drag and drop a URL onto desktopview. kwin used to crash here Now a context menu now appears and I can add a link Reviewers: #kwin Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D28630 --- xwl/drag_x.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/xwl/drag_x.cpp b/xwl/drag_x.cpp index f84bb136c2..10105d4123 100644 --- a/xwl/drag_x.cpp +++ b/xwl/drag_x.cpp @@ -69,13 +69,12 @@ XToWlDrag::XToWlDrag(X11Source *source) // we use this mechanism, because the finished call is not // reliable done by Wayland clients auto it = std::find_if(m_dataRequests.begin(), m_dataRequests.end(), [eventTime](const QPair &req) { - return req.first == eventTime; + return req.first == eventTime && req.second == false; }); if (it == m_dataRequests.end()) { // transfer finished for a different drag return; } - Q_ASSERT(!(*it).second); (*it).second = true; checkForFinished(); });