Merge lp:~saviq/unity8/revert-r376 into lp:unity8

Proposed by Michał Sawicz
Status: Merged
Approved by: Loïc Minier
Approved revision: 395
Merged at revision: 395
Proposed branch: lp:~saviq/unity8/revert-r376
Merge into: lp:unity8
Diff against target: 409 lines (+9/-128)
7 files modified
Components/PageHeader.qml (+1/-44)
Dash/GenericScopeView.qml (+0/-1)
plugins/Unity/scope.cpp (+5/-30)
plugins/Unity/scope.h (+2/-7)
tests/mocks/Unity/fake_scope.cpp (+0/-13)
tests/mocks/Unity/fake_scope.h (+1/-5)
tests/qmltests/Components/tst_PageHeader.qml (+0/-28)
To merge this branch: bzr merge lp:~saviq/unity8/revert-r376
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Loïc Minier Approve
Review via email: mp+189455@code.launchpad.net

Commit message

Revert r376 that caused constant CPU usage due to the ActivityIndicator.

To post a comment you must log in.
Revision history for this message
Loïc Minier (lool) wrote :

Tested binaries that Saviq provided for indicator-network and for unity8 with the unity-notifications before revert, and I didn't get the high CPU usage anymore.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Components/PageHeader.qml'
--- Components/PageHeader.qml 2013-10-02 16:11:27 +0000
+++ Components/PageHeader.qml 2013-10-05 08:36:17 +0000
@@ -18,7 +18,6 @@
18import Ubuntu.Components 0.118import Ubuntu.Components 0.1
19import Ubuntu.Components.Popups 0.119import Ubuntu.Components.Popups 0.1
20import Ubuntu.Components.ListItems 0.1 as ListItem20import Ubuntu.Components.ListItems 0.1 as ListItem
21import Unity 0.1
2221
23Item {22Item {
24 /*!23 /*!
@@ -31,7 +30,6 @@
31 property bool searchEntryEnabled: false30 property bool searchEntryEnabled: false
32 property alias searchQuery: searchField.text31 property alias searchQuery: searchField.text
33 property ListModel searchHistory: SearchHistoryModel {}32 property ListModel searchHistory: SearchHistoryModel {}
34 property Scope scope
3533
36 height: units.gu(8.5)34 height: units.gu(8.5)
37 implicitHeight: units.gu(8.5)35 implicitHeight: units.gu(8.5)
@@ -150,7 +148,7 @@
150 hasClearButton: false148 hasClearButton: false
151149
152 primaryItem: AbstractButton {150 primaryItem: AbstractButton {
153 enabled: searchField.text != "" && !searchIndicator.running151 enabled: searchField.text != ""
154 onClicked: {152 onClicked: {
155 if (searchField.text != "") {153 if (searchField.text != "") {
156 searchHistory.addQuery(searchField.text)154 searchHistory.addQuery(searchField.text)
@@ -160,22 +158,8 @@
160 height: parent.height158 height: parent.height
161 width: height159 width: height
162160
163 ActivityIndicator {
164 id: searchIndicator
165 objectName: "searchIndicator"
166
167 anchors {
168 verticalCenter: parent.verticalCenter
169 left: parent.left
170 leftMargin: units.gu(0.5)
171 }
172
173 running: opacity > 0
174 }
175
176 Image {161 Image {
177 id: primaryImage162 id: primaryImage
178 objectName: "primaryImage"
179 anchors {163 anchors {
180 verticalCenter: parent.verticalCenter164 verticalCenter: parent.verticalCenter
181 left: parent.left165 left: parent.left
@@ -183,7 +167,6 @@
183 }167 }
184 width: units.gu(3)168 width: units.gu(3)
185 height: units.gu(3)169 height: units.gu(3)
186 visible: opacity > 0
187 }170 }
188171
189 Item {172 Item {
@@ -202,32 +185,6 @@
202 onActiveFocusChanged: {185 onActiveFocusChanged: {
203 if (!activeFocus) searchContainer.closePopover()186 if (!activeFocus) searchContainer.closePopover()
204 }187 }
205
206 states: [
207 State {
208 name: "searching"
209 when: scope.searchInProgress && searchField.text !== ""
210 PropertyChanges { target: searchIndicator; running: true; opacity: 1 }
211 PropertyChanges { target: primaryImage; opacity: 0 }
212 },
213 State {
214 name: "idle"
215 when: !scope.searchInProgress || searchField.text === ""
216 PropertyChanges { target: searchIndicator; opacity: 0 }
217 PropertyChanges { target: primaryImage; opacity: 1 }
218 }
219 ]
220
221 transitions: [
222 Transition {
223 to: "searching"
224 reversible: true
225 SequentialAnimation {
226 NumberAnimation { target: primaryImage; property: "opacity"; duration: UbuntuAnimation.FastDuration; easing.type: Easing.Linear }
227 NumberAnimation { target: searchIndicator; property: "opacity"; duration: UbuntuAnimation.FastDuration; easing.type: Easing.Linear }
228 }
229 }
230 ]
231 }188 }
232189
233 states: [190 states: [
234191
=== modified file 'Dash/GenericScopeView.qml'
--- Dash/GenericScopeView.qml 2013-10-04 15:44:55 +0000
+++ Dash/GenericScopeView.qml 2013-10-05 08:36:17 +0000
@@ -190,7 +190,6 @@
190 width: categoryView.width190 width: categoryView.width
191 text: scopeView.scope.name191 text: scopeView.scope.name
192 searchEntryEnabled: true192 searchEntryEnabled: true
193 scope: scopeView.scope
194 }193 }
195 }194 }
196195
197196
=== modified file 'plugins/Unity/scope.cpp'
--- plugins/Unity/scope.cpp 2013-09-30 11:33:51 +0000
+++ plugins/Unity/scope.cpp 2013-10-05 08:36:17 +0000
@@ -33,14 +33,12 @@
33#include <QQmlEngine>33#include <QQmlEngine>
3434
35#include <UnityCore/Variant.h>35#include <UnityCore/Variant.h>
36#include <UnityCore/GLibWrapper.h>
3736
38#include <libintl.h>37#include <libintl.h>
39#include <glib.h>38#include <glib.h>
4039
41Scope::Scope(QObject *parent) : QObject(parent)40Scope::Scope(QObject *parent) : QObject(parent)
42 , m_formFactor("phone")41 , m_formFactor("phone")
43 , m_searchInProgress(false)
44{42{
45 m_categories.reset(new Categories(this));43 m_categories.reset(new Categories(this));
46}44}
@@ -70,11 +68,6 @@
70 return QString::fromStdString(m_unityScope->search_hint());68 return QString::fromStdString(m_unityScope->search_hint());
71}69}
7270
73bool Scope::searchInProgress() const
74{
75 return m_searchInProgress;
76}
77
78bool Scope::visible() const71bool Scope::visible() const
79{72{
80 return m_unityScope->visible();73 return m_unityScope->visible();
@@ -122,15 +115,10 @@
122 string ("") and m_searchQuery is the null string,115 string ("") and m_searchQuery is the null string,
123 search_query != m_searchQuery is still true.116 search_query != m_searchQuery is still true.
124 */117 */
125 using namespace std::placeholders;
126
127 if (m_searchQuery.isNull() || search_query != m_searchQuery) {118 if (m_searchQuery.isNull() || search_query != m_searchQuery) {
128 m_searchQuery = search_query;119 m_searchQuery = search_query;
129 m_cancellable.Renew();120 m_unityScope->Search(search_query.toStdString(), sigc::mem_fun(this, &Scope::searchFinished));
130 m_searchInProgress = true;
131 m_unityScope->Search(search_query.toStdString(), std::bind(&Scope::onSearchFinished, this, _1, _2, _3), m_cancellable);
132 Q_EMIT searchQueryChanged();121 Q_EMIT searchQueryChanged();
133 Q_EMIT searchInProgressChanged();
134 }122 }
135}123}
136124
@@ -306,6 +294,8 @@
306 m_unityScope->visible.changed.connect(sigc::mem_fun(this, &Scope::visibleChanged));294 m_unityScope->visible.changed.connect(sigc::mem_fun(this, &Scope::visibleChanged));
307 m_unityScope->shortcut.changed.connect(sigc::mem_fun(this, &Scope::shortcutChanged));295 m_unityScope->shortcut.changed.connect(sigc::mem_fun(this, &Scope::shortcutChanged));
308 m_unityScope->connected.changed.connect(sigc::mem_fun(this, &Scope::connectedChanged));296 m_unityScope->connected.changed.connect(sigc::mem_fun(this, &Scope::connectedChanged));
297 /* Signals forwarding */
298 connect(this, SIGNAL(searchFinished(const std::string &, unity::glib::HintsMap const &, unity::glib::Error const &)), SLOT(onSearchFinished(const std::string &, unity::glib::HintsMap const &)));
309299
310 /* FIXME: signal should be forwarded instead of calling the handler directly */300 /* FIXME: signal should be forwarded instead of calling the handler directly */
311 m_unityScope->activated.connect(sigc::mem_fun(this, &Scope::onActivated));301 m_unityScope->activated.connect(sigc::mem_fun(this, &Scope::onActivated));
@@ -326,33 +316,18 @@
326316
327void Scope::synchronizeStates()317void Scope::synchronizeStates()
328{318{
329 using namespace std::placeholders;
330
331 if (connected()) {319 if (connected()) {
332 /* Forward local states to m_unityScope */320 /* Forward local states to m_unityScope */
333 if (!m_searchQuery.isNull()) {321 if (!m_searchQuery.isNull()) {
334 m_cancellable.Renew();322 m_unityScope->Search(m_searchQuery.toStdString());
335 m_searchInProgress = true;
336 m_unityScope->Search(m_searchQuery.toStdString(), std::bind(&Scope::onSearchFinished, this, _1, _2, _3), m_cancellable);
337 Q_EMIT searchInProgressChanged();
338 }323 }
339 }324 }
340}325}
341326
342void Scope::onSearchFinished(std::string const& /* query */, unity::glib::HintsMap const& hints, unity::glib::Error const& err)327void Scope::onSearchFinished(const std::string& /* query */, unity::glib::HintsMap const &hints)
343{328{
344 QString hint;329 QString hint;
345330
346 GError* error = const_cast<unity::glib::Error&>(err);
347
348 if (!err || !g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
349 m_searchInProgress = false;
350 Q_EMIT searchInProgressChanged();
351 } else {
352 // no need to check the results hint, we're still searching
353 return;
354 }
355
356 if (!m_unityScope->results()->count()) {331 if (!m_unityScope->results()->count()) {
357 unity::glib::HintsMap::const_iterator it = hints.find("no-results-hint");332 unity::glib::HintsMap::const_iterator it = hints.find("no-results-hint");
358 if (it != hints.end()) {333 if (it != hints.end()) {
359334
=== modified file 'plugins/Unity/scope.h'
--- plugins/Unity/scope.h 2013-09-30 11:33:51 +0000
+++ plugins/Unity/scope.h 2013-10-05 08:36:17 +0000
@@ -28,7 +28,6 @@
28// libunity-core28// libunity-core
29#include <UnityCore/Scope.h>29#include <UnityCore/Scope.h>
30#include <UnityCore/Results.h>30#include <UnityCore/Results.h>
31#include <UnityCore/GLibWrapper.h>
3231
33#include "categories.h"32#include "categories.h"
34#include "filters.h"33#include "filters.h"
@@ -44,7 +43,6 @@
44 Q_PROPERTY(QString iconHint READ iconHint NOTIFY iconHintChanged)43 Q_PROPERTY(QString iconHint READ iconHint NOTIFY iconHintChanged)
45 Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)44 Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
46 Q_PROPERTY(QString searchHint READ searchHint NOTIFY searchHintChanged)45 Q_PROPERTY(QString searchHint READ searchHint NOTIFY searchHintChanged)
47 Q_PROPERTY(bool searchInProgress READ searchInProgress NOTIFY searchInProgressChanged)
48 Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)46 Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)
49 Q_PROPERTY(QString shortcut READ shortcut NOTIFY shortcutChanged)47 Q_PROPERTY(QString shortcut READ shortcut NOTIFY shortcutChanged)
50 Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)48 Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
@@ -67,7 +65,6 @@
67 bool visible() const;65 bool visible() const;
68 QString shortcut() const;66 QString shortcut() const;
69 bool connected() const;67 bool connected() const;
70 bool searchInProgress() const;
71 Categories* categories() const;68 Categories* categories() const;
72 Filters* filters() const;69 Filters* filters() const;
73 QString searchQuery() const;70 QString searchQuery() const;
@@ -98,11 +95,11 @@
98 void iconHintChanged(const std::string&);95 void iconHintChanged(const std::string&);
99 void descriptionChanged(const std::string&);96 void descriptionChanged(const std::string&);
100 void searchHintChanged(const std::string&);97 void searchHintChanged(const std::string&);
101 void searchInProgressChanged();
102 void visibleChanged(bool);98 void visibleChanged(bool);
103 void shortcutChanged(const std::string&);99 void shortcutChanged(const std::string&);
104 void connectedChanged(bool);100 void connectedChanged(bool);
105 void categoriesChanged();101 void categoriesChanged();
102 void searchFinished(const std::string&, unity::glib::HintsMap const&, unity::glib::Error const&);
106 void searchQueryChanged();103 void searchQueryChanged();
107 void noResultsHintChanged();104 void noResultsHintChanged();
108 void formFactorChanged();105 void formFactorChanged();
@@ -118,7 +115,7 @@
118115
119private Q_SLOTS:116private Q_SLOTS:
120 void synchronizeStates();117 void synchronizeStates();
121 void onSearchFinished(std::string const &, unity::glib::HintsMap const &, unity::glib::Error const&);118 void onSearchFinished(const std::string &, unity::glib::HintsMap const &);
122119
123private:120private:
124 unity::dash::LocalResult createLocalResult(const QVariant &uri, const QVariant &icon_hint,121 unity::dash::LocalResult createLocalResult(const QVariant &uri, const QVariant &icon_hint,
@@ -136,8 +133,6 @@
136 QString m_searchQuery;133 QString m_searchQuery;
137 QString m_noResultsHint;134 QString m_noResultsHint;
138 QString m_formFactor;135 QString m_formFactor;
139 bool m_searchInProgress;
140 unity::glib::Cancellable m_cancellable;
141 unity::glib::Cancellable m_previewCancellable;136 unity::glib::Cancellable m_previewCancellable;
142};137};
143138
144139
=== modified file 'tests/mocks/Unity/fake_scope.cpp'
--- tests/mocks/Unity/fake_scope.cpp 2013-09-30 15:10:55 +0000
+++ tests/mocks/Unity/fake_scope.cpp 2013-10-05 08:36:17 +0000
@@ -30,7 +30,6 @@
30Scope::Scope(QObject* parent)30Scope::Scope(QObject* parent)
31 : QObject(parent)31 : QObject(parent)
32 , m_visible(false)32 , m_visible(false)
33 , m_searching(false)
34 , m_categories(new Categories(this))33 , m_categories(new Categories(this))
35 , m_results(new DeeListModel(this))34 , m_results(new DeeListModel(this))
36{35{
@@ -45,7 +44,6 @@
45 , m_id(id)44 , m_id(id)
46 , m_name(name)45 , m_name(name)
47 , m_visible(visible)46 , m_visible(visible)
48 , m_searching(false)
49 , m_categories(new Categories(this))47 , m_categories(new Categories(this))
50 , m_results(new DeeListModel(this))48 , m_results(new DeeListModel(this))
51{49{
@@ -87,10 +85,6 @@
87 return true;85 return true;
88}86}
8987
90bool Scope::searchInProgress() const {
91 return m_searching;
92}
93
94Categories* Scope::categories() const {88Categories* Scope::categories() const {
95 return m_categories;89 return m_categories;
96}90}
@@ -128,13 +122,6 @@
128 }122 }
129}123}
130124
131void Scope::setSearchInProgress(const bool inProg) {
132 if (inProg != m_searching) {
133 m_searching = inProg;
134 Q_EMIT searchInProgressChanged();
135 }
136}
137
138void Scope::setNoResultsHint(const QString& str) {125void Scope::setNoResultsHint(const QString& str) {
139 if (str != m_noResultsHint) {126 if (str != m_noResultsHint) {
140 m_noResultsHint = str;127 m_noResultsHint = str;
141128
=== modified file 'tests/mocks/Unity/fake_scope.h'
--- tests/mocks/Unity/fake_scope.h 2013-09-30 15:10:55 +0000
+++ tests/mocks/Unity/fake_scope.h 2013-10-05 08:36:17 +0000
@@ -37,7 +37,6 @@
37 Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)37 Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
38 Q_PROPERTY(Categories* categories READ categories NOTIFY categoriesChanged)38 Q_PROPERTY(Categories* categories READ categories NOTIFY categoriesChanged)
3939
40 Q_PROPERTY(bool searchInProgress READ searchInProgress WRITE setSearchInProgress NOTIFY searchInProgressChanged)
41 Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)40 Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
42 Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)41 Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
43 Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)42 Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
@@ -55,7 +54,6 @@
55 bool visible() const;54 bool visible() const;
56 QString shortcut() const;55 QString shortcut() const;
57 bool connected() const;56 bool connected() const;
58 bool searchInProgress() const;
59 Categories* categories() const;57 Categories* categories() const;
60 QString searchQuery() const;58 QString searchQuery() const;
61 QString noResultsHint() const;59 QString noResultsHint() const;
@@ -66,7 +64,6 @@
66 void setSearchQuery(const QString& search_query);64 void setSearchQuery(const QString& search_query);
67 void setNoResultsHint(const QString& hint);65 void setNoResultsHint(const QString& hint);
68 void setFormFactor(const QString& form_factor);66 void setFormFactor(const QString& form_factor);
69 void setSearchInProgress(const bool inProg);
7067
71 Q_INVOKABLE void activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,68 Q_INVOKABLE void activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
72 const QVariant &result_type, const QVariant &mimetype, const QVariant &title,69 const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
@@ -81,11 +78,11 @@
81 void iconHintChanged(const QString&);78 void iconHintChanged(const QString&);
82 void descriptionChanged(const QString&);79 void descriptionChanged(const QString&);
83 void searchHintChanged(const QString&);80 void searchHintChanged(const QString&);
84 void searchInProgressChanged();
85 void visibleChanged(bool);81 void visibleChanged(bool);
86 void shortcutChanged(const QString&);82 void shortcutChanged(const QString&);
87 void connectedChanged(bool);83 void connectedChanged(bool);
88 void categoriesChanged();84 void categoriesChanged();
85 void searchFinished(const QString&);
89 void searchQueryChanged();86 void searchQueryChanged();
90 void noResultsHintChanged();87 void noResultsHintChanged();
91 void formFactorChanged();88 void formFactorChanged();
@@ -106,7 +103,6 @@
106 QString m_noResultsHint;103 QString m_noResultsHint;
107 QString m_formFactor;104 QString m_formFactor;
108 bool m_visible;105 bool m_visible;
109 bool m_searching;
110106
111 Categories* m_categories;107 Categories* m_categories;
112 DeeListModel* m_results;108 DeeListModel* m_results;
113109
=== modified file 'tests/qmltests/Components/tst_PageHeader.qml'
--- tests/qmltests/Components/tst_PageHeader.qml 2013-10-01 13:42:52 +0000
+++ tests/qmltests/Components/tst_PageHeader.qml 2013-10-05 08:36:17 +0000
@@ -19,17 +19,12 @@
19import ".."19import ".."
20import "../../../Components"20import "../../../Components"
21import Ubuntu.Components 0.121import Ubuntu.Components 0.1
22import Unity 0.1
23import Unity.Test 0.1 as UT22import Unity.Test 0.1 as UT
2423
25Item {24Item {
26 width: units.gu(110)25 width: units.gu(110)
27 height: units.gu(30)26 height: units.gu(30)
2827
29 Scope {
30 id: scopeMock
31 }
32
33 UT.UnityTestCase {28 UT.UnityTestCase {
34 name: "PageHeaderTest"29 name: "PageHeaderTest"
35 when: windowShown30 when: windowShown
@@ -137,27 +132,6 @@
137 compare(pageHeader.searchHistory.count, 3)132 compare(pageHeader.searchHistory.count, 3)
138 compare(pageHeader.searchHistory.get(0).query, "humppa4")133 compare(pageHeader.searchHistory.get(0).query, "humppa4")
139 }134 }
140
141 function test_search_indicator() {
142 var searchIndicator = findChild(pageHeader, "searchIndicator")
143 var primaryImage = findChild(pageHeader, "primaryImage")
144
145 pageHeader.triggerSearch()
146
147 scopeMock.searchInProgress = false
148 compare(searchIndicator.running, false, "Search indicator is running.")
149 tryCompare(primaryImage, "visible", true)
150
151 scopeMock.searchInProgress = true
152 compare(searchIndicator.running, true, "Search indicator isn't running.")
153 tryCompare(primaryImage, "visible", false)
154
155 pageHeader.resetSearch()
156 }
157
158 function cleanup() {
159 scopeMock.searchInProgress = false
160 }
161 }135 }
162136
163 Column {137 Column {
@@ -171,8 +145,6 @@
171 right: parent.right145 right: parent.right
172 }146 }
173147
174 scope: scopeMock
175
176 searchEntryEnabled: true148 searchEntryEnabled: true
177 text: "%^$%^%^&%^&%^$%GHR%"149 text: "%^$%^%^&%^&%^$%GHR%"
178 }150 }

Subscribers

People subscribed via source and target branches