Merge lp:~gerboland/unity-2d/hud-misc-fixes into lp:unity-2d

Proposed by Gerry Boland
Status: Merged
Approved by: Paweł Stołowski
Approved revision: 1012
Merged at revision: 1019
Proposed branch: lp:~gerboland/unity-2d/hud-misc-fixes
Merge into: lp:unity-2d
Diff against target: 90 lines (+25/-11)
3 files modified
libunity-2d-private/src/hud.cpp (+19/-7)
libunity-2d-private/src/hud.h (+2/-1)
shell/hud/Hud.qml (+4/-3)
To merge this branch: bzr merge lp:~gerboland/unity-2d/hud-misc-fixes
Reviewer Review Type Date Requested Status
Paweł Stołowski (community) Approve
Review via email: mp+99280@code.launchpad.net

Commit message

[hud] Improve monitoring of HUD service connection: reset data properly and disconnect only when connected

Description of the change

[hud] Improve monitoring of HUD service connection: reset data properly and disconnect only when connected

To post a comment you must log in.
Revision history for this message
Paweł Stołowski (stolowski) wrote :

Can you initialize m_hudQueryOpen in ctor just to be on the safe side, in case anyone adds any logic based on it in the future?
Also, I'd use at least UQ_WARNING to signal connection error, rather than UQ_DEBUG.

review: Needs Fixing
1011. By Gerry Boland

Initialise m_hudQueryOpen to be safe

1012. By Gerry Boland

HUD-service missing error should be warning

Revision history for this message
Paweł Stołowski (stolowski) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libunity-2d-private/src/hud.cpp'
2--- libunity-2d-private/src/hud.cpp 2012-03-06 14:40:24 +0000
3+++ libunity-2d-private/src/hud.cpp 2012-03-26 14:12:19 +0000
4@@ -35,7 +35,8 @@
5
6 Hud::Hud(QObject *parent) :
7 QAbstractListModel(parent),
8- m_connected(false)
9+ m_connected(false),
10+ m_hudQueryOpen(false)
11 {
12 QHash<int, QByteArray> names;
13 names[ResultIdRole] = "resultId";
14@@ -115,11 +116,16 @@
15
16 void Hud::setSearchQuery(const QString& searchQuery)
17 {
18- if (searchQuery != m_searchQuery) {
19- m_searchQuery = searchQuery;
20- m_unityHud->RequestQuery(m_searchQuery.toStdString());
21- beginResetModel();
22- Q_EMIT searchQueryChanged();
23+ if (!connected()) {
24+ UQ_WARNING << "No connection to HUD service available. Unable to search.";
25+ } else {
26+ if (searchQuery != m_searchQuery) {
27+ m_searchQuery = searchQuery;
28+ m_unityHud->RequestQuery(m_searchQuery.toStdString());
29+ m_hudQueryOpen = true;
30+ beginResetModel();
31+ Q_EMIT searchQueryChanged();
32+ }
33 }
34 }
35
36@@ -146,8 +152,14 @@
37
38 void Hud::endSearch()
39 {
40- m_unityHud->CloseQuery();
41+ if (m_hudQueryOpen && connected()) {
42+ m_unityHud->CloseQuery();
43+ m_hudQueryOpen = false;
44+ }
45 m_searchQuery.clear();
46+ beginResetModel();
47+ m_unityHudResults.clear();
48+ endResetModel();
49 }
50
51 void Hud::onResultsUpdated(const unity::hud::Hud::Queries results)
52
53=== modified file 'libunity-2d-private/src/hud.h'
54--- libunity-2d-private/src/hud.h 2012-03-06 14:40:24 +0000
55+++ libunity-2d-private/src/hud.h 2012-03-26 14:12:19 +0000
56@@ -78,7 +78,8 @@
57 void onResultsUpdated(const unity::hud::Hud::Queries);
58
59 private:
60- bool m_connected;
61+ bool m_connected; //Unity-Core's GlibDbusWrapper is connected to the service and is listening to the service signals
62+ bool m_hudQueryOpen; //status of the HUD query connection with HUD service
63 QString m_searchQuery;
64 unity::hud::Hud* m_unityHud;
65 unity::hud::Hud::Queries m_unityHudResults; //doubly-ended queue of 'Query's.
66
67=== modified file 'shell/hud/Hud.qml'
68--- shell/hud/Hud.qml 2012-03-14 14:29:05 +0000
69+++ shell/hud/Hud.qml 2012-03-26 14:12:19 +0000
70@@ -58,7 +58,7 @@
71 shellManager.hudShell.forceActivateWindow()
72 resultList.focus = true
73 } else {
74- hudModel.endSearch
75+ hudModel.endSearch()
76 resultList.currentIndex = -1
77 }
78 }
79@@ -194,8 +194,9 @@
80
81 opacity: 1
82
83- active: hud.active
84- placeHolderText: u2d.tr("Type your Command")
85+ active: hudModel.connected && hud.active
86+ placeHolderText: (hudModel.connected) ? u2d.tr("Type your Command")
87+ : u2d.tr("Error: HUD service not connected")
88
89 onSearchQueryChanged: {
90 hudModel.searchQuery = searchQuery

Subscribers

People subscribed via source and target branches