Activity log for bug #1621509

Date Who What changed Old value New value Message
2016-09-08 14:40:45 Tim Peeters bug added bug
2016-09-08 14:42:28 Tim Peeters ubuntu-ui-toolkit (Ubuntu): importance Undecided Critical
2016-09-08 14:42:32 Tim Peeters tags qt56
2016-09-08 14:43:52 Tim Peeters tags qt56 qt5.6
2016-09-08 15:08:05 Cris Dywan description This is the cause for the Sections index resetting after initialization, see bug https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1610231 Create the file ModelTest.qml: import QtQuick 2.4 Item { id: root width: 800 height: 600 ListView { model: root.model onModelChanged: print("LV model changed to "+model[0]+" "+model[1]+" "+model[2]+" "+model[3]) Component.onCompleted: print("ListView completed.") } Component.onCompleted: print("root item completed.") property list<QtObject> objectList onObjectListChanged: print("root.objectList changed to "+objectList[0]+" "+objectList[1]+" "+objectList[2]) property var model: objectList } and run this program modelInst.qml: import QtQuick 2.4 import Ubuntu.Components 1.3 ModelTest { QtObject { objectName: "one" id: objectOne } QtObject { objectName: "two" id: objectTwo } QtObject{ objectName: "three" id: objectThree } objectList: [objectOne, objectTwo, objectThree] } The output is as follows: ubuntu@xenial1:~/dev/ubuntu-ui-toolkit/m/qt56fixes2sections$ qmlscene modelInst.qml qml: root.objectList changed to undefined undefined undefined qml: root.objectList changed to QObject(0x118abf0, "one") undefined undefined qml: root.objectList changed to QObject(0x118abf0, "one") QObject(0x118a110, "two") undefined qml: root.objectList changed to QObject(0x118abf0, "one") QObject(0x118a110, "two") QObject(0x1182f80, "three") qml: LV model changed to QObject(0x118abf0, "one") QObject(0x118a110, "two") QObject(0x1182f80, "three") undefined qml: LV model changed to QObject(0x118abf0, "one") QObject(0x118a110, "two") QObject(0x1182f80, "three") undefined qml: root item completed. qml: ListView completed. qml: LV model changed to QObject(0x118abf0, "one") QObject(0x118a110, "two") QObject(0x1182f80, "three") undefined qml: LV model changed to QObject(0x118abf0, "one") QObject(0x118a110, "two") QObject(0x1182f80, "three") undefined so the model ic changed AFTER the ListView and root item are completed. When the Ubuntu.Components import is removed, the output is correct, like this: ubuntu@xenial1:~/dev/ubuntu-ui-toolkit/m/qt56fixes2sections$ qmlscene modelInst.qml qml: root.objectList changed to undefined undefined undefined qml: root.objectList changed to QObject(0x171c8d0, "one") undefined undefined qml: root.objectList changed to QObject(0x171c8d0, "one") QObject(0x171d290, "two") undefined qml: root.objectList changed to QObject(0x171c8d0, "one") QObject(0x171d290, "two") QObject(0x171d420, "three") qml: LV model changed to QObject(0x171c8d0, "one") QObject(0x171d290, "two") QObject(0x171d420, "three") undefined qml: LV model changed to QObject(0x171c8d0, "one") QObject(0x171d290, "two") QObject(0x171d420, "three") undefined qml: root item completed. qml: ListView completed. Also, if there is no ListView inside ModelTest.qml, then nothing is updated after the items are completed. So I suspect the issue is in our ListView extension. This is the cause for the Sections index resetting after initialization, see bug 1610231. Create the file ModelTest.qml: import QtQuick 2.4 Item {     id: root     width: 800     height: 600     ListView {         model: root.model         onModelChanged: print("LV model changed to "+model[0]+" "+model[1]+" "+model[2]+" "+model[3])         Component.onCompleted: print("ListView completed.")     }     Component.onCompleted: print("root item completed.")     property list<QtObject> objectList     onObjectListChanged: print("root.objectList changed to "+objectList[0]+" "+objectList[1]+" "+objectList[2])     property var model: objectList } And run this program modelInst.qml: import QtQuick 2.4 import Ubuntu.Components 1.3 ModelTest {     QtObject {         objectName: "one"         id: objectOne     }     QtObject {         objectName: "two"         id: objectTwo     }     QtObject{         objectName: "three"         id: objectThree     }    objectList: [objectOne, objectTwo, objectThree] } The output is as follows: $ qmlscene modelInst.qml qml: root.objectList changed to undefined undefined undefined qml: root.objectList changed to QObject(0x118abf0, "one") undefined undefined qml: root.objectList changed to QObject(0x118abf0, "one") QObject(0x118a110, "two") undefined qml: root.objectList changed to QObject(0x118abf0, "one") QObject(0x118a110, "two") QObject(0x1182f80, "three") qml: LV model changed to QObject(0x118abf0, "one") QObject(0x118a110, "two") QObject(0x1182f80, "three") undefined qml: LV model changed to QObject(0x118abf0, "one") QObject(0x118a110, "two") QObject(0x1182f80, "three") undefined qml: root item completed. qml: ListView completed. qml: LV model changed to QObject(0x118abf0, "one") QObject(0x118a110, "two") QObject(0x1182f80, "three") undefined qml: LV model changed to QObject(0x118abf0, "one") QObject(0x118a110, "two") QObject(0x1182f80, "three") undefined So the model is changed AFTER the ListView and root item are completed. When the Ubuntu.Components import is removed the output is correct: $ qmlscene modelInst.qml qml: root.objectList changed to undefined undefined undefined qml: root.objectList changed to QObject(0x171c8d0, "one") undefined undefined qml: root.objectList changed to QObject(0x171c8d0, "one") QObject(0x171d290, "two") undefined qml: root.objectList changed to QObject(0x171c8d0, "one") QObject(0x171d290, "two") QObject(0x171d420, "three") qml: LV model changed to QObject(0x171c8d0, "one") QObject(0x171d290, "two") QObject(0x171d420, "three") undefined qml: LV model changed to QObject(0x171c8d0, "one") QObject(0x171d290, "two") QObject(0x171d420, "three") undefined qml: root item completed. qml: ListView completed. Also, if there is no ListView inside ModelTest.qml, then nothing is updated after the items are completed. So I suspect the issue is in our ListView extension.
2016-09-08 15:08:26 Launchpad Janitor ubuntu-ui-toolkit (Ubuntu): status New Confirmed
2016-09-14 11:58:29 Tim Peeters ubuntu-ui-toolkit (Ubuntu): assignee Tim Peeters (tpeeters)
2016-09-14 11:58:33 Tim Peeters ubuntu-ui-toolkit (Ubuntu): status Confirmed In Progress
2016-09-14 14:56:20 Tim Peeters summary ListView with extension from UbuntuToolkit updates its model after the component is completed 'window' contextProperty is registered after components are completed
2016-09-15 13:51:17 Tim Peeters description This is the cause for the Sections index resetting after initialization, see bug 1610231. Create the file ModelTest.qml: import QtQuick 2.4 Item {     id: root     width: 800     height: 600     ListView {         model: root.model         onModelChanged: print("LV model changed to "+model[0]+" "+model[1]+" "+model[2]+" "+model[3])         Component.onCompleted: print("ListView completed.")     }     Component.onCompleted: print("root item completed.")     property list<QtObject> objectList     onObjectListChanged: print("root.objectList changed to "+objectList[0]+" "+objectList[1]+" "+objectList[2])     property var model: objectList } And run this program modelInst.qml: import QtQuick 2.4 import Ubuntu.Components 1.3 ModelTest {     QtObject {         objectName: "one"         id: objectOne     }     QtObject {         objectName: "two"         id: objectTwo     }     QtObject{         objectName: "three"         id: objectThree     }    objectList: [objectOne, objectTwo, objectThree] } The output is as follows: $ qmlscene modelInst.qml qml: root.objectList changed to undefined undefined undefined qml: root.objectList changed to QObject(0x118abf0, "one") undefined undefined qml: root.objectList changed to QObject(0x118abf0, "one") QObject(0x118a110, "two") undefined qml: root.objectList changed to QObject(0x118abf0, "one") QObject(0x118a110, "two") QObject(0x1182f80, "three") qml: LV model changed to QObject(0x118abf0, "one") QObject(0x118a110, "two") QObject(0x1182f80, "three") undefined qml: LV model changed to QObject(0x118abf0, "one") QObject(0x118a110, "two") QObject(0x1182f80, "three") undefined qml: root item completed. qml: ListView completed. qml: LV model changed to QObject(0x118abf0, "one") QObject(0x118a110, "two") QObject(0x1182f80, "three") undefined qml: LV model changed to QObject(0x118abf0, "one") QObject(0x118a110, "two") QObject(0x1182f80, "three") undefined So the model is changed AFTER the ListView and root item are completed. When the Ubuntu.Components import is removed the output is correct: $ qmlscene modelInst.qml qml: root.objectList changed to undefined undefined undefined qml: root.objectList changed to QObject(0x171c8d0, "one") undefined undefined qml: root.objectList changed to QObject(0x171c8d0, "one") QObject(0x171d290, "two") undefined qml: root.objectList changed to QObject(0x171c8d0, "one") QObject(0x171d290, "two") QObject(0x171d420, "three") qml: LV model changed to QObject(0x171c8d0, "one") QObject(0x171d290, "two") QObject(0x171d420, "three") undefined qml: LV model changed to QObject(0x171c8d0, "one") QObject(0x171d290, "two") QObject(0x171d420, "three") undefined qml: root item completed. qml: ListView completed. Also, if there is no ListView inside ModelTest.qml, then nothing is updated after the items are completed. So I suspect the issue is in our ListView extension. This is the cause for the Sections index resetting after initialization, see bug 1610231. Use this code: ------ ModelFromList13.qml ------ import QtQuick 2.4 // This component is used in tst_listview_bug1621509.13.qml Item { id: root property var myObject property int count: 0 // will hold the number of changes to myObject after Component.completed. onMyObjectChanged: { print("myObject changed to "+myObject) count++; } Component.onCompleted: { count = 0; } } ------ tst_list_model_from_list_bug1621509.13.qml ------ import QtQuick 2.4 import QtTest 1.0 // Ubuntu.Components is not explicitly used below, but its import causes bug #1621509. import Ubuntu.Components 1.3 TestCase { id: testCase name: "EmbeddedListView" width: 100 height: 100 // Bug #1621509 only occurs when we wait for the window to be visible. // Forces the components to be completed before the test functions are executed. when: windowShown ModelFromList13 { id: embeddedListView QtObject { objectName: "one" id: objectOne } myObject: objectOne } Component.onCompleted: { print("Component completed."); // must print something to reproduce the bug. } function test_no_model_change_after_completed_bug1621509_bug1610231() { compare(embeddedListView.count, 0, "The model was changed after the component was completed."); } } ---------- the test will fail. Also, one can replace the TestCase by Item (and remove when: windowShown) and simply use qmlscene to start the app. It will show that myObject is set twice: before the component completed, and then again afterwards. I suspect the reason for this is the change of the 'window' context property which causes everything in the context (objectOne) and properties that depend on that to be re-evaluated.
2016-09-19 22:15:49 Launchpad Janitor branch linked lp:~tpeeters/ubuntu-ui-toolkit/qt56fixes2sections
2016-09-27 17:31:10 Tim Peeters ubuntu-ui-toolkit (Ubuntu): status In Progress Fix Committed
2016-10-03 09:36:26 Launchpad Janitor branch linked lp:~ci-train-bot/ubuntu-ui-toolkit/ubuntu-ui-toolkit-ubuntu-yakkety-2035
2016-10-06 21:49:54 Launchpad Janitor ubuntu-ui-toolkit (Ubuntu): status Fix Committed Fix Released