Comment 0 for bug 1333460

Revision history for this message
damianatorrpm@gmail.com (damianatorrpm) wrote :

GSettings-qt crashes when qlist (any list value in gsettings), below

  Example code:
  Binding {target: virtualDesktopSettings; property:"names"; value:windowSystem.desktopNames}
  Binding {target: windowSystem; property: "desktopNames"; value:virtualDesktopSettings.names}
//windowSystem is another cpp plugin exposing also virtual desktop names

    GSettings {id:virtualDesktopSettings;
        schema.id:"org.qmldesktop.virtualdesktops";
        schema.path:"/org/qmldesktop/virtualdesktops/";
    }

Scenario A:
 You close above application and change the value (as an example the names of the virtual desktops)
somehow externally via windowManager/Unity/KDE/etc
from [ "old_desktopname1", "old_desktopname2" ] to [ "new_desktopname1", "new_desktopname2" ]
and restart the application.
//This works

Scenario B:
 You close above application and change the value (as an example the names of the virtual desktops)
somehow externally via windowManager/Unity/KDE/etc
from [ "old_desktopname1", "old_desktopname2" ] to [ "new_desktopname1", "new_desktopname2", "new_desktopname3" ]
and restart the application.
//The length changed as we added an additional virtual desktop. Now the application just crashes:
//ASSERT failure in QList<T>::operator[]: "index out of range", file ../../Qt5.3.0/5.3/gcc_64/include/QtCore/qlist.h, line 487
//The program has unexpectedly finished.

Workaround:
//change example code to:
property bool startSync
Timer {running:true;interval:1000; onTriggered:startSync=true}
  Binding {target: virtualDesktopSettings; property:"names"; value:windowSystem.desktopNames}
  Binding {target: windowSystem; property: "desktopNames"; value:virtualDesktopSettings.names;when:(startSync)}
//windowSystem is another cpp plugin exposing also virtual desktop names

    GSettings {id:virtualDesktopSettings;
        schema.id:"org.qmldesktop.virtualdesktops";
        schema.path:"/org/qmldesktop/virtualdesktops/";
    }

PS:
Just wondering right now on such a bidirectional binding, if changed while application was not running which one should have precedence (when I set when: it's obvious)? Should GSettings enforce it's settings, or the other side enforce onto GSettings?
But this should be more of a Qt request for a true QML BiDirectionalBinding {}