From c85ca114553c198af79eedacdb6b40ac4cab20e0 Mon Sep 17 00:00:00 2001 From: Elvis Angelaccio Date: Fri, 21 Apr 2017 13:16:05 +0200 Subject: Ignore drops-onto-items from invalid places items If the QMimeData object created by PlacesItemModel doesn't have any url set (e.g. when dragging unmounted devices), it is detected by the resulting DropJob as "drop raw data" because the mimeData has one format set (the internalMimeType() used for dragging between places items). This results in a crash because the DropJob schedules a PasteJob, but in the meantime the QDrag from Dolphin ends and deletes the mimeData object that was passed to the paste job. The fix is to prevent the DropJob in the first place. We can introduce a new internal mimetype that we use to blacklist drops-onto-items (while still allowing drops-between-items). This way PlacesItemModel can set the blacklist flag if the mimeData is being created without urls. BUG: 373005 FIXED-IN: 17.04.3 Test Plan: Drag and drop an unmounted device to another place item or the DolphinView, doesn't crash anymore. Dropping the unmounted device between two places item still works. Differential Revision: https://phabricator.kde.org/D5535 --- src/kitemviews/kitemmodelbase.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/kitemviews/kitemmodelbase.cpp') diff --git a/src/kitemviews/kitemmodelbase.cpp b/src/kitemviews/kitemmodelbase.cpp index bf41b1c84..ee7e81084 100644 --- a/src/kitemviews/kitemmodelbase.cpp +++ b/src/kitemviews/kitemmodelbase.cpp @@ -142,6 +142,11 @@ bool KItemModelBase::supportsDropping(int index) const return false; } +QString KItemModelBase::blacklistItemDropEventMimeType() const +{ + return QStringLiteral("application/x-dolphin-blacklist-drop"); +} + void KItemModelBase::onGroupedSortingChanged(bool current) { Q_UNUSED(current); -- cgit v1.3