Mir-backed InputDeviceModel’s count property is not updated timely
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
qtsystems-opensource-src (Ubuntu) |
Fix Released
|
High
|
Lorn Potter |
Bug Description
I’m trying to use InputDeviceModel from QML with the following example:
import QtQuick 2.4
import QtSystemInfo 5.5
Item {
InputDeviceModel {
id: idm
filter: InputInfo.Mouse
onCountChanged: console.log("mice model count:", devices, count)
onAdded: console.log("added mouse:", inputDevice, count)
onRemoved: console.
}
readonly property bool hasMouse: idm.count > 0
onHasMouseCha
}
When I launch the example with qmlscene on my arale with no mouse connected, I’m not seeing any output (expected).
Then I connect a bluetooth keyboard/mouse combo, and I’m seeing the following:
mice model count: 1 0
added mouse: QInputDevice(
(note how 'hasMouse', which supposedly was initially false, hasn’t been updated)
Then I disconnect the combo, and I’m seeing the following:
mice model count: 0 1
has mouse: true
removed mouse: 15 0
Then I connect it again, and I’m seeing the following:
mice model count: 1 0
has mouse: false
added mouse: QInputDevice(
It appears the countChanged property is emitted before a device is added to/removed from the model, and thus the row count hasn’t actually been updated yet. So any property binding that relies on 'count' will have an incorrect value.
Changed in qtsystems-opensource-src (Ubuntu): | |
importance: | Undecided → High |
status: | New → In Progress |
I guess an easy fix would be to emit countChanged again when a device is added to/removed from the model. A (probably) better approach would be to not emit countChanged until after the model has been updated.