Mir-backed InputDeviceModel’s count property is not updated timely

Bug #1646080 reported by Olivier Tilloy
8
This bug affects 1 person
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.log("removed mouse:", deviceId, count)
  }
  readonly property bool hasMouse: idm.count > 0
  onHasMouseChanged: console.log("has mouse:", hasMouse)
}

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(0x17f6298) 1
  (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(0x18ee508) 1

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.

Tags: patch
Revision history for this message
Olivier Tilloy (osomon) wrote :

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.

Changed in qtsystems-opensource-src (Ubuntu):
assignee: nobody → Lorn Potter (lorn-potter)
Revision history for this message
Olivier Tilloy (osomon) wrote :

Attaching a simple patch that fixes the issue for me. Please review!

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "fix-1646080.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Changed in qtsystems-opensource-src (Ubuntu):
importance: Undecided → High
status: New → In Progress
Revision history for this message
Lorn Potter (lorn-potter) wrote :

@osomon looks good. I will apply upstream.

Revision history for this message
Lorn Potter (lorn-potter) wrote :
Revision history for this message
Olivier Tilloy (osomon) wrote :

Thanks!

Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

Can you test the ticket? It would be ready for xenial (overlay) and zesty.

Revision history for this message
Olivier Tilloy (osomon) wrote :

I tested silo 2326 on desktop and frieza (both on xenial+overlay), and I confirm that it fixes the issue. Thanks!

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package qtsystems-opensource-src - 5.0~git20141206~44f70d99-0ubuntu12~1

---------------
qtsystems-opensource-src (5.0~git20141206~44f70d99-0ubuntu12~1) zesty; urgency=medium

  * debian/patches/Fix-InputDeviceModel-on-Mir-count-property.patch:
    - Fix InputDeviceModel on Mir (LP: #1646080)

 -- Timo Jyrinki <email address hidden> Fri, 18 Nov 2016 09:45:02 +0000

Changed in qtsystems-opensource-src (Ubuntu):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.