summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-08-30 12:53:54 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-08-30 13:11:19 (GMT)
commitc6623b6a7305f78375b8075b4edd3dfc03c5ec9e (patch)
tree1439bc1e34817ac8264e074cfd730c8351f9f5e0
parente4f12672ab7a70dbaac2feb81499a9ee816f677f (diff)
downloadQt-c6623b6a7305f78375b8075b4edd3dfc03c5ec9e.zip
Qt-c6623b6a7305f78375b8075b4edd3dfc03c5ec9e.tar.gz
Qt-c6623b6a7305f78375b8075b4edd3dfc03c5ec9e.tar.bz2
Fix crash introduced with d34287af6fc1c7558e8ed15dbb29c0e6b58b7b00
Crash occured in tst_QTreeWidget::task253109_itemHeight When we use loop over editorIndexHash, we cannot garantee that the key is still a valid valid pointer, we need to confirm it with the QWeakPointer in indexEditorHash Reviewed-by: Gabriel
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index a5630ec..7ddd339 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -1037,8 +1037,10 @@ void QAbstractItemView::reset()
{
Q_D(QAbstractItemView);
d->delayedReset.stop(); //make sure we stop the timer
- for (QEditorIndexHash::iterator it = d->editorIndexHash.begin(); it != d->editorIndexHash.end(); ++it)
- d->releaseEditor(it.key());
+ foreach (const QEditorInfo &info, d->indexEditorHash) {
+ if (info.widget)
+ d->releaseEditor(info.widget.data());
+ }
d->editorIndexHash.clear();
d->indexEditorHash.clear();
d->persistent.clear();
@@ -3239,9 +3241,10 @@ void QAbstractItemView::rowsAboutToBeRemoved(const QModelIndex &parent, int star
const QModelIndex index = i.value();
if (index.row() >= start && index.row() <= end && d->model->parent(index) == parent) {
QWidget *editor = i.key();
- d->indexEditorHash.remove(index);
+ QEditorInfo info = d->indexEditorHash.take(index);
i = d->editorIndexHash.erase(i);
- d->releaseEditor(editor);
+ if (info.widget)
+ d->releaseEditor(editor);
} else {
++i;
}
@@ -3305,9 +3308,10 @@ void QAbstractItemViewPrivate::_q_columnsAboutToBeRemoved(const QModelIndex &par
QModelIndex index = it.value();
if (index.column() <= start && index.column() >= end && model->parent(index) == parent) {
QWidget *editor = it.key();
- indexEditorHash.remove(it.value());
+ QEditorInfo info = indexEditorHash.take(it.value());
it = editorIndexHash.erase(it);
- releaseEditor(editor);
+ if (info.widget)
+ releaseEditor(editor);
} else {
++it;
}