core/icon: stop reusing image ids (dbusmenu, notifications)

Fixes issues caused by the QML engine caching old pixmaps using the
same IDs as new ones, notably dbusmenu icons.
This commit is contained in:
outfoxxed 2025-01-22 23:10:49 -08:00
parent c6791cf1f2
commit cdaff2967f
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
8 changed files with 75 additions and 58 deletions

View file

@ -1,5 +1,4 @@
#include "notification.hpp"
#include <utility>
#include <qcontainerfwd.h>
#include <qdbusargument.h>
@ -117,13 +116,12 @@ void Notification::updateProperties(
QString imagePath;
if (!imageDataName.isEmpty()) {
if (imageDataName.isEmpty()) {
this->mImagePixmap.clear();
} else {
auto value = hints.value(imageDataName).value<QDBusArgument>();
DBusNotificationImage image;
value >> image;
if (this->mImagePixmap) this->mImagePixmap->deleteLater();
this->mImagePixmap = new NotificationImage(std::move(image), this);
imagePath = this->mImagePixmap->url();
value >> this->mImagePixmap.writeImage();
imagePath = this->mImagePixmap.url();
}
// don't store giant byte arrays longer than necessary
@ -131,7 +129,7 @@ void Notification::updateProperties(
hints.remove("image_data");
hints.remove("icon_data");
if (!this->mImagePixmap) {
if (!this->mImagePixmap.hasData()) {
QString imagePathName;
if (hints.contains("image-path")) imagePathName = "image-path";
else if (hints.contains("image_path")) imagePathName = "image_path";