Go to file
Volker Hilsheimer 813bbc515b QStyle: don't use the QPixmapCache when a style sheet is set
If a style sheet is active, then the palette in the QStyleOption might
be a generated, short-lived, temporary QPalette instance. As QPalette's
cacheKey is based on instance-counters of the private data structures,
it will always be unique for such a QPalette, even if the brushes are
the same as in a previous instance.

(QPalette::cacheKey is just a 64bit integer, we cannot possibly encode
the entire QPalette data in it in a collision-free way, and since a
brush in the palette might contain a pixmap or a gradient we couldn't
even generate an efficient string representation for it. We could at
most cache and reuse QPalette instances based on the attributes in the
style sheet rule and in the base palette of the widget. However, this
seems fragile; it might be an opportunity for future optimization.)

Some styles use the QPixmapCache, with a key that includes the
palette's cache key. The key will always be unique if the palette is
based on style sheet rules, and then we fill pixmap cache with pixmaps
that can never be reused, making the cache both useless and wasteful.

To solve this, generate an empty key if we detect that it is for a style
object that is the target of a style sheet. Return an empty cache key
string from QStyleHelper::uniqueName, which will make QPixmapCache
return immediatey when trying to insert or find an object.

This is not pretty, but it makes the change minimal and low-risk.
Refactoring the respective code paths to e.g. consistently use the
BEGIN_STYLE_PIXMAPCACHE helper macro requires larger changes that
can only be verified visually, and so are out of scope for a bug fix.

This requires changes to code that uses QStyleHelper::uniqueName, as we
need to avoid that other key elements are appended to the generated (and
maybe empty) key. As a side effect, this ends up with code that makes
better use of QStringBuilder.

Pick-to: 6.6
Fixes: QTBUG-114473
Change-Id: I011aed0885f105cbf1e8c0bc6b94c46df47761a3
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-07-11 14:31:12 +02:00
.github/workflows Repair github action workflow 2021-11-10 18:57:33 +01:00
bin Add simple project generation based on existing source files 2023-02-08 12:59:19 +01:00
cmake Add a private API to capture a graphics frame 2023-07-11 15:24:26 +03:00
coin Doc: Move the warninglimit configuration to doc/global 2023-06-29 12:08:34 +00:00
config.tests Remove the mandatory x86-64 features from its feature list 2023-05-31 14:55:37 -07:00
dist Add Qt 6.0.0 changes file 2020-11-16 10:02:08 +02:00
doc Introduce macro.qtpolicydeprecatedbehavior for Qt CMake Policy 2023-07-10 21:47:08 +02:00
examples XBEL streaming example: renumber xbelreader.cpp's snippet fragments 2023-07-10 12:57:21 +02:00
lib Purge all fonts 2015-08-18 19:59:14 +00:00
libexec Remove syncqt.pl 2023-06-30 13:23:46 +02:00
LICENSES Clarify license of SHA-1 algorithm 2023-04-26 16:36:18 +02:00
mkspecs Fix spelling of D-Bus in the source code 2023-07-06 21:51:29 +02:00
qmake qtpaths: generate proper JSON 2023-07-08 10:50:41 +02:00
src QStyle: don't use the QPixmapCache when a style sheet is set 2023-07-11 14:31:12 +02:00
tests Fix assert in qCleanupFuncInfo when using QDebug from a lambda with auto 2023-07-11 02:37:58 +02:00
util wasm: add shared library preload scripts 2023-07-03 19:02:48 +02:00
.cmake.conf CMake: Require CMake 3.21 when building/using Qt on Apple platforms 2023-06-28 22:09:20 +02:00
.gitattributes Give batch files CRLF line endings 2020-11-04 15:02:29 +00:00
.gitignore Add CMakeUserPresets.json to .gitignore 2023-06-23 12:13:08 +02:00
.lgtm.yml Skip LGTM analysis for the bootstrap library and tools 2020-07-16 01:04:34 +02:00
.tag
CMakeLists.txt Introduce QT_ALLOW_SYMLINK_IN_PATHS flag 2023-05-03 19:44:45 +02:00
config_help.txt Introduce -no-vcpkg flag for disabling vcpkg detection/integration 2023-06-27 18:41:00 +02:00
configure Retrieve an old -redo behavior 2023-02-07 18:51:58 +00:00
configure.bat Retrieve an old -redo behavior 2023-02-07 18:51:58 +00:00
configure.cmake Update the implementation of -unity-build 2023-06-29 10:20:25 +02:00
dependencies.yaml Re-add dependencies.yaml now that qt5.git wip/qt6 builds fine 2019-09-18 13:19:31 +02:00
qt_cmdline.cmake Update the implementation of -unity-build 2023-06-29 10:20:25 +02:00
sync.profile rhi: Make it a QPA-style private but semi-public API 2023-05-21 15:42:58 +02:00