Merge lp:~larryprice/libertine-scope/fix-desktop-scope-load into lp:libertine-scope

Proposed by Larry Price
Status: Merged
Approved by: Christopher Townsend
Approved revision: 53
Merged at revision: 60
Proposed branch: lp:~larryprice/libertine-scope/fix-desktop-scope-load
Merge into: lp:libertine-scope
Diff against target: 95 lines (+11/-10)
4 files modified
scope/apps/libertine.cpp (+1/-2)
scope/apps/libertine.h (+1/-1)
scope/apps/query.cpp (+7/-5)
scope/apps/query.h (+2/-2)
To merge this branch: bzr merge lp:~larryprice/libertine-scope/fix-desktop-scope-load
Reviewer Review Type Date Requested Status
Libertine CI Bot continuous-integration Approve
Christopher Townsend Approve
Review via email: mp+301383@code.launchpad.net

Commit message

Initialize libertine object in Query::run() to allow constructor to execute in time.

Description of the change

Initialize libertine object in Query::run() to allow constructor to execute in time.

This fixes the desktop unity8 libertine-scope requiring a refresh because the ctor was taking to long to finish. I changed Libertine::UPtr to be a shared_ptr so I could pass the object to other functions (the unique_ptr copy ctor is deleted for obvious reasons).

To post a comment you must log in.
Revision history for this message
Christopher Townsend (townsend) wrote :

I was never able to reproduce the bug, so I cannot test for that. However, the code looks good and it still works. +1

review: Approve
Revision history for this message
Libertine CI Bot (libertine-ci-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scope/apps/libertine.cpp'
2--- scope/apps/libertine.cpp 2016-07-12 18:26:07 +0000
3+++ scope/apps/libertine.cpp 2016-07-28 14:10:06 +0000
4@@ -91,6 +91,5 @@
5 Libertine::UPtr Libertine::
6 from_libertine_cli()
7 {
8- return Libertine::UPtr(new LibertineCli());
9+ return std::make_shared<LibertineCli>();
10 }
11-
12
13=== modified file 'scope/apps/libertine.h'
14--- scope/apps/libertine.h 2016-01-13 00:38:37 +0000
15+++ scope/apps/libertine.h 2016-07-28 14:10:06 +0000
16@@ -29,7 +29,7 @@
17 class Libertine
18 {
19 public:
20- using UPtr = std::unique_ptr<Libertine>;
21+ using UPtr = std::shared_ptr<Libertine>;
22 using ContainerList = std::vector<std::unique_ptr<Container>>;
23
24 /**
25
26=== modified file 'scope/apps/query.cpp'
27--- scope/apps/query.cpp 2016-07-19 13:57:43 +0000
28+++ scope/apps/query.cpp 2016-07-28 14:10:06 +0000
29@@ -121,7 +121,7 @@
30 std::shared_ptr<HiddenApps> hidden,
31 std::shared_ptr<Blacklist> blacklist)
32 : usc::SearchQueryBase(query, metadata)
33- , libertine_(libertine_factory())
34+ , libertine_factory_(libertine_factory)
35 , hidden_(hidden)
36 , blacklist_(blacklist)
37 {
38@@ -135,14 +135,14 @@
39
40
41 QStringList Query::
42-make_filters(usc::SearchReplyProxy const& reply) const
43+make_filters(usc::SearchReplyProxy const& reply, Libertine::UPtr libertine) const
44 {
45 auto filter_state = query().filter_state();
46 QStringList excludes_by_filter;
47 std::list<usc::FilterBase::SCPtr> app_filters;
48
49 //make exclude scope filter for apps
50- for (auto const& container: libertine_->get_container_list())
51+ for (auto const& container: libertine->get_container_list())
52 {
53 usc::OptionSelectorFilter::SPtr filter{usc::OptionSelectorFilter::create(container->id(),
54 EXCLUDED_APPS_FILTER_TITLE + container->name(),
55@@ -208,18 +208,20 @@
56 register_departments(reply);
57 }
58
59+ auto libertine = libertine_factory_();
60+
61 // only provide filters in root department
62 QStringList excludes_by_filter;
63 if (query().department_id().empty())
64 {
65- excludes_by_filter = make_filters(reply);
66+ excludes_by_filter = make_filters(reply, libertine);
67 }
68
69 QRegExp search_query(QString::fromStdString(query().query_string()), Qt::CaseInsensitive);
70 bool has_no_apps = true,
71 all_filtered = true;
72
73- for (auto const& container: libertine_->get_container_list())
74+ for (auto const& container: libertine->get_container_list())
75 {
76 auto category = reply->register_category(container->id(),
77 container->name(),
78
79=== modified file 'scope/apps/query.h'
80--- scope/apps/query.h 2016-07-12 18:26:07 +0000
81+++ scope/apps/query.h 2016-07-28 14:10:06 +0000
82@@ -50,11 +50,11 @@
83
84 private:
85 QStringList get_hidden_department() const;
86- QStringList make_filters(unity::scopes::SearchReplyProxy const& reply) const;
87+ QStringList make_filters(unity::scopes::SearchReplyProxy const& reply, Libertine::UPtr libertine) const;
88 void show_hint(unity::scopes::SearchReplyProxy const& reply, std::string const& reason) const;
89 void parse_blacklist(const std::string& data_dir);
90
91- Libertine::UPtr libertine_;
92+ Libertine::Factory libertine_factory_;
93 std::shared_ptr<HiddenApps> hidden_;
94 std::shared_ptr<Blacklist> blacklist_;
95 };

Subscribers

People subscribed via source and target branches