diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2018-08-28 14:24:00 +0200 |
---|---|---|
committer | Johan Helsing <johan.helsing@qt.io> | 2018-08-29 12:54:32 +0000 |
commit | 5439e06206a2411bd0a7fc45b32ac3e00e92f257 (patch) | |
tree | 5696aa14cd7b9abfeb39c55f6439b1378a893026 | |
parent | ec01fddd6b14fa26d9ae9e9f693c6fd419f5ba2c (diff) |
Compositor: Fix assignment to null object in WaylandCursorItem
setCursor would sometimes be called on null objects causing a JavaScript error.
Use Connections instead which will disconnect the signal automatically if
either side is destroyed or in case seat is reassigned.
Change-Id: I70686937b510ab516f27f1e61b2f2a921e74f4b3
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
-rw-r--r-- | src/imports/compositor/WaylandCursorItem.qml | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/imports/compositor/WaylandCursorItem.qml b/src/imports/compositor/WaylandCursorItem.qml index 0f5b289e1..c835ef8b0 100644 --- a/src/imports/compositor/WaylandCursorItem.qml +++ b/src/imports/compositor/WaylandCursorItem.qml @@ -51,16 +51,13 @@ WaylandQuickItem { enabled: false transform: Translate { x: -hotspotX; y: -hotspotY } - onSeatChanged: { - if (!seat) - return; - seat.cursorSurfaceRequest.connect(setCursorSurface); - } - - function setCursorSurface(surface, hotspotX, hotspotY) { - cursorItem.surface = surface; - cursorItem.hotspotX = hotspotX; - cursorItem.hotspotY = hotspotY; + Connections { + target: seat + onCursorSurfaceRequest: { + cursorItem.surface = surface; + cursorItem.hotspotX = hotspotX; + cursorItem.hotspotY = hotspotY; + } } WaylandQuickItem { |