summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThorbjørn Lund Martsum <tmartsum@gmail.com>2018-02-28 09:23:54 +0100
committerThorbjørn Lund Martsum <tmartsum@gmail.com>2018-03-02 17:25:21 +0000
commit133196ecdb4677ff0324be38fdad2a204f688d17 (patch)
tree6c2c1d11488122bdba4c2bdf0a3e03a40a59e159 /src
parenta038f776dd888d5fb094650b023e3cfce78ed853 (diff)
QHeaderView: Fix crash in layout about to change
Before there was a risk looking up e.g index -1 if there were no visible sections in layoutAboutToChange. Change-Id: Ic911e4292e8e8c4892fef1c0f34cf7dccaad2bac Task-number: QTBUG-65478 Reviewed-by: David Faure <david.faure@kdab.com> (cherry picked from commit e8425f9e52c9df0ce0fbf122adff3ef6930f9961)
Diffstat (limited to 'src')
-rw-r--r--src/widgets/itemviews/qheaderview.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
index 91331b84be..27da7a16e5 100644
--- a/src/widgets/itemviews/qheaderview.cpp
+++ b/src/widgets/itemviews/qheaderview.cpp
@@ -2075,9 +2075,11 @@ void QHeaderViewPrivate::_q_layoutAboutToBeChanged()
layoutChangePersistentSections.clear();
layoutChangePersistentSections.reserve(std::min(10, sectionItems.count()));
// after layoutChanged another section can be last stretched section
- if (stretchLastSection) {
+ if (stretchLastSection && lastSectionLogicalIdx >= 0 && lastSectionLogicalIdx < sectionItems.count()) {
const int visual = visualIndex(lastSectionLogicalIdx);
- sectionItems[visual].size = lastSectionSize;
+ if (visual >= 0 && visual < sectionItems.size()) {
+ sectionItems[visual].size = lastSectionSize;
+ }
}
for (int i = 0; i < sectionItems.size(); ++i) {
auto s = sectionItems.at(i);