summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qstylehelper.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-11-16 07:37:38 +0100
committerLiang Qi <liang.qi@qt.io>2016-11-16 12:35:36 +0100
commit90c425642dfeae4564b43dacf15f80479962e910 (patch)
tree7e51683195210b3c70c04a8a0753ee272af1cd4c /src/widgets/styles/qstylehelper.cpp
parent1a43199fcea1bcec1ebf1a1a12cd3dcb942d67b4 (diff)
parent9808b53fde1dfc65ad3757cc6720e430c3cc89a2 (diff)
Merge remote-tracking branch 'origin/5.7' into 5.8
Conflicts: mkspecs/common/linux-android.conf src/gui/opengl/qopengl.h src/network/socket/qnativesocketengine_winrt.cpp src/network/socket/qnativesocketengine_winrt_p.h src/plugins/platforms/cocoa/qcocoawindow.mm src/plugins/platforms/eglfs/api/qeglfsintegration.cpp src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp sync.profile Change-Id: If70aaf2c49df91157b864cf0d7d9513546c9bec4
Diffstat (limited to 'src/widgets/styles/qstylehelper.cpp')
-rw-r--r--src/widgets/styles/qstylehelper.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp
index 583385ee8a..602421725f 100644
--- a/src/widgets/styles/qstylehelper.cpp
+++ b/src/widgets/styles/qstylehelper.cpp
@@ -49,6 +49,8 @@
#include "qstylehelper_p.h"
#include <qstringbuilder.h>
+#include <qdatastream.h>
+#include <qcryptographichash.h>
QT_BEGIN_NAMESPACE
@@ -62,7 +64,6 @@ QString uniqueName(const QString &key, const QStyleOption *option, const QSize &
QString tmp = key % HexString<uint>(option->state)
% HexString<uint>(option->direction)
% HexString<uint>(complexOption ? uint(complexOption->activeSubControls) : 0u)
- % HexString<quint64>(option->palette.cacheKey())
% HexString<uint>(size.width())
% HexString<uint>(size.height());
@@ -73,6 +74,25 @@ QString uniqueName(const QString &key, const QStyleOption *option, const QSize &
% QLatin1Char(spinBox->frame ? '1' : '0'); ;
}
#endif // QT_NO_SPINBOX
+
+ // QTBUG-56743, try to create a palette cache key reflecting the value,
+ // as leaks may occur in conjunction with QStyleSheetStyle/QRenderRule modifying
+ // palettes when using QPalette::cacheKey()
+ if (option->palette != QGuiApplication::palette()) {
+ tmp.append(QLatin1Char('P'));
+#ifndef QT_NO_DATASTREAM
+ QByteArray key;
+ key.reserve(5120); // Observed 5040B for a serialized palette on 64bit
+ {
+ QDataStream str(&key, QIODevice::WriteOnly);
+ str << option->palette;
+ }
+ const QByteArray sha1 = QCryptographicHash::hash(key, QCryptographicHash::Sha1).toHex();
+ tmp.append(QString::fromLatin1(sha1));
+#else // QT_NO_DATASTREAM
+ tmp.append(QString::number(option->palette.cacheKey(), 16));
+#endif // !QT_NO_DATASTREAM
+ }
return tmp;
}