From ef379f95c7621272933b06fb3edfe502b14bd145 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 22 Nov 2022 13:00:22 +0100 Subject: 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 Reviewed-by: JiDe Zhang Reviewed-by: Alessandro Portale --- src/gui/kernel/qpalette.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/gui') 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; }; @@ -864,6 +864,8 @@ void QPalette::detach() if (!d->ref.deref()) delete d; d = x; + } else { + d->detach_no = ++QPalettePrivate::qt_palette_private_count; } } -- cgit v1.2.3