summaryrefslogtreecommitdiffstats
path: root/src/widgets/itemviews/qheaderview.cpp
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2018-03-01 11:04:00 +0100
committerThorbjørn Lund Martsum <tmartsum@gmail.com>2018-03-07 05:29:16 +0000
commit4a04eea4f4316684e20c509352c6c533cf39306e (patch)
tree0d82c1f72c75fc10c8eaf988e05f3086380cf781 /src/widgets/itemviews/qheaderview.cpp
parent3eb42abab6c7d1f3a32ca55c972b1d7a4a703658 (diff)
QHeaderView: fix inconsistent saved state, ignored during restore
The code that updates a section size must also update length, otherwise saveState can end up saving inconsistent state, and restoreState() goes to an early-return, not doing anything. The actual bug was fixed meanwhile because _q_sectionsChanged is called again, which recalculates length. I still see this only as a safety measure, every other code path that changes section sizes updates length right away. Change-Id: I6cc16261692d93b3640afafef600a5bdff8dca0c Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Diffstat (limited to 'src/widgets/itemviews/qheaderview.cpp')
-rw-r--r--src/widgets/itemviews/qheaderview.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
index 5cbf642802..b7048d1616 100644
--- a/src/widgets/itemviews/qheaderview.cpp
+++ b/src/widgets/itemviews/qheaderview.cpp
@@ -2191,7 +2191,11 @@ void QHeaderViewPrivate::_q_sectionsAboutToBeChanged(const QList<QPersistentMode
if (stretchLastSection && lastSectionLogicalIdx >= 0 && lastSectionLogicalIdx < sectionItems.count()) {
const int visual = visualIndex(lastSectionLogicalIdx);
if (visual >= 0 && visual < sectionItems.size()) {
- sectionItems[visual].size = lastSectionSize;
+ auto &itemRef = sectionItems[visual];
+ if (itemRef.size != lastSectionSize) {
+ length += lastSectionSize - itemRef.size;
+ itemRef.size = lastSectionSize;
+ }
}
}
for (int i = 0; i < sectionItems.size(); ++i) {