Merge lp:~michael.rawson/light-software-center/build-fixes into lp:light-software-center

Proposed by Michael Rawson
Status: Merged
Merge reported by: Stephen Smally
Merged at revision: not available
Proposed branch: lp:~michael.rawson/light-software-center/build-fixes
Merge into: lp:light-software-center
Diff against target: 139 lines (+55/-14)
2 files modified
db-build/dbbuild.vala (+48/-11)
db-build/libmenu.vala (+7/-3)
To merge this branch: bzr merge lp:~michael.rawson/light-software-center/build-fixes
Reviewer Review Type Date Requested Status
Stephen Smally Pending
Review via email: mp+114602@code.launchpad.net

Description of the change

This fixes 11 of the 12 dbbuild build warnings. The 12th requires a blank function to fix, so I left that.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'db-build/dbbuild.vala'
2--- db-build/dbbuild.vala 2012-07-11 18:59:07 +0000
3+++ db-build/dbbuild.vala 2012-07-12 10:23:12 +0000
4@@ -52,11 +52,16 @@
5 foreach (string dir in app_pkg.directories) {
6 GLib.debug ("Inserting %s in %s\n", app_pkg.id, dir);
7 Type t_string = typeof(string);
8- trs.execute_insert("INSERT INTO '%s' VALUES (:id, :name, :description, :icon);".printf (dir),
9+ try {
10+ trs.execute_insert("INSERT INTO '%s' VALUES (:id, :name, :description, :icon);".printf (dir),
11 ":id", t_string, app_pkg.id,
12 ":name", t_string, app_pkg.name,
13 ":description", t_string, app_pkg.summary,
14 ":icon", t_string, app_pkg.icon);
15+ }
16+ catch(GLib.Error e) {
17+ GLib.error("Failed to insert values into database. %s", e.message);
18+ }
19 }
20 }
21
22@@ -112,28 +117,47 @@
23 packages = new Gee.HashMap<string, AppInstallPackage> ();
24
25 desktop_dir = "/usr/share/app-install/desktop/";
26- root = Dir.open (desktop_dir, 0);
27+ try {
28+ root = Dir.open (desktop_dir, 0);
29+ }
30+ catch(GLib.Error e) {
31+ GLib.error("Failed to open desktop directory: %s: %s", desktop_dir, e.message);
32+ }
33 keys = new KeyFile ();
34
35 MenuParser parser = new MenuParser (menu_file);
36
37- trans = db.begin_transaction ();
38+ try {
39+ trans = db.begin_transaction ();
40+ }
41+ catch(GLib.Error e) {
42+ GLib.error("Failed to start database transaction: %s", e.message);
43+ }
44
45 stdout.printf ("Collecting app-install data...\n");
46-
47- trans.execute ("CREATE TABLE 'DIRECTORIES' (id, name, summary, icon, directory);");
48+ try {
49+ trans.execute ("CREATE TABLE 'DIRECTORIES' (id, name, summary, icon, directory);");
50+ }
51+ catch(GLib.Error e) {
52+ GLib.error("Failed to create table DIRECTORIES: %s", e.message);
53+ }
54
55 menu_dirs = parser.parse();
56
57 foreach (MenuDir item in menu_dirs) {
58 if (item.level == 1) { // We just want the Applications childs
59- trans.execute ("CREATE TABLE '%s' (id, name, summary, icon);".printf (item.id));
60- trans.execute ("INSERT INTO 'DIRECTORIES' VALUES (:id, :name, :summary, :icon, :directory);",
61+ try {
62+ trans.execute ("CREATE TABLE '%s' (id, name, summary, icon);".printf (item.id));
63+ trans.execute ("INSERT INTO 'DIRECTORIES' VALUES (:id, :name, :summary, :icon, :directory);",
64 ":id", typeof (string), item.id,
65 ":name", typeof (string), item.name,
66 ":summary", typeof (string), item.summary,
67 ":icon", typeof (string), item.icon,
68 ":directory", typeof (string), item.directory);
69+ }
70+ catch(GLib.Error e) {
71+ GLib.error("Failed to create table %s: %s", item.id, e.message);
72+ }
73 }
74 }
75
76@@ -176,8 +200,11 @@
77 OptionContext context = new OptionContext ("Build a Lsc (Light Software Center) Database");
78 context.add_main_entries (entries, null);
79
80- if (! context.parse (ref args)) {
81- GLib.error ("Options parsing error!\n");
82+ try {
83+ context.parse (ref args);
84+ }
85+ catch(GLib.Error e) {
86+ GLib.error("Failed to parse options: %s", e.message);
87 }
88
89 if (db_filename == null) {
90@@ -192,12 +219,22 @@
91 }
92
93 FileUtils.remove ("/var/cache/lsc-vala.db");
94- db = new Database ("/var/cache/lsc-vala.db");
95+ try {
96+ db = new Database ("/var/cache/lsc-vala.db");
97+ }
98+ catch(GLib.Error e) {
99+ GLib.error("Failed to create database: %s", e.message);
100+ }
101
102 dbbuilder = new DbBuilder (db, menu_filename);
103
104 client = new Client ();
105- trans = db.begin_transaction ();
106+ try {
107+ trans = db.begin_transaction ();
108+ }
109+ catch(GLib.Error e) {
110+ GLib.error("Failed to begin transaction: %s", e.message);
111+ }
112
113 stdout.printf ("Querying PackageKit...\n");
114
115
116=== modified file 'db-build/libmenu.vala'
117--- db-build/libmenu.vala 2012-07-04 17:01:15 +0000
118+++ db-build/libmenu.vala 2012-07-12 10:23:12 +0000
119@@ -1,4 +1,3 @@
120-
121 namespace Menu {
122 class MenuDir : Object {
123 public string id { get; set; }
124@@ -55,8 +54,13 @@
125
126 public MenuDir[] parse () {
127 string file;
128- FileUtils.get_contents (menu_file, out file, null);
129- context.parse (file, file.length);
130+ try {
131+ FileUtils.get_contents (menu_file, out file, null);
132+ context.parse (file, file.length);
133+ }
134+ catch(GLib.Error e) {
135+ GLib.error("Failed to parse file. %s\n", e.message);
136+ }
137
138 return dirlist;
139 }

Subscribers

People subscribed via source and target branches

to all changes: