diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-11-22 13:00:22 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-11-25 14:28:48 +0100 |
commit | ef379f95c7621272933b06fb3edfe502b14bd145 (patch) | |
tree | efd7e5ec1b81684183a294b5379110274a7a8562 /tests | |
parent | 01780d753e960133ae0110c6ef4292fbd2ea306c (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 'tests')
-rw-r--r-- | tests/auto/gui/kernel/qpalette/tst_qpalette.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp index f9b0792960..81036bee0a 100644 --- a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp +++ b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp @@ -274,6 +274,14 @@ void tst_QPalette::cacheKey() const auto defaultSerNo = defaultCacheKey >> 32; const auto defaultDetachNo = defaultCacheKey & 0xffffffff; + QPalette changeTwicePalette(defaultPalette); + changeTwicePalette.setBrush(QPalette::All, QPalette::ButtonText, Qt::red); + const auto firstChangeCacheKey = changeTwicePalette.cacheKey(); + QCOMPARE_NE(firstChangeCacheKey, defaultCacheKey); + changeTwicePalette.setBrush(QPalette::All, QPalette::ButtonText, Qt::green); + const auto secondChangeCacheKey = changeTwicePalette.cacheKey(); + QCOMPARE_NE(firstChangeCacheKey, secondChangeCacheKey); + QPalette copyDifferentData(defaultPalette); QPalette copyDifferentMask(defaultPalette); QPalette copyDifferentMaskAndData(defaultPalette); |