Orientation lock switch doesn't notice gsettings changes

Bug #1390643 reported by Charles Kerr
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gsettings-qt
Invalid
Undecided
Unassigned
ubuntu-system-settings (Ubuntu)
Fix Released
High
Sebastien Bacher
ubuntu-system-settings (Ubuntu RTM)
New
Undecided
Unassigned

Bug Description

Changes to the GSettings aren't reflected in the UI unless they're triggered from inside of system settings.

Manual test I tried out on 14.10 r151:

1. launch system settings
2. turn on orientation lock if it's not already on
3. from phablet shell, run "gsettings get com.ubuntu.touch.system rotation-lock" to confirm lock setting reads "true"
4. tap settings' orientation lock switch to disable lock
5. from phablet shell, run "gsettings get com.ubuntu.touch.system rotation-lock" again to confirm lock setting now reads "false"
6. from phablet shell, run "gsettings set com.ubuntu.touch.system rotation-lock true" to enable rotation lock
7. from system sesttings, confirm that the orientation lock switch shows the feature enabled
8. from phablet shell, run "gsettings set com.ubuntu.touch.system rotation-lock false" to disable rotation lock
9. from system sesttings, confirm that the orientation lock switch now shows the feature disabled

Fails on step 6 -- changing the GSettings isn't reflected in the UI.

This also breaks u-s-s if the flag is toggled from the rotation lock indicator (when the rotation lock indicator lands).

Charles Kerr (charlesk)
description: updated
description: updated
Omer Akram (om26er)
Changed in ubuntu-system-settings (Ubuntu):
status: New → Confirmed
Revision history for this message
Charles Kerr (charlesk) wrote :

Adding gsettings-qt for another pair of eyes because at first glance the u-s-s code looks alright:

http://bazaar.launchpad.net/~system-settings-touch/ubuntu-system-settings/rtm-14.09/view/head:/plugins/orientation-lock/EntryComponent.qml?start_revid=935

    control: Switch {
        id: control
        objectName: "orientationLockSwitch"
        checked: systemSettings.rotationLock
        onClicked: {
            systemSettings.rotationLock = checked
        }
        GSettings {
            id: systemSettings
            schema.id: "com.ubuntu.touch.system"
        }
    }

Revision history for this message
Lars Karlitski (larsu) wrote :

The problem seems to be that the binding (checked: systemSettings.rotationLock) gets destroyed when assigning the value in the click handler. It works if you either explicitly set the value in onChanged of the settings object:

  GSettings {
    id: systemSettings
    schema.id: "com.ubuntu.touch.system"
    onChanged: control.checked = settings.rotationLock
  }

That's a bit ugly, because now the settings object needs to know about all UI elements that depend on it. Alternatively, you can use the Binding element:

  Binding {
    target: control
    property: 'checked'
    value: systemSettings.rotationLock
  }

To be honest, I don't know what the difference between the two ways of binding properties is, but the one with the Binding element works in my test.

(Removing gsettings-qt, as it's not a bug in that)

Changed in gsettings-qt:
status: New → Invalid
Changed in ubuntu-system-settings (Ubuntu):
importance: Undecided → High
Revision history for this message
Michał Sawicz (saviq) wrote :

We have a general lack of two-way bindings (and for a reason, they're not trivial in async world). Using Binding { } is preferable over assignment in a signal handler, though.

And yeah, the original binding is destroyed because the component assigns a value to its "checked" property, so the binding has nowhere to "live" any more. Having an explicit Binding { } object works around this. Because "checked" changes onClick anyway, you should probably use a Binding the other way, too, instead of assigning to systemSettings.rotationLock.

Changed in ubuntu-system-settings (Ubuntu):
status: Confirmed → In Progress
assignee: nobody → Sebastien Bacher (seb128)
Olli Ries (ories)
tags: added: rtm14 touch-2014-11-06
Revision history for this message
Sebastien Bacher (seb128) wrote :

the issue should be already fixed with https://launchpad.net/ubuntu/+source/ubuntu-system-settings/0.3+15.04.20141105.1-0ubuntu1

that's being backported to rtm next

Changed in ubuntu-system-settings (Ubuntu):
assignee: Sebastien Bacher (seb128) → nobody
assignee: nobody → Sebastien Bacher (seb128)
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.