Merge lp:~mhr3/unity-lens-applications/fix-1066816 into lp:unity-lens-applications

Proposed by Michal Hruby
Status: Merged
Approved by: Paweł Stołowski
Approved revision: 311
Merged at revision: 313
Proposed branch: lp:~mhr3/unity-lens-applications/fix-1066816
Merge into: lp:unity-lens-applications
Diff against target: 59 lines (+19/-9)
1 file modified
src/daemon.vala (+19/-9)
To merge this branch: bzr merge lp:~mhr3/unity-lens-applications/fix-1066816
Reviewer Review Type Date Requested Status
Paweł Stołowski (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+129646@code.launchpad.net

Commit message

Initialize the ratings DB lazily.

Description of the change

Initialize the ratings DB lazily.

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

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/daemon.vala'
2--- src/daemon.vala 2012-10-15 10:06:36 +0000
3+++ src/daemon.vala 2012-10-15 10:31:01 +0000
4@@ -58,7 +58,8 @@
5 public Unity.Package.Searcher appsearcher;
6
7 /* Read the app ratings dumped by the Software Center */
8- private Unity.Ratings.Database? ratings;
9+ private bool ratings_db_initialized = false;
10+ private Unity.Ratings.Database? ratings = null;
11
12 private Unity.Lens lens;
13 private Unity.Scope scope;
14@@ -146,13 +147,6 @@
15 critical ("Failed to load Software Center index. 'Apps Available for Download' will not be listed");
16 }
17
18- try {
19- ratings = new Unity.Ratings.Database ();
20- } catch (FileError e) {
21- warning (e.message);
22- ratings = null;
23- }
24-
25 /* Image file extensions in order of popularity */
26 image_extensions = new Gee.ArrayList<string> ();
27 image_extensions.add ("png");
28@@ -241,6 +235,21 @@
29 lens.export ();
30 }
31
32+ private void init_ratings_db ()
33+ {
34+ if (ratings_db_initialized) return;
35+ try
36+ {
37+ ratings = new Unity.Ratings.Database ();
38+ }
39+ catch (FileError e)
40+ {
41+ warning ("%s", e.message);
42+ ratings = null;
43+ }
44+ ratings_db_initialized = true;
45+ }
46+
47 private async void dispatch_search (LensSearch lens_search,
48 SearchType search_type,
49 Cancellable cancellable)
50@@ -1186,7 +1195,8 @@
51 preview = new Unity.ApplicationPreview (details.name, subtitle, details.description, icon, screenshot);
52 preview.license = details.license;
53
54- if (ratings !=null)
55+ init_ratings_db ();
56+ if (ratings != null)
57 {
58 Unity.Ratings.Result result;
59 ratings.query (pkgname, out result);

Subscribers

People subscribed via source and target branches