Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 61b2b173 authored by Stefan Brüns's avatar Stefan Brüns

[Device Notifier] Avoid accessing attributes of stale UDIs

Summary:
When a Solid device is removed (e.g. a CD is ejected) the notifier tries
to read the attributes although the Source for the UDI has just vanished.

Fixes several QML error messages, i.e. "TypeError: Cannot read property
'...' of undefined" and "Unable to assign [undefined] to QString".

Apparently these errors also have the effect of items showing outdated
state, i.e. optical media still being shown after ejecting it.

CCBUG: 394348

Test Plan:
1. insert optical medium
2. eject
Without the changes, the item was stuck
Now, the item is removed as soon as the medium is ejected

Also, no more errors are logged for the devicenotifier

Reviewers: #frameworks, broulik

Reviewed By: broulik

Subscribers: ngraham, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D15687
parent 7a93d2cd
......@@ -158,10 +158,10 @@ MouseArea {
DeviceItem {
width: notifierDialog.width
udi: DataEngineSource
icon: sdSource.data[udi].Icon
deviceName: sdSource.data[udi].Description
emblemIcon: Emblems[0]
state: sdSource.data[udi].State
icon: sdSource.data[udi] ? sdSource.data[udi].Icon : ""
deviceName: sdSource.data[udi] ? sdSource.data[udi].Description : ""
emblemIcon: Emblems && Emblems[0] ? Emblems[0] : ""
state: sdSource.data[udi] ? sdSource.data[udi].State : 0
percentUsage: {
if (!sdSource.data[udi]) {
......@@ -177,9 +177,10 @@ MouseArea {
actionIcon: mounted ? "media-eject" : "media-mount"
actionVisible: model["Device Types"].indexOf("Portable Media Player") == -1
actionToolTip: {
var types = model["Device Types"];
if (!mounted) {
return i18n("Click to access this device from other applications.")
} else if (model["Device Types"].indexOf("OpticalDisc") != -1) {
} else if (types && types.indexOf("OpticalDisc") != -1) {
return i18n("Click to eject this disc.")
} else {
return i18n("Click to safely remove this device.")
......
......@@ -140,6 +140,10 @@ Item {
}
var device = data[udi];
if (!device) {
return false;
}
return (devicesType === "removable" && device.Removable)
|| (devicesType === "nonRemovable" && !device.Removable);
}
......@@ -246,6 +250,10 @@ Item {
}
function isMounted(udi) {
if (!sdSource.data[udi]) {
return false;
}
var types = sdSource.data[udi]["Device Types"];
if (types.indexOf("Storage Access") >= 0) {
return sdSource.data[udi]["Accessible"];
......
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