@@ -59,8 +59,8 @@ QString DBusMenuItem::icon() const {
5959 this ->iconName ,
6060 this ->menu ->iconThemePath .value ().join (' :' )
6161 );
62- } else if (this ->image != nullptr ) {
63- return this ->image -> url ();
62+ } else if (this ->image . hasData () ) {
63+ return this ->image . url ();
6464 } else return nullptr ;
6565}
6666
@@ -113,7 +113,7 @@ void DBusMenuItem::updateProperties(const QVariantMap& properties, const QString
113113 auto originalEnabled = this ->mEnabled ;
114114 auto originalVisible = this ->visible ;
115115 auto originalIconName = this ->iconName ;
116- auto * originalImage = this -> image ;
116+ auto imageChanged = false ;
117117 auto originalIsSeparator = this ->mSeparator ;
118118 auto originalButtonType = this ->mButtonType ;
119119 auto originalToggleState = this ->mCheckState ;
@@ -173,12 +173,16 @@ void DBusMenuItem::updateProperties(const QVariantMap& properties, const QString
173173 if (iconData.canConvert <QByteArray>()) {
174174 auto data = iconData.value <QByteArray>();
175175 if (data.isEmpty ()) {
176- this ->image = nullptr ;
177- } else if (this ->image == nullptr || this ->image ->data != data) {
178- this ->image = new DBusMenuPngImage (data, this );
176+ imageChanged = this ->image .hasData ();
177+ this ->image .data .clear ();
178+ } else if (!this ->image .hasData () || this ->image .data != data) {
179+ imageChanged = true ;
180+ this ->image .data = data;
181+ this ->image .imageChanged ();
179182 }
180183 } else if (removed.isEmpty () || removed.contains (" icon-data" )) {
181- this ->image = nullptr ;
184+ imageChanged = this ->image .hasData ();
185+ image.data .clear ();
182186 }
183187
184188 auto type = properties.value (" type" );
@@ -239,17 +243,13 @@ void DBusMenuItem::updateProperties(const QVariantMap& properties, const QString
239243 if (this ->mSeparator != originalIsSeparator) emit this ->isSeparatorChanged ();
240244 if (this ->displayChildren != originalDisplayChildren) emit this ->hasChildrenChanged ();
241245
242- if (this ->iconName != originalIconName || this ->image != originalImage) {
243- if (this ->image != originalImage) {
244- delete originalImage;
245- }
246-
246+ if (this ->iconName != originalIconName || imageChanged) {
247247 emit this ->iconChanged ();
248248 }
249249
250250 qCDebug (logDbusMenu).nospace () << " Updated properties of " << this << " { label=" << this ->mText
251251 << " , enabled=" << this ->mEnabled << " , visible=" << this ->visible
252- << " , iconName=" << this ->iconName << " , iconData=" << this ->image
252+ << " , iconName=" << this ->iconName << " , iconData=" << & this ->image
253253 << " , separator=" << this ->mSeparator
254254 << " , toggleType=" << this ->mButtonType
255255 << " , toggleState=" << this ->mCheckState
0 commit comments