summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2009-11-13 09:58:15 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-11-13 09:58:15 (GMT)
commite6be9c88bc98481936fcba7fa1cfb4e255f6e30b (patch)
tree4284a5cb47e4bb5d0b1a368b149eb66ed888c0d2 /src/corelib
parent63856f13721bce420fe94dab31c36329af976276 (diff)
downloadQt-e6be9c88bc98481936fcba7fa1cfb4e255f6e30b.zip
Qt-e6be9c88bc98481936fcba7fa1cfb4e255f6e30b.tar.gz
Qt-e6be9c88bc98481936fcba7fa1cfb4e255f6e30b.tar.bz2
Early return for allowMove within a parent QModelIndex
If this is not done, the climbing ancestors later in the method uses srcParent.row() as pos causing failure depending on which rows are being moved, and what the row of the parent is. Merge-request: 2072 Reviewed-by: Olivier Goffart <ogoffart@trolltech.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/kernel/qabstractitemmodel.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp
index 8e2273d..10a61ca 100644
--- a/src/corelib/kernel/qabstractitemmodel.cpp
+++ b/src/corelib/kernel/qabstractitemmodel.cpp
@@ -2475,10 +2475,8 @@ void QAbstractItemModel::endRemoveRows()
bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int start, int end, const QModelIndex &destinationParent, int destinationStart, Qt::Orientation orientation)
{
// Don't move the range within itself.
- if ( ( destinationParent == srcParent )
- && ( destinationStart >= start )
- && ( destinationStart <= end + 1) )
- return false;
+ if (destinationParent == srcParent)
+ return !(destinationStart >= start && destinationStart <= end + 1);
QModelIndex destinationAncestor = destinationParent;
int pos = (Qt::Vertical == orientation) ? destinationAncestor.row() : destinationAncestor.column();