summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2022-11-22 13:00:22 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2022-11-25 14:28:48 +0100
commitef379f95c7621272933b06fb3edfe502b14bd145 (patch)
treeefd7e5ec1b81684183a294b5379110274a7a8562 /src/gui
parent01780d753e960133ae0110c6ef4292fbd2ea306c (diff)
QPalette: always increase serial number when modifying
After 109e088c7c5d0c9325966e88d55fd9f7a58f67ea, cache keys were unique for palettes with different private or data instances, but the key did not change when a palette without any shared copies was modified, as that does not create new private data structures. To fix this, always increase the counter for the private data structure, also when not detaching from shared copies. Augment test case with scenario that broke. Pick-to: 6.4 Fixes: QTBUG-108709 Change-Id: I606abfb8b1a03e515e46b10dc840a631eb31d496 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: JiDe Zhang <zhangjide@uniontech.com> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qpalette.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp
index 081af38074..4abbcd5e65 100644
--- a/src/gui/kernel/qpalette.cpp
+++ b/src/gui/kernel/qpalette.cpp
@@ -62,7 +62,7 @@ public:
QAtomicInt ref;
QPalette::ResolveMask resolveMask = {0};
static inline int qt_palette_private_count = 0;
- const int detach_no = ++qt_palette_private_count;
+ int detach_no = ++qt_palette_private_count;
QExplicitlySharedDataPointer<Data> data;
};
@@ -864,6 +864,8 @@ void QPalette::detach()
if (!d->ref.deref())
delete d;
d = x;
+ } else {
+ d->detach_no = ++QPalettePrivate::qt_palette_private_count;
}
}