Merge lp:~alecu/unity-scope-click/force-finished into lp:unity-scope-click/devel

Proposed by Alejandro J. Cura
Status: Merged
Approved by: dobey
Approved revision: 232
Merged at revision: 232
Proposed branch: lp:~alecu/unity-scope-click/force-finished
Merge into: lp:unity-scope-click/devel
Diff against target: 84 lines (+30/-1)
3 files modified
scope/click/query.cpp (+7/-0)
scope/click/query.h (+2/-1)
scope/tests/test_query.cpp (+21/-0)
To merge this branch: bzr merge lp:~alecu/unity-scope-click/force-finished
Reviewer Review Type Date Requested Status
dobey (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+217993@code.launchpad.net

Commit message

Force calling .finished() when the last search result is pushed

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alejandro J. Cura (alecu) wrote :

Just tried the .deb created by jenkins above on image #7 on mako, and the branch fixes the issue that dobey found.

Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
Michal Hruby (mhr3) wrote :

I don't like this, it's just hiding that you're actually leaking the SearchReply + the instance that contains it.

Revision history for this message
Alejandro J. Cura (alecu) wrote :

I agree with mhr3's comment, but I intended this as a workaround so we can unblock the landing.
If it's ok with you, we can open a new bug to trace the leak.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scope/click/query.cpp'
2--- scope/click/query.cpp 2014-04-16 21:49:04 +0000
3+++ scope/click/query.cpp 2014-05-02 00:03:08 +0000
4@@ -160,6 +160,11 @@
5 return searchReply->push(res);
6 }
7
8+void click::Query::finished(const scopes::SearchReplyProxy &searchReply)
9+{
10+ searchReply->finished();
11+}
12+
13 scopes::Category::SCPtr click::Query::register_category(const scopes::SearchReplyProxy &searchReply,
14 const std::string &id,
15 const std::string &title,
16@@ -215,6 +220,8 @@
17 qDebug() << "no reason to catch";
18 }
19 }
20+ qDebug() << "search completed";
21+ this->finished(searchReply);
22 });
23
24 });
25
26=== modified file 'scope/click/query.h'
27--- scope/click/query.h 2014-04-24 16:03:18 +0000
28+++ scope/click/query.h 2014-05-02 00:03:08 +0000
29@@ -70,7 +70,7 @@
30 };
31
32 Query(std::string const& query, click::Index& index, scopes::SearchMetadata const& metadata);
33- ~Query();
34+ virtual ~Query();
35
36 virtual void cancelled() override;
37
38@@ -79,6 +79,7 @@
39 protected:
40 virtual void add_available_apps(const scopes::SearchReplyProxy &searchReply, const std::set<std::string> &locallyInstalledApps, const std::string &category);
41 virtual bool push_result(const scopes::SearchReplyProxy &searchReply, scopes::CategorisedResult const& res);
42+ virtual void finished(const scopes::SearchReplyProxy &searchReply);
43 virtual void push_local_results(scopes::SearchReplyProxy const &replyProxy,
44 std::vector<click::Application> const &apps,
45 std::string& categoryTemplate);
46
47=== modified file 'scope/tests/test_query.cpp'
48--- scope/tests/test_query.cpp 2014-04-16 21:49:04 +0000
49+++ scope/tests/test_query.cpp 2014-05-02 00:03:08 +0000
50@@ -104,6 +104,7 @@
51 add_available_apps(searchReply, locallyInstalledApps, categoryTemplate);
52 }
53 MOCK_METHOD2(push_result, bool(scopes::SearchReplyProxy const&, scopes::CategorisedResult const&));
54+ MOCK_METHOD1(finished, void(scopes::SearchReplyProxy const&));
55 MOCK_METHOD5(register_category, scopes::Category::SCPtr(const scopes::SearchReplyProxy &searchReply,
56 const std::string &id,
57 const std::string &title,
58@@ -175,6 +176,26 @@
59 q.wrap_add_available_apps(reply, no_installed_packages, FAKE_CATEGORY_TEMPLATE);
60 }
61
62+TEST(QueryTest, testAddAvailableAppsCallsFinished)
63+{
64+ click::PackageList packages {
65+ {"name", "title", 0.0, "", ""}
66+ };
67+ MockIndex mock_index(packages);
68+ scopes::SearchMetadata metadata("en_EN", "phone");
69+ std::set<std::string> no_installed_packages;
70+ MockQuery q(FAKE_QUERY, mock_index, metadata);
71+ EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _));
72+
73+ scopes::CategoryRenderer renderer("{}");
74+ auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);
75+ EXPECT_CALL(q, register_category(_, _, _, _, _)).WillOnce(Return(ptrCat));
76+
77+ scopes::SearchReplyProxy reply;
78+ EXPECT_CALL(q, finished(_));
79+ q.wrap_add_available_apps(reply, no_installed_packages, FAKE_CATEGORY_TEMPLATE);
80+}
81+
82 TEST(QueryTest, testAddAvailableAppsWithNullCategory)
83 {
84 click::PackageList packages {

Subscribers

People subscribed via source and target branches

to all changes: