Commit 77975468 authored by Konrad Materka's avatar Konrad Materka
Browse files

[systemtray] Fix SNI icon not rendering

Summary:
In some rare situations SNI icons are not rendered. It happens randomly, only some users are affected. It does not happen on every login.
Only SNI icons are not rendered, Plasmoids are fine. Restarting plasmashell or re-adding systemtray applet helps.

In QML all roles need to be defined before model is used. When data engines is used a a source for a data model, all roles has to be defined and proper value assigned (not a null QVariant). StatusNotifierItemSource does this properly, but in some situations it sets null QVariant for Icon. Setting empty/null QVariant removes key/role from the date set (DataConteiner implementation). If data model was loaded earlier or later when Icon has proper value it will work properly. In some rare situation it is possible that data model is loaded when Icon has null value assigned (in other words - removed), role is removed from the data model and not avaiable to system tray applet.

This fix makes sure that there is always a value for Icon role. To check if icon is null native method has to be used - QML does not understand that QIcon can be null.

BUG: 419305
FIXED-IN: 5.18.5

Test Plan: I don't have any reliable method to reproduce this issue.

Reviewers: #plasma_workspaces, #plasma, davidedmundson, broulik, ngraham

Reviewed By: ngraham

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D29386
parent 6db69ae0
......@@ -45,18 +45,22 @@ AbstractItem {
iconItem: iconItem
function isIconNotNull(icon) {
return icon && !plasmoid.nativeInterface.isIconNull(icon);
}
PlasmaCore.IconItem {
id: iconItem
source: {
if (taskIcon.status === PlasmaCore.Types.NeedsAttentionStatus) {
if (AttentionIcon) {
if (isIconNotNull(AttentionIcon)) {
return AttentionIcon
}
if (AttentionIconName) {
return AttentionIconName
}
}
return Icon ? Icon : IconName
return isIconNotNull(Icon) ? Icon : IconName
}
width: Math.min(parent.width, parent.height)
......
......@@ -341,6 +341,11 @@ bool SystemTray::isSystemTrayApplet(const QString &appletId)
return m_systrayApplets.contains(appletId);
}
bool SystemTray::isIconNull(const QIcon &icon) const
{
return icon.isNull();
}
void SystemTray::restoreContents(KConfigGroup &group)
{
Q_UNUSED(group);
......
......@@ -109,6 +109,13 @@ public:
Q_INVOKABLE bool isSystemTrayApplet(const QString &appletId);
/**
* @brief isIconNull checks if icon is null
* @param icon
* @return true if icon is null
*/
Q_INVOKABLE bool isIconNull(const QIcon &icon) const;
private Q_SLOTS:
void serviceNameFetchFinished(QDBusPendingCallWatcher* watcher, const QDBusConnection &connection);
void serviceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner);
......
......@@ -303,7 +303,7 @@ void StatusNotifierItemSource::refreshCallback(QDBusPendingCallWatcher *call)
overlayIcon(&icon, &overlay);
}
}
setData(QStringLiteral("Icon"), icon.isNull() ? QVariant() : icon);
setData(QStringLiteral("Icon"), icon);
setData(QStringLiteral("IconName"), iconName);
}
......@@ -329,7 +329,7 @@ void StatusNotifierItemSource::refreshCallback(QDBusPendingCallWatcher *call)
overlayIcon(&attentionIcon, &overlay);
}
}
setData(QStringLiteral("AttentionIcon"), attentionIcon.isNull() ? QVariant() : attentionIcon);
setData(QStringLiteral("AttentionIcon"), attentionIcon);
}
//ToolTip
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment