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
=== modified file 'scope/apps/libertine.cpp'
--- scope/apps/libertine.cpp 2016-07-12 18:26:07 +0000
+++ scope/apps/libertine.cpp 2016-07-28 14:10:06 +0000
@@ -91,6 +91,5 @@
91Libertine::UPtr Libertine::91Libertine::UPtr Libertine::
92from_libertine_cli()92from_libertine_cli()
93{93{
94 return Libertine::UPtr(new LibertineCli());94 return std::make_shared<LibertineCli>();
95}95}
96
9796
=== modified file 'scope/apps/libertine.h'
--- scope/apps/libertine.h 2016-01-13 00:38:37 +0000
+++ scope/apps/libertine.h 2016-07-28 14:10:06 +0000
@@ -29,7 +29,7 @@
29class Libertine29class Libertine
30{30{
31public:31public:
32 using UPtr = std::unique_ptr<Libertine>;32 using UPtr = std::shared_ptr<Libertine>;
33 using ContainerList = std::vector<std::unique_ptr<Container>>;33 using ContainerList = std::vector<std::unique_ptr<Container>>;
3434
35 /**35 /**
3636
=== modified file 'scope/apps/query.cpp'
--- scope/apps/query.cpp 2016-07-19 13:57:43 +0000
+++ scope/apps/query.cpp 2016-07-28 14:10:06 +0000
@@ -121,7 +121,7 @@
121 std::shared_ptr<HiddenApps> hidden,121 std::shared_ptr<HiddenApps> hidden,
122 std::shared_ptr<Blacklist> blacklist)122 std::shared_ptr<Blacklist> blacklist)
123 : usc::SearchQueryBase(query, metadata)123 : usc::SearchQueryBase(query, metadata)
124 , libertine_(libertine_factory())124 , libertine_factory_(libertine_factory)
125 , hidden_(hidden)125 , hidden_(hidden)
126 , blacklist_(blacklist)126 , blacklist_(blacklist)
127{127{
@@ -135,14 +135,14 @@
135135
136136
137QStringList Query::137QStringList Query::
138make_filters(usc::SearchReplyProxy const& reply) const138make_filters(usc::SearchReplyProxy const& reply, Libertine::UPtr libertine) const
139{139{
140 auto filter_state = query().filter_state();140 auto filter_state = query().filter_state();
141 QStringList excludes_by_filter;141 QStringList excludes_by_filter;
142 std::list<usc::FilterBase::SCPtr> app_filters;142 std::list<usc::FilterBase::SCPtr> app_filters;
143143
144 //make exclude scope filter for apps144 //make exclude scope filter for apps
145 for (auto const& container: libertine_->get_container_list())145 for (auto const& container: libertine->get_container_list())
146 {146 {
147 usc::OptionSelectorFilter::SPtr filter{usc::OptionSelectorFilter::create(container->id(),147 usc::OptionSelectorFilter::SPtr filter{usc::OptionSelectorFilter::create(container->id(),
148 EXCLUDED_APPS_FILTER_TITLE + container->name(),148 EXCLUDED_APPS_FILTER_TITLE + container->name(),
@@ -208,18 +208,20 @@
208 register_departments(reply);208 register_departments(reply);
209 }209 }
210210
211 auto libertine = libertine_factory_();
212
211 // only provide filters in root department213 // only provide filters in root department
212 QStringList excludes_by_filter;214 QStringList excludes_by_filter;
213 if (query().department_id().empty())215 if (query().department_id().empty())
214 {216 {
215 excludes_by_filter = make_filters(reply);217 excludes_by_filter = make_filters(reply, libertine);
216 }218 }
217219
218 QRegExp search_query(QString::fromStdString(query().query_string()), Qt::CaseInsensitive);220 QRegExp search_query(QString::fromStdString(query().query_string()), Qt::CaseInsensitive);
219 bool has_no_apps = true,221 bool has_no_apps = true,
220 all_filtered = true;222 all_filtered = true;
221223
222 for (auto const& container: libertine_->get_container_list())224 for (auto const& container: libertine->get_container_list())
223 {225 {
224 auto category = reply->register_category(container->id(),226 auto category = reply->register_category(container->id(),
225 container->name(),227 container->name(),
226228
=== modified file 'scope/apps/query.h'
--- scope/apps/query.h 2016-07-12 18:26:07 +0000
+++ scope/apps/query.h 2016-07-28 14:10:06 +0000
@@ -50,11 +50,11 @@
5050
51private:51private:
52 QStringList get_hidden_department() const;52 QStringList get_hidden_department() const;
53 QStringList make_filters(unity::scopes::SearchReplyProxy const& reply) const;53 QStringList make_filters(unity::scopes::SearchReplyProxy const& reply, Libertine::UPtr libertine) const;
54 void show_hint(unity::scopes::SearchReplyProxy const& reply, std::string const& reason) const;54 void show_hint(unity::scopes::SearchReplyProxy const& reply, std::string const& reason) const;
55 void parse_blacklist(const std::string& data_dir);55 void parse_blacklist(const std::string& data_dir);
5656
57 Libertine::UPtr libertine_;57 Libertine::Factory libertine_factory_;
58 std::shared_ptr<HiddenApps> hidden_;58 std::shared_ptr<HiddenApps> hidden_;
59 std::shared_ptr<Blacklist> blacklist_;59 std::shared_ptr<Blacklist> blacklist_;
60};60};

Subscribers

People subscribed via source and target branches