diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-02-10 16:57:11 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2015-02-10 16:57:11 +0000 |
commit | 0866680bd904aff4fe2a643a2b81c460cbb99c77 (patch) | |
tree | 242dae052199994a35f5e68578661175241a0a71 /src/gui/itemmodels | |
parent | 34ea269b3b173498312b0203d6875ef3b4ba0253 (diff) | |
parent | fc35f714340d5361231506dfbead132122f59460 (diff) |
Merge "Merge remote-tracking branch 'origin/5.4' into dev" into refs/staging/dev
Diffstat (limited to 'src/gui/itemmodels')
-rw-r--r-- | src/gui/itemmodels/qstandarditemmodel.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp index 4102230e1b..c0fa01d887 100644 --- a/src/gui/itemmodels/qstandarditemmodel.cpp +++ b/src/gui/itemmodels/qstandarditemmodel.cpp @@ -2936,9 +2936,13 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const itemsSet.reserve(indexes.count()); stack.reserve(indexes.count()); for (int i = 0; i < indexes.count(); ++i) { - QStandardItem *item = itemFromIndex(indexes.at(i)); - itemsSet << item; - stack.push(item); + if (QStandardItem *item = itemFromIndex(indexes.at(i))) { + itemsSet << item; + stack.push(item); + } else { + qWarning() << "QStandardItemModel::mimeData: No item associated with invalid index"; + return 0; + } } //remove duplicates childrens @@ -2972,16 +2976,11 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const //stream everything recursively while (!stack.isEmpty()) { QStandardItem *item = stack.pop(); - if(itemsSet.contains(item)) { //if the item is selection 'top-level', strem its position + if (itemsSet.contains(item)) //if the item is selection 'top-level', stream its position stream << item->row() << item->column(); - } - if(item) { - stream << *item << item->columnCount() << item->d_ptr->children.count(); - stack += item->d_ptr->children; - } else { - QStandardItem dummy; - stream << dummy << 0 << 0; - } + + stream << *item << item->columnCount() << item->d_ptr->children.count(); + stack += item->d_ptr->children; } data->setData(format, encoded); |