Fix memory leak in Qt Quick Controls icon

The implementation of the icon property uses the internal
QThemeIconInfo struct from qtbase. That is low level and expects the
user to handle memory deallocation, and this was missing.

Fixes: QTBUG-93050
Pick-to: 6.2
Change-Id: Ied6488aa8871c246d3781a3db47f40130dc19bcc
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
This commit is contained in:
Eirik Aavitsland 2021-09-06 17:51:37 +02:00
parent 97b1062674
commit 47ded88e0c
2 changed files with 8 additions and 0 deletions

View File

@ -42,6 +42,12 @@
QT_BEGIN_NAMESPACE
QQuickIconImagePrivate::~QQuickIconImagePrivate()
{
qDeleteAll(icon.entries);
icon.entries.clear();
}
bool QQuickIconImagePrivate::updateDevicePixelRatio(qreal targetDevicePixelRatio)
{
if (isThemeIcon) {
@ -132,6 +138,7 @@ void QQuickIconImage::setName(const QString &name)
if (d->icon.iconName == name)
return;
qDeleteAll(d->icon.entries);
d->icon = QIconLoader::instance()->loadIcon(name);
if (isComponentComplete())
d->updateIcon();

View File

@ -59,6 +59,7 @@ class Q_QUICKCONTROLS2_PRIVATE_EXPORT QQuickIconImagePrivate : public QQuickImag
Q_DECLARE_PUBLIC(QQuickIconImage)
public:
~QQuickIconImagePrivate() override;
void updateIcon();
void updateFillMode();
qreal calculateDevicePixelRatio() const;