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
1=== modified file 'Components/PageHeader.qml'
2--- Components/PageHeader.qml 2013-10-02 16:11:27 +0000
3+++ Components/PageHeader.qml 2013-10-05 08:36:17 +0000
4@@ -18,7 +18,6 @@
5 import Ubuntu.Components 0.1
6 import Ubuntu.Components.Popups 0.1
7 import Ubuntu.Components.ListItems 0.1 as ListItem
8-import Unity 0.1
9
10 Item {
11 /*!
12@@ -31,7 +30,6 @@
13 property bool searchEntryEnabled: false
14 property alias searchQuery: searchField.text
15 property ListModel searchHistory: SearchHistoryModel {}
16- property Scope scope
17
18 height: units.gu(8.5)
19 implicitHeight: units.gu(8.5)
20@@ -150,7 +148,7 @@
21 hasClearButton: false
22
23 primaryItem: AbstractButton {
24- enabled: searchField.text != "" && !searchIndicator.running
25+ enabled: searchField.text != ""
26 onClicked: {
27 if (searchField.text != "") {
28 searchHistory.addQuery(searchField.text)
29@@ -160,22 +158,8 @@
30 height: parent.height
31 width: height
32
33- ActivityIndicator {
34- id: searchIndicator
35- objectName: "searchIndicator"
36-
37- anchors {
38- verticalCenter: parent.verticalCenter
39- left: parent.left
40- leftMargin: units.gu(0.5)
41- }
42-
43- running: opacity > 0
44- }
45-
46 Image {
47 id: primaryImage
48- objectName: "primaryImage"
49 anchors {
50 verticalCenter: parent.verticalCenter
51 left: parent.left
52@@ -183,7 +167,6 @@
53 }
54 width: units.gu(3)
55 height: units.gu(3)
56- visible: opacity > 0
57 }
58
59 Item {
60@@ -202,32 +185,6 @@
61 onActiveFocusChanged: {
62 if (!activeFocus) searchContainer.closePopover()
63 }
64-
65- states: [
66- State {
67- name: "searching"
68- when: scope.searchInProgress && searchField.text !== ""
69- PropertyChanges { target: searchIndicator; running: true; opacity: 1 }
70- PropertyChanges { target: primaryImage; opacity: 0 }
71- },
72- State {
73- name: "idle"
74- when: !scope.searchInProgress || searchField.text === ""
75- PropertyChanges { target: searchIndicator; opacity: 0 }
76- PropertyChanges { target: primaryImage; opacity: 1 }
77- }
78- ]
79-
80- transitions: [
81- Transition {
82- to: "searching"
83- reversible: true
84- SequentialAnimation {
85- NumberAnimation { target: primaryImage; property: "opacity"; duration: UbuntuAnimation.FastDuration; easing.type: Easing.Linear }
86- NumberAnimation { target: searchIndicator; property: "opacity"; duration: UbuntuAnimation.FastDuration; easing.type: Easing.Linear }
87- }
88- }
89- ]
90 }
91
92 states: [
93
94=== modified file 'Dash/GenericScopeView.qml'
95--- Dash/GenericScopeView.qml 2013-10-04 15:44:55 +0000
96+++ Dash/GenericScopeView.qml 2013-10-05 08:36:17 +0000
97@@ -190,7 +190,6 @@
98 width: categoryView.width
99 text: scopeView.scope.name
100 searchEntryEnabled: true
101- scope: scopeView.scope
102 }
103 }
104
105
106=== modified file 'plugins/Unity/scope.cpp'
107--- plugins/Unity/scope.cpp 2013-09-30 11:33:51 +0000
108+++ plugins/Unity/scope.cpp 2013-10-05 08:36:17 +0000
109@@ -33,14 +33,12 @@
110 #include <QQmlEngine>
111
112 #include <UnityCore/Variant.h>
113-#include <UnityCore/GLibWrapper.h>
114
115 #include <libintl.h>
116 #include <glib.h>
117
118 Scope::Scope(QObject *parent) : QObject(parent)
119 , m_formFactor("phone")
120- , m_searchInProgress(false)
121 {
122 m_categories.reset(new Categories(this));
123 }
124@@ -70,11 +68,6 @@
125 return QString::fromStdString(m_unityScope->search_hint());
126 }
127
128-bool Scope::searchInProgress() const
129-{
130- return m_searchInProgress;
131-}
132-
133 bool Scope::visible() const
134 {
135 return m_unityScope->visible();
136@@ -122,15 +115,10 @@
137 string ("") and m_searchQuery is the null string,
138 search_query != m_searchQuery is still true.
139 */
140- using namespace std::placeholders;
141-
142 if (m_searchQuery.isNull() || search_query != m_searchQuery) {
143 m_searchQuery = search_query;
144- m_cancellable.Renew();
145- m_searchInProgress = true;
146- m_unityScope->Search(search_query.toStdString(), std::bind(&Scope::onSearchFinished, this, _1, _2, _3), m_cancellable);
147+ m_unityScope->Search(search_query.toStdString(), sigc::mem_fun(this, &Scope::searchFinished));
148 Q_EMIT searchQueryChanged();
149- Q_EMIT searchInProgressChanged();
150 }
151 }
152
153@@ -306,6 +294,8 @@
154 m_unityScope->visible.changed.connect(sigc::mem_fun(this, &Scope::visibleChanged));
155 m_unityScope->shortcut.changed.connect(sigc::mem_fun(this, &Scope::shortcutChanged));
156 m_unityScope->connected.changed.connect(sigc::mem_fun(this, &Scope::connectedChanged));
157+ /* Signals forwarding */
158+ connect(this, SIGNAL(searchFinished(const std::string &, unity::glib::HintsMap const &, unity::glib::Error const &)), SLOT(onSearchFinished(const std::string &, unity::glib::HintsMap const &)));
159
160 /* FIXME: signal should be forwarded instead of calling the handler directly */
161 m_unityScope->activated.connect(sigc::mem_fun(this, &Scope::onActivated));
162@@ -326,33 +316,18 @@
163
164 void Scope::synchronizeStates()
165 {
166- using namespace std::placeholders;
167-
168 if (connected()) {
169 /* Forward local states to m_unityScope */
170 if (!m_searchQuery.isNull()) {
171- m_cancellable.Renew();
172- m_searchInProgress = true;
173- m_unityScope->Search(m_searchQuery.toStdString(), std::bind(&Scope::onSearchFinished, this, _1, _2, _3), m_cancellable);
174- Q_EMIT searchInProgressChanged();
175+ m_unityScope->Search(m_searchQuery.toStdString());
176 }
177 }
178 }
179
180-void Scope::onSearchFinished(std::string const& /* query */, unity::glib::HintsMap const& hints, unity::glib::Error const& err)
181+void Scope::onSearchFinished(const std::string& /* query */, unity::glib::HintsMap const &hints)
182 {
183 QString hint;
184
185- GError* error = const_cast<unity::glib::Error&>(err);
186-
187- if (!err || !g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
188- m_searchInProgress = false;
189- Q_EMIT searchInProgressChanged();
190- } else {
191- // no need to check the results hint, we're still searching
192- return;
193- }
194-
195 if (!m_unityScope->results()->count()) {
196 unity::glib::HintsMap::const_iterator it = hints.find("no-results-hint");
197 if (it != hints.end()) {
198
199=== modified file 'plugins/Unity/scope.h'
200--- plugins/Unity/scope.h 2013-09-30 11:33:51 +0000
201+++ plugins/Unity/scope.h 2013-10-05 08:36:17 +0000
202@@ -28,7 +28,6 @@
203 // libunity-core
204 #include <UnityCore/Scope.h>
205 #include <UnityCore/Results.h>
206-#include <UnityCore/GLibWrapper.h>
207
208 #include "categories.h"
209 #include "filters.h"
210@@ -44,7 +43,6 @@
211 Q_PROPERTY(QString iconHint READ iconHint NOTIFY iconHintChanged)
212 Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
213 Q_PROPERTY(QString searchHint READ searchHint NOTIFY searchHintChanged)
214- Q_PROPERTY(bool searchInProgress READ searchInProgress NOTIFY searchInProgressChanged)
215 Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)
216 Q_PROPERTY(QString shortcut READ shortcut NOTIFY shortcutChanged)
217 Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
218@@ -67,7 +65,6 @@
219 bool visible() const;
220 QString shortcut() const;
221 bool connected() const;
222- bool searchInProgress() const;
223 Categories* categories() const;
224 Filters* filters() const;
225 QString searchQuery() const;
226@@ -98,11 +95,11 @@
227 void iconHintChanged(const std::string&);
228 void descriptionChanged(const std::string&);
229 void searchHintChanged(const std::string&);
230- void searchInProgressChanged();
231 void visibleChanged(bool);
232 void shortcutChanged(const std::string&);
233 void connectedChanged(bool);
234 void categoriesChanged();
235+ void searchFinished(const std::string&, unity::glib::HintsMap const&, unity::glib::Error const&);
236 void searchQueryChanged();
237 void noResultsHintChanged();
238 void formFactorChanged();
239@@ -118,7 +115,7 @@
240
241 private Q_SLOTS:
242 void synchronizeStates();
243- void onSearchFinished(std::string const &, unity::glib::HintsMap const &, unity::glib::Error const&);
244+ void onSearchFinished(const std::string &, unity::glib::HintsMap const &);
245
246 private:
247 unity::dash::LocalResult createLocalResult(const QVariant &uri, const QVariant &icon_hint,
248@@ -136,8 +133,6 @@
249 QString m_searchQuery;
250 QString m_noResultsHint;
251 QString m_formFactor;
252- bool m_searchInProgress;
253- unity::glib::Cancellable m_cancellable;
254 unity::glib::Cancellable m_previewCancellable;
255 };
256
257
258=== modified file 'tests/mocks/Unity/fake_scope.cpp'
259--- tests/mocks/Unity/fake_scope.cpp 2013-09-30 15:10:55 +0000
260+++ tests/mocks/Unity/fake_scope.cpp 2013-10-05 08:36:17 +0000
261@@ -30,7 +30,6 @@
262 Scope::Scope(QObject* parent)
263 : QObject(parent)
264 , m_visible(false)
265- , m_searching(false)
266 , m_categories(new Categories(this))
267 , m_results(new DeeListModel(this))
268 {
269@@ -45,7 +44,6 @@
270 , m_id(id)
271 , m_name(name)
272 , m_visible(visible)
273- , m_searching(false)
274 , m_categories(new Categories(this))
275 , m_results(new DeeListModel(this))
276 {
277@@ -87,10 +85,6 @@
278 return true;
279 }
280
281-bool Scope::searchInProgress() const {
282- return m_searching;
283-}
284-
285 Categories* Scope::categories() const {
286 return m_categories;
287 }
288@@ -128,13 +122,6 @@
289 }
290 }
291
292-void Scope::setSearchInProgress(const bool inProg) {
293- if (inProg != m_searching) {
294- m_searching = inProg;
295- Q_EMIT searchInProgressChanged();
296- }
297-}
298-
299 void Scope::setNoResultsHint(const QString& str) {
300 if (str != m_noResultsHint) {
301 m_noResultsHint = str;
302
303=== modified file 'tests/mocks/Unity/fake_scope.h'
304--- tests/mocks/Unity/fake_scope.h 2013-09-30 15:10:55 +0000
305+++ tests/mocks/Unity/fake_scope.h 2013-10-05 08:36:17 +0000
306@@ -37,7 +37,6 @@
307 Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
308 Q_PROPERTY(Categories* categories READ categories NOTIFY categoriesChanged)
309
310- Q_PROPERTY(bool searchInProgress READ searchInProgress WRITE setSearchInProgress NOTIFY searchInProgressChanged)
311 Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
312 Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
313 Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
314@@ -55,7 +54,6 @@
315 bool visible() const;
316 QString shortcut() const;
317 bool connected() const;
318- bool searchInProgress() const;
319 Categories* categories() const;
320 QString searchQuery() const;
321 QString noResultsHint() const;
322@@ -66,7 +64,6 @@
323 void setSearchQuery(const QString& search_query);
324 void setNoResultsHint(const QString& hint);
325 void setFormFactor(const QString& form_factor);
326- void setSearchInProgress(const bool inProg);
327
328 Q_INVOKABLE void activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
329 const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
330@@ -81,11 +78,11 @@
331 void iconHintChanged(const QString&);
332 void descriptionChanged(const QString&);
333 void searchHintChanged(const QString&);
334- void searchInProgressChanged();
335 void visibleChanged(bool);
336 void shortcutChanged(const QString&);
337 void connectedChanged(bool);
338 void categoriesChanged();
339+ void searchFinished(const QString&);
340 void searchQueryChanged();
341 void noResultsHintChanged();
342 void formFactorChanged();
343@@ -106,7 +103,6 @@
344 QString m_noResultsHint;
345 QString m_formFactor;
346 bool m_visible;
347- bool m_searching;
348
349 Categories* m_categories;
350 DeeListModel* m_results;
351
352=== modified file 'tests/qmltests/Components/tst_PageHeader.qml'
353--- tests/qmltests/Components/tst_PageHeader.qml 2013-10-01 13:42:52 +0000
354+++ tests/qmltests/Components/tst_PageHeader.qml 2013-10-05 08:36:17 +0000
355@@ -19,17 +19,12 @@
356 import ".."
357 import "../../../Components"
358 import Ubuntu.Components 0.1
359-import Unity 0.1
360 import Unity.Test 0.1 as UT
361
362 Item {
363 width: units.gu(110)
364 height: units.gu(30)
365
366- Scope {
367- id: scopeMock
368- }
369-
370 UT.UnityTestCase {
371 name: "PageHeaderTest"
372 when: windowShown
373@@ -137,27 +132,6 @@
374 compare(pageHeader.searchHistory.count, 3)
375 compare(pageHeader.searchHistory.get(0).query, "humppa4")
376 }
377-
378- function test_search_indicator() {
379- var searchIndicator = findChild(pageHeader, "searchIndicator")
380- var primaryImage = findChild(pageHeader, "primaryImage")
381-
382- pageHeader.triggerSearch()
383-
384- scopeMock.searchInProgress = false
385- compare(searchIndicator.running, false, "Search indicator is running.")
386- tryCompare(primaryImage, "visible", true)
387-
388- scopeMock.searchInProgress = true
389- compare(searchIndicator.running, true, "Search indicator isn't running.")
390- tryCompare(primaryImage, "visible", false)
391-
392- pageHeader.resetSearch()
393- }
394-
395- function cleanup() {
396- scopeMock.searchInProgress = false
397- }
398 }
399
400 Column {
401@@ -171,8 +145,6 @@
402 right: parent.right
403 }
404
405- scope: scopeMock
406-
407 searchEntryEnabled: true
408 text: "%^$%^%^&%^&%^$%GHR%"
409 }

Subscribers

People subscribed via source and target branches