diff options
Diffstat (limited to 'src/widgets/itemviews')
-rw-r--r-- | src/widgets/itemviews/qheaderview.cpp | 16 | ||||
-rw-r--r-- | src/widgets/itemviews/qlistwidget.cpp | 8 |
2 files changed, 15 insertions, 9 deletions
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 62abf56751..99309633a7 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -2283,13 +2283,15 @@ void QHeaderViewPrivate::_q_sectionsChanged(const QList<QPersistentModelIndex> & : index.row()); // the new visualIndices are already adjusted / reset by initializeSections() const int newVisualIndex = visualIndex(newLogicalIndex); - auto &newSection = sectionItems[newVisualIndex]; - newSection = item.section; - - if (newSection.isHidden) { - // otherwise setSectionHidden will return without doing anything - newSection.isHidden = false; - q->setSectionHidden(newLogicalIndex, true); + if (newVisualIndex < sectionItems.count()) { + auto &newSection = sectionItems[newVisualIndex]; + newSection = item.section; + + if (newSection.isHidden) { + // otherwise setSectionHidden will return without doing anything + newSection.isHidden = false; + q->setSectionHidden(newLogicalIndex, true); + } } } diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp index a9899983c2..e46d25bef1 100644 --- a/src/widgets/itemviews/qlistwidget.cpp +++ b/src/widgets/itemviews/qlistwidget.cpp @@ -650,11 +650,13 @@ QListWidgetItem::QListWidgetItem(const QString &text, QListWidget *listview, int |Qt::ItemIsEnabled |Qt::ItemIsDragEnabled) { + QListModel *model = listModel(); { QSignalBlocker b(view); + QSignalBlocker bm(model); setData(Qt::DisplayRole, text); } - if (QListModel *model = listModel()) + if (model) model->insert(model->rowCount(), this); } @@ -683,12 +685,14 @@ QListWidgetItem::QListWidgetItem(const QIcon &icon,const QString &text, |Qt::ItemIsEnabled |Qt::ItemIsDragEnabled) { + QListModel *model = listModel(); { QSignalBlocker b(view); + QSignalBlocker bm(model); setData(Qt::DisplayRole, text); setData(Qt::DecorationRole, icon); } - if (QListModel *model = listModel()) + if (model) model->insert(model->rowCount(), this); } |