813bbc515b
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> |
||
---|---|---|
.github/workflows | ||
bin | ||
cmake | ||
coin | ||
config.tests | ||
dist | ||
doc | ||
examples | ||
lib | ||
libexec | ||
LICENSES | ||
mkspecs | ||
qmake | ||
src | ||
tests | ||
util | ||
.cmake.conf | ||
.gitattributes | ||
.gitignore | ||
.lgtm.yml | ||
.tag | ||
CMakeLists.txt | ||
config_help.txt | ||
configure | ||
configure.bat | ||
configure.cmake | ||
dependencies.yaml | ||
qt_cmdline.cmake | ||
sync.profile |