Commit c2b41137 authored by ivan tkachenko's avatar ivan tkachenko Committed by Nate Graham
Browse files

[applets/touchpad] Fix potential undefined property access

There's a race condition between the hasTouchpad and touchpadEnabled

This commit fixes a potential undefined property access, in case if an
expression for touchpadEnabled property is re-evaluated before its
dependency -- hasTouchpad property -- toggles from true to false.

With this commit patch applied, there's still a race in Plasmoid.status
and Plasmoid.toolTipSubText, but we don't care about it as much, as
those harmless strings/enums would become "eventually consistent" by
the end of their cycle of the event loop.
parent 188d3cf4
Pipeline #130047 passed with stage
in 5 minutes and 28 seconds
......@@ -31,8 +31,13 @@ import org.kde.plasma.plasmoid 2.0
Item {
id: root
// Don't de-duplicate `touchpadEnabled` expression using `hasTouchpad`
// property, QML doesn't work that way. Order of signals propagation is
// not specified, so if/when data source disconnects, touchpadEnabled
// might get re-evaluated while hasTouchpad is still true.
readonly property bool hasTouchpad: typeof !== "undefined" &&
readonly property bool touchpadEnabled: hasTouchpad ? : false
readonly property bool touchpadEnabled: typeof !== "undefined" &&
Plasmoid.preferredRepresentation: Plasmoid.compactRepresentation
Plasmoid.icon: touchpadEnabled ? "input-touchpad-on" : "input-touchpad-off"
Supports Markdown
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