aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/types
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-08-22 11:20:03 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-08-22 15:44:49 +0000
commit8ee5dff21c3701a5a0dd1de9bed563da0aa12ef6 (patch)
tree3de793f50b4544f5209a6b5664e2d6ffe0ef7d03 /src/qml/types
parentcd5937273ee14c3941574a2db7cc0f8c3682def0 (diff)
QQmlDelegateModelItem: ensure that we emit changes to row and column
As it stood, we would only emit changes to row and column if index changed as well. But when removing rows and columns from the model, it can happen that we reuse an item that by accident has the same index as the one we change it to, but belonging to a different row and column. So we need to check for changes to the index the same way we do for row and column. Change-Id: I9d507a74aa5dcb0fe7630e7af1e949bd2db7fb47 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/qml/types')
-rw-r--r--src/qml/types/qqmldelegatemodel.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp
index 41970ce626..6732be9844 100644
--- a/src/qml/types/qqmldelegatemodel.cpp
+++ b/src/qml/types/qqmldelegatemodel.cpp
@@ -2093,9 +2093,7 @@ void QQmlDelegateModelItem::Dispose()
void QQmlDelegateModelItem::setModelIndex(int idx, int newRow, int newColumn)
{
- if (idx == index)
- return;
-
+ const int prevIndex = index;
const int prevRow = row;
const int prevColumn = column;
@@ -2103,8 +2101,8 @@ void QQmlDelegateModelItem::setModelIndex(int idx, int newRow, int newColumn)
row = newRow;
column = newColumn;
- Q_EMIT modelIndexChanged();
-
+ if (idx != prevIndex)
+ emit modelIndexChanged();
if (row != prevRow)
emit rowChanged();
if (column != prevColumn)