Merge lp:~fboucault/ubuntu-ui-toolkit/state_saving_store_type into lp:ubuntu-ui-toolkit/staging

Proposed by Florian Boucault
Status: Merged
Approved by: Cris Dywan
Approved revision: 1167
Merged at revision: 1167
Proposed branch: lp:~fboucault/ubuntu-ui-toolkit/state_saving_store_type
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 146 lines (+79/-3)
4 files modified
modules/Ubuntu/Components/plugin/statesaverbackend_p.cpp (+23/-2)
tests/unit_x11/tst_statesaver/SaveEnum.qml (+23/-0)
tests/unit_x11/tst_statesaver/tst_statesaver.cpp (+31/-0)
tests/unit_x11/tst_statesaver/tst_statesaver.pro (+2/-1)
To merge this branch: bzr merge lp:~fboucault/ubuntu-ui-toolkit/state_saving_store_type
Reviewer Review Type Date Requested Status
Cris Dywan Approve
PS Jenkins bot continuous-integration Approve
Tim Peeters Pending
Review via email: mp+228503@code.launchpad.net

Commit message

StateSaver: also save the type of each property along with its value so that we can convert them back to the right type during state restoration.
This makes some problematic cases such as enumeration to work.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:1163
http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-ci/668/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/2582
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/2065
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-amd64-ci/500
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-armhf-ci/500
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-armhf-ci/500/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-i386-ci/500
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/2720
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/3825
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/3825/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/10534
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/1727
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/2318
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/2318/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-ci/668/rebuild

review: Approve (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) wrote :

See comments inline.

Question: can this ultimately be addressed in QSettings and could a bug be filed/ added as a comment? Provided it's not a fundamental design problem.

review: Needs Fixing
Revision history for this message
Florian Boucault (fboucault) wrote :

> See comments inline.
>
> Question: can this ultimately be addressed in QSettings and could a bug be
> filed/ added as a comment? Provided it's not a fundamental design problem.

It does sound like QSettings should do a better job. Not sure how to describe it.

Revision history for this message
Cris Dywan (kalikiana) wrote :

Nice. Thanks a lot!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:1164
http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-ci/673/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/2599
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/2082
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-amd64-ci/505
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-armhf-ci/505
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-armhf-ci/505/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-i386-ci/505
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/2733
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/3842
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/3842/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/10553
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/1740
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/2335
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/2335/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-ci/673/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-autolanding/284/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/2614/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/2097
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-amd64-autolanding/228
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-armhf-autolanding/228
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-armhf-autolanding/228/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-i386-autolanding/228
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/2746/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/3857
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/3857/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/10567
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/1751
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/2350
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/2350/artifact/work/output/*zip*/output.zip

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:1166
http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-ci/676/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/2617/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/2100
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-amd64-ci/508
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-armhf-ci/508
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-armhf-ci/508/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-i386-ci/508
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/2749/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/3860
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/3860/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/10571
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/1754
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/2353
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/2353/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-ci/676/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) wrote :

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/unity8/process_helpers.py", line 123, in restart_unity_with_testability
    return restart_unity(*args)
  File "/usr/lib/python3/dist-packages/unity8/process_helpers.py", line 155, in restart_unity
    pid = _get_unity_pid()
  File "/usr/lib/python3/dist-packages/unity8/process_helpers.py", line 178, in _get_unity_pid
    return int(status.split()[-1])
ValueError: invalid literal for int() with base 10: 'start/running'

1167. By Florian Boucault

Empty commit

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:1167
http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-ci/677/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/2641
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/2111
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-amd64-ci/509
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-armhf-ci/509
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-armhf-ci/509/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-i386-ci/509
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/2769
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/3884
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/3884/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/10602
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/1765
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/2368
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/2368/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-ci/677/rebuild

review: Approve (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/Ubuntu/Components/plugin/statesaverbackend_p.cpp'
2--- modules/Ubuntu/Components/plugin/statesaverbackend_p.cpp 2014-03-17 11:57:53 +0000
3+++ modules/Ubuntu/Components/plugin/statesaverbackend_p.cpp 2014-07-29 09:48:52 +0000
4@@ -145,8 +145,20 @@
5 }
6 QQmlProperty qmlProperty(item, propertyName.toLocal8Bit().constData(), qmlContext(item));
7 if (qmlProperty.isValid() && qmlProperty.isWritable()) {
8- qmlProperty.write(value);
9- result++;
10+ QVariant type = m_archive.data()->value(propertyName + "_TYPE");
11+ value.convert(type.toInt());
12+ bool writeSuccess = qmlProperty.write(value);
13+ if (writeSuccess) {
14+ result++;
15+ } else {
16+ qmlInfo(item) << UbuntuI18n::instance().tr("property \"%1\" of "
17+ "object %2 has type %3 and cannot be set to value \"%4\" of"
18+ " type %5").arg(propertyName)
19+ .arg(qmlContext(item)->nameForObject(item))
20+ .arg(qmlProperty.propertyTypeName())
21+ .arg(value.toString())
22+ .arg(value.typeName());
23+ }
24 } else {
25 qmlInfo(item) << UbuntuI18n::instance().tr("property \"%1\" does not exist or is not writable for object %2")
26 .arg(propertyName).arg(qmlContext(item)->nameForObject(item));
27@@ -173,6 +185,15 @@
28 QVariant value = qmlProperty.read();
29 if (static_cast<QMetaType::Type>(value.type()) != QMetaType::QObjectStar) {
30 m_archive.data()->setValue(propertyName, value);
31+ /* Save the type of the property along with its value.
32+ * This is important because QSettings deserializes values as QString.
33+ * Setting these strings to QML properties usually works because the
34+ * implicit type conversion from string to the type of the QML property
35+ * usually works. In some cases cases however (e.g. enum) it fails.
36+ *
37+ * See Qt Bug: https://bugreports.qt-project.org/browse/QTBUG-40474
38+ */
39+ m_archive.data()->setValue(propertyName + "_TYPE", QVariant::fromValue((int)value.type()));
40 result++;
41 }
42 }
43
44=== added file 'tests/unit_x11/tst_statesaver/SaveEnum.qml'
45--- tests/unit_x11/tst_statesaver/SaveEnum.qml 1970-01-01 00:00:00 +0000
46+++ tests/unit_x11/tst_statesaver/SaveEnum.qml 2014-07-29 09:48:52 +0000
47@@ -0,0 +1,23 @@
48+/*
49+ * Copyright 2014 Canonical Ltd.
50+ *
51+ * This program is free software; you can redistribute it and/or modify
52+ * it under the terms of the GNU Lesser General Public License as published by
53+ * the Free Software Foundation; version 3.
54+ *
55+ * This program is distributed in the hope that it will be useful,
56+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
57+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58+ * GNU Lesser General Public License for more details.
59+ *
60+ * You should have received a copy of the GNU Lesser General Public License
61+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
62+ */
63+
64+import QtQuick 2.0
65+import Ubuntu.Components 1.1
66+
67+Text {
68+ id: testItem
69+ StateSaver.properties: "horizontalAlignment"
70+}
71
72=== modified file 'tests/unit_x11/tst_statesaver/tst_statesaver.cpp'
73--- tests/unit_x11/tst_statesaver/tst_statesaver.cpp 2014-04-10 09:36:36 +0000
74+++ tests/unit_x11/tst_statesaver/tst_statesaver.cpp 2014-07-29 09:48:52 +0000
75@@ -36,8 +36,10 @@
76 #include <signal.h>
77
78 #define protected public
79+#define private public
80 #include "ucstatesaver.h"
81 #include "statesaverbackend_p.h"
82+#undef private
83 #undef protected
84
85 class tst_StateSaverTest : public QObject
86@@ -59,6 +61,8 @@
87 {
88 Q_EMIT StateSaverBackend::instance().initiateStateSaving();
89 view.reset();
90+ // Make sure that the state is reloaded from file
91+ StateSaverBackend::instance().m_archive.data()->sync();
92 view.reset(new UbuntuTestCase(file));
93 }
94
95@@ -66,6 +70,8 @@
96 {
97 Q_EMIT StateSaverBackend::instance().initiateStateSaving();
98 view.reset();
99+ // Make sure that the state is reloaded from file
100+ StateSaverBackend::instance().m_archive.data()->sync();
101 view.reset(createView(file));
102 }
103
104@@ -171,6 +177,31 @@
105 }
106 }
107
108+ void test_SaveEnum()
109+ {
110+ /* This test is important because when saving the value of an enum
111+ * property to QSettings, it is deserialized as a string. Setting that
112+ * string value to an enum property fails and therefore the state
113+ * restoration does not work.
114+ * In most cases implicit type conversion from string to the appropriate
115+ * type works.
116+ */
117+ QScopedPointer<QQuickView> view(createView("SaveEnum.qml"));
118+ QVERIFY(view);
119+ QObject *testItem = view->rootObject();
120+ QVERIFY(testItem);
121+
122+ testItem->setProperty("horizontalAlignment", Qt::AlignRight);
123+
124+ resetView(view, "SaveEnum.qml");
125+ QVERIFY(view);
126+ testItem = view->rootObject();
127+ QVERIFY(testItem);
128+
129+
130+ QVERIFY(testItem->property("horizontalAlignment") == Qt::AlignRight);
131+ }
132+
133 void test_SavePropertyGroup()
134 {
135 QScopedPointer<QQuickView> view(createView("SavePropertyGroups.qml"));
136
137=== modified file 'tests/unit_x11/tst_statesaver/tst_statesaver.pro'
138--- tests/unit_x11/tst_statesaver/tst_statesaver.pro 2014-02-06 19:16:34 +0000
139+++ tests/unit_x11/tst_statesaver/tst_statesaver.pro 2014-07-29 09:48:52 +0000
140@@ -26,4 +26,5 @@
141 RepeaterStates.qml \
142 ListViewItems.qml \
143 GridViewItems.qml \
144- NormalAppClose.qml
145+ NormalAppClose.qml \
146+ SaveEnum.qml

Subscribers

People subscribed via source and target branches