Merge lp:~nick-dedekind/unity8/lp1236249 into lp:unity8

Proposed by Nick Dedekind
Status: Merged
Merged at revision: 447
Proposed branch: lp:~nick-dedekind/unity8/lp1236249
Merge into: lp:unity8
Diff against target: 140 lines (+79/-1)
4 files modified
plugins/Unity/Indicators/rootactionstate.cpp (+15/-1)
plugins/Unity/Indicators/rootactionstate.h (+1/-0)
tests/plugins/Unity/Indicators/CMakeLists.txt (+5/-0)
tests/plugins/Unity/Indicators/rootactionstatetest.cpp (+58/-0)
To merge this branch: bzr merge lp:~nick-dedekind/unity8/lp1236249
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Michael Terry Needs Fixing
Review via email: mp+190687@code.launchpad.net

Commit message

Only use the root action state as a unitymenumodel ActionStateParser when needed.

Description of the change

Only use the root action state as a unitymenumodel ActionStateParser when needed.
Removes issue where object is destroyed before menu.

Added tests.

To post a comment you must log in.
lp:~nick-dedekind/unity8/lp1236249 updated
416. By Nick Dedekind

Only use the parser when needed.

Revision history for this message
Michael Terry (mterry) wrote :

A couple style comments:

17 +void RootActionState::reset() {

Brace should be on new line.

27 if (m_menu && m_menu->rowCount() > 0) {
28 +
29 + ActionStateParser* oldParser = m_menu->actionStateParser();

We can drop the extra new line.

review: Needs Fixing
lp:~nick-dedekind/unity8/lp1236249 updated
417. By Nick Dedekind

fixed style

Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

> A couple style comments:
>
> 17 +void RootActionState::reset() {
>
> Brace should be on new line.
>
> 27 if (m_menu && m_menu->rowCount() > 0) {
> 28 +
> 29 + ActionStateParser* oldParser = m_menu->actionStateParser();
>
> We can drop the extra new line.

Thanks.
Fixed.

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

FAILED: Continuous integration, rev:415
http://jenkins.qa.ubuntu.com/job/unity8-ci/1370/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-saucy/4952
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-touch/2856
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-saucy/2236
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-amd64-ci/393
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-armhf-ci/1370
        deb: http://jenkins.qa.ubuntu.com/job/unity8-saucy-armhf-ci/1370/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-i386-ci/1369
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-saucy/1128
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-amd64/827
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-amd64/827/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/2858
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/2858/artifact/work/output/*zip*/output.zip
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2375
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2415

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/unity8-ci/1370/rebuild

review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/Unity/Indicators/rootactionstate.cpp'
2--- plugins/Unity/Indicators/rootactionstate.cpp 2013-09-17 12:31:19 +0000
3+++ plugins/Unity/Indicators/rootactionstate.cpp 2013-10-11 15:51:58 +0000
4@@ -57,7 +57,7 @@
5 connect(m_menu, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), SLOT(onModelRowsRemoved(const QModelIndex&, int, int)));
6 connect(m_menu, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)), SLOT(onModelDataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)));
7
8- m_menu->setActionStateParser(this);
9+ connect(m_menu, SIGNAL(destroyed()), SLOT(reset()));
10 }
11 updateActionState();
12 Q_EMIT menuChanged();
13@@ -92,10 +92,24 @@
14 }
15 }
16
17+void RootActionState::reset()
18+{
19+ m_cachedState.clear();
20+ m_menu = NULL;
21+
22+ Q_EMIT menuChanged();
23+ Q_EMIT updated();
24+}
25+
26 void RootActionState::updateActionState()
27 {
28 if (m_menu && m_menu->rowCount() > 0) {
29+ ActionStateParser* oldParser = m_menu->actionStateParser();
30+ m_menu->setActionStateParser(this);
31+
32 m_cachedState = m_menu->get(0, "actionState").toMap();
33+
34+ m_menu->setActionStateParser(oldParser);
35 } else {
36 m_cachedState.clear();
37 }
38
39=== modified file 'plugins/Unity/Indicators/rootactionstate.h'
40--- plugins/Unity/Indicators/rootactionstate.h 2013-09-17 12:31:19 +0000
41+++ plugins/Unity/Indicators/rootactionstate.h 2013-10-11 15:51:58 +0000
42@@ -77,6 +77,7 @@
43 void onModelRowsAdded(const QModelIndex& parent, int start, int end);
44 void onModelRowsRemoved(const QModelIndex& parent, int start, int end);
45 void onModelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>&);
46+ void reset();
47
48 private:
49 void updateActionState();
50
51=== modified file 'tests/plugins/Unity/Indicators/CMakeLists.txt'
52--- tests/plugins/Unity/Indicators/CMakeLists.txt 2013-07-17 09:11:03 +0000
53+++ tests/plugins/Unity/Indicators/CMakeLists.txt 2013-10-11 15:51:58 +0000
54@@ -1,6 +1,9 @@
55+pkg_check_modules(QMENUMODEL REQUIRED qmenumodel)
56+
57 include_directories(
58 ${CMAKE_CURRENT_BINARY_DIR}
59 ${CMAKE_CURRENT_SOURCE_DIR}/../../../../plugins/Unity/Indicators
60+ ${QMENUMODEL_INCLUDE_DIRS}
61 )
62
63 macro(run_tests)
64@@ -16,6 +19,7 @@
65 qt5_use_modules(${_test}Exec Test Core Qml)
66 target_link_libraries(${_test}Exec
67 IndicatorsQml
68+ ${QMENUMODEL_LDFLAGS}
69 )
70 set(_test_list "${_test_list};${_test}")
71 endforeach()
72@@ -25,4 +29,5 @@
73 indicatorsmanagertest
74 indicatorsmodeltest
75 menucontentactivatortest
76+ rootactionstatetest
77 )
78
79=== added file 'tests/plugins/Unity/Indicators/rootactionstatetest.cpp'
80--- tests/plugins/Unity/Indicators/rootactionstatetest.cpp 1970-01-01 00:00:00 +0000
81+++ tests/plugins/Unity/Indicators/rootactionstatetest.cpp 2013-10-11 15:51:58 +0000
82@@ -0,0 +1,58 @@
83+/*
84+ * Copyright 2013 Canonical Ltd.
85+ *
86+ * This program is free software; you can redistribute it and/or modify
87+ * it under the terms of the GNU Lesser General Public License as published by
88+ * the Free Software Foundation; version 3.
89+ *
90+ * This program is distributed in the hope that it will be useful,
91+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
92+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
93+ * GNU Lesser General Public License for more details.
94+ *
95+ * You should have received a copy of the GNU Lesser General Public License
96+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
97+ *
98+ * Authors:
99+ * Nick Dedekind <nick.dedekind@canonical.com>
100+ */
101+
102+#include "rootactionstate.h"
103+
104+#include <unitymenumodel.h>
105+#include <QtTest>
106+
107+class RootActionStateTest : public QObject
108+{
109+ Q_OBJECT
110+private Q_SLOTS:
111+
112+ void testDeleteRootActionState()
113+ {
114+ UnityMenuModel* menuModel = new UnityMenuModel();
115+ ActionStateParser* originalParser = menuModel->actionStateParser();
116+ RootActionState* rootState = new RootActionState();
117+
118+ rootState->setMenu(menuModel);
119+
120+ delete rootState;
121+ QCOMPARE(menuModel->actionStateParser(), originalParser);
122+ delete menuModel;
123+ }
124+
125+ void testDeleteUnityMenuModel()
126+ {
127+ UnityMenuModel* menuModel = new UnityMenuModel();
128+ RootActionState* rootState = new RootActionState();
129+
130+ rootState->setMenu(menuModel);
131+
132+ QCOMPARE(rootState->menu(), menuModel);
133+ delete menuModel;
134+ QVERIFY(rootState->menu() == NULL);
135+ delete rootState;
136+ }
137+};
138+
139+QTEST_GUILESS_MAIN(RootActionStateTest)
140+#include "rootactionstatetest.moc"

Subscribers

People subscribed via source and target branches