From 4b3bee64006ab3d3e033714238208d0d64d61e96 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Sun, 7 Apr 2013 11:50:42 +0200 Subject: [PATCH] Add extra checks so we never return empty QMimeData from mimeData(). --- src/gui/entry/EntryModel.cpp | 10 ++++++++-- src/gui/group/GroupModel.cpp | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/gui/entry/EntryModel.cpp b/src/gui/entry/EntryModel.cpp index 29e6637ba..890b6cafb 100644 --- a/src/gui/entry/EntryModel.cpp +++ b/src/gui/entry/EntryModel.cpp @@ -227,8 +227,14 @@ QMimeData* EntryModel::mimeData(const QModelIndexList& indexes) const } } - data->setData(mimeTypes().first(), encoded); - return data; + if (seenEntries.isEmpty()) { + delete data; + return Q_NULLPTR; + } + else { + data->setData(mimeTypes().first(), encoded); + return data; + } } void EntryModel::entryAboutToAdd(Entry* entry) diff --git a/src/gui/group/GroupModel.cpp b/src/gui/group/GroupModel.cpp index 6c789a86a..d1bad58a9 100644 --- a/src/gui/group/GroupModel.cpp +++ b/src/gui/group/GroupModel.cpp @@ -313,8 +313,14 @@ QMimeData* GroupModel::mimeData(const QModelIndexList& indexes) const } } - data->setData(mimeTypes().first(), encoded); - return data; + if (seenGroups.isEmpty()) { + delete data; + return Q_NULLPTR; + } + else { + data->setData(mimeTypes().first(), encoded); + return data; + } } void GroupModel::groupDataChanged(Group* group)