Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37807984
en ru br
Репозитории ALT
S:4.8.7-alt25
5.1: 4.6.3-alt1.M51.1
4.1: 4.4.3-alt1.M41.1
4.0: 4.3.4-alt5.M40.1
3.0: 4.0.1-alt1
+updates:4.0.1-alt2
+backports:4.2.3-alt7.1.M30
www.altlinux.org/Changes

Группа :: Система/Библиотеки
Пакет: qt4

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: 0102-qabstractitemmodel_invalidate.diff
Скачать


qt-bugs@ issue : 80061
applied: no 
author: teske
Below is the original description of the issue. The current qt-copy has a partial fix
for the issue. This patch fixes the fix to be more correct. (But is not complete.)
there are at least two bugs in the handling of PersistentModelIndexes. 
1) PersistentModelIndex which are invalid because their rows where deleted are still accesed.
2) Not every PersistentModelIndex which should be invalidated is marked as invalid.
(I use "invalid QModelIndex" for ModelIndexes, whose data was deleted.)
1) Consider this code from QAbstractItemModel 
qabstractitemmodel.cpp:
beginRemoveRows() calls rowsAboutToBeRemoved()
which fills persistent.invalid with the positions of those PersistentModelIndexes which will become invalid.
Note: These PersistentModelIndexes are not removed from persistent.indexes.
So in between beginRemoveRows and endRemoveRows, the PersistentModelIndexes of removed rows become invalid.
Now move forward after the data is removed.
This means some of the PersistentModelIndexes inside persistent.indexes are now invalid but not marked as such.
endRemoveRows() calls rowsRemoved() calls invalidate()
And inside invalidate() the code iterates over persistent.indexes and asks each of them for their parent. As some of them are invalid, (their data was already removed) this is clearly wrong.
2) The code which checks if a PersistentIndexModel will become invalid is not correct.
Consider this tree (just one column, only rows shown):
top == QModelIndex()
|->a
   |->b
   A PersistentModelIndex to b will become invalid if a is removed. The current code doesn't do that.
   The attached patch fixes both of bugs. (A similar fix for removing columns is obviously needed.)
   You might want to look at QItemSelections unchecked usage of PersistentModelIndexes, I get crashes in  there. (I'll report those if I'm sure that it is indeed a bug in your libary.)
   
Index: src/corelib/kernel/qabstractitemmodel.cpp
===================================================================
--- src/corelib/kernel/qabstractitemmodel.cpp	(revision 446120)
+++ src/corelib/kernel/qabstractitemmodel.cpp	(working copy)
@@ -401,13 +401,6 @@
 
 void QAbstractItemModelPrivate::invalidate(int position)
 {
-    QModelIndex parent = persistent.indexes.at(position)->index;
-    for (int i = 0; i < persistent.indexes.count(); ++i) {
-        if (persistent.indexes.at(i)->index.parent() == parent) {
-            Q_ASSERT((persistent.indexes.at(i)));
-            invalidate(i); // recursive
-        }
-    }
     persistent.indexes[position]->index = QModelIndex();
 }
 
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin