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
=== modified file 'db-build/dbbuild.vala'
--- db-build/dbbuild.vala 2012-07-11 18:59:07 +0000
+++ db-build/dbbuild.vala 2012-07-12 10:23:12 +0000
@@ -52,11 +52,16 @@
52 foreach (string dir in app_pkg.directories) {52 foreach (string dir in app_pkg.directories) {
53 GLib.debug ("Inserting %s in %s\n", app_pkg.id, dir);53 GLib.debug ("Inserting %s in %s\n", app_pkg.id, dir);
54 Type t_string = typeof(string);54 Type t_string = typeof(string);
55 trs.execute_insert("INSERT INTO '%s' VALUES (:id, :name, :description, :icon);".printf (dir),55 try {
56 trs.execute_insert("INSERT INTO '%s' VALUES (:id, :name, :description, :icon);".printf (dir),
56 ":id", t_string, app_pkg.id,57 ":id", t_string, app_pkg.id,
57 ":name", t_string, app_pkg.name,58 ":name", t_string, app_pkg.name,
58 ":description", t_string, app_pkg.summary,59 ":description", t_string, app_pkg.summary,
59 ":icon", t_string, app_pkg.icon);60 ":icon", t_string, app_pkg.icon);
61 }
62 catch(GLib.Error e) {
63 GLib.error("Failed to insert values into database. %s", e.message);
64 }
60 }65 }
61 }66 }
62 67
@@ -112,28 +117,47 @@
112 packages = new Gee.HashMap<string, AppInstallPackage> ();117 packages = new Gee.HashMap<string, AppInstallPackage> ();
113 118
114 desktop_dir = "/usr/share/app-install/desktop/";119 desktop_dir = "/usr/share/app-install/desktop/";
115 root = Dir.open (desktop_dir, 0);120 try {
121 root = Dir.open (desktop_dir, 0);
122 }
123 catch(GLib.Error e) {
124 GLib.error("Failed to open desktop directory: %s: %s", desktop_dir, e.message);
125 }
116 keys = new KeyFile ();126 keys = new KeyFile ();
117 127
118 MenuParser parser = new MenuParser (menu_file);128 MenuParser parser = new MenuParser (menu_file);
119 129
120 trans = db.begin_transaction ();130 try {
131 trans = db.begin_transaction ();
132 }
133 catch(GLib.Error e) {
134 GLib.error("Failed to start database transaction: %s", e.message);
135 }
121 136
122 stdout.printf ("Collecting app-install data...\n");137 stdout.printf ("Collecting app-install data...\n");
123 138 try {
124 trans.execute ("CREATE TABLE 'DIRECTORIES' (id, name, summary, icon, directory);");139 trans.execute ("CREATE TABLE 'DIRECTORIES' (id, name, summary, icon, directory);");
140 }
141 catch(GLib.Error e) {
142 GLib.error("Failed to create table DIRECTORIES: %s", e.message);
143 }
125 144
126 menu_dirs = parser.parse();145 menu_dirs = parser.parse();
127 146
128 foreach (MenuDir item in menu_dirs) {147 foreach (MenuDir item in menu_dirs) {
129 if (item.level == 1) { // We just want the Applications childs148 if (item.level == 1) { // We just want the Applications childs
130 trans.execute ("CREATE TABLE '%s' (id, name, summary, icon);".printf (item.id));149 try {
131 trans.execute ("INSERT INTO 'DIRECTORIES' VALUES (:id, :name, :summary, :icon, :directory);", 150 trans.execute ("CREATE TABLE '%s' (id, name, summary, icon);".printf (item.id));
151 trans.execute ("INSERT INTO 'DIRECTORIES' VALUES (:id, :name, :summary, :icon, :directory);",
132 ":id", typeof (string), item.id,152 ":id", typeof (string), item.id,
133 ":name", typeof (string), item.name,153 ":name", typeof (string), item.name,
134 ":summary", typeof (string), item.summary,154 ":summary", typeof (string), item.summary,
135 ":icon", typeof (string), item.icon,155 ":icon", typeof (string), item.icon,
136 ":directory", typeof (string), item.directory);156 ":directory", typeof (string), item.directory);
157 }
158 catch(GLib.Error e) {
159 GLib.error("Failed to create table %s: %s", item.id, e.message);
160 }
137 }161 }
138 }162 }
139 163
@@ -176,8 +200,11 @@
176 OptionContext context = new OptionContext ("Build a Lsc (Light Software Center) Database");200 OptionContext context = new OptionContext ("Build a Lsc (Light Software Center) Database");
177 context.add_main_entries (entries, null);201 context.add_main_entries (entries, null);
178 202
179 if (! context.parse (ref args)) {203 try {
180 GLib.error ("Options parsing error!\n");204 context.parse (ref args);
205 }
206 catch(GLib.Error e) {
207 GLib.error("Failed to parse options: %s", e.message);
181 }208 }
182 209
183 if (db_filename == null) {210 if (db_filename == null) {
@@ -192,12 +219,22 @@
192 }219 }
193 220
194 FileUtils.remove ("/var/cache/lsc-vala.db");221 FileUtils.remove ("/var/cache/lsc-vala.db");
195 db = new Database ("/var/cache/lsc-vala.db");222 try {
223 db = new Database ("/var/cache/lsc-vala.db");
224 }
225 catch(GLib.Error e) {
226 GLib.error("Failed to create database: %s", e.message);
227 }
196 228
197 dbbuilder = new DbBuilder (db, menu_filename);229 dbbuilder = new DbBuilder (db, menu_filename);
198 230
199 client = new Client ();231 client = new Client ();
200 trans = db.begin_transaction ();232 try {
233 trans = db.begin_transaction ();
234 }
235 catch(GLib.Error e) {
236 GLib.error("Failed to begin transaction: %s", e.message);
237 }
201 238
202 stdout.printf ("Querying PackageKit...\n");239 stdout.printf ("Querying PackageKit...\n");
203 240
204241
=== modified file 'db-build/libmenu.vala'
--- db-build/libmenu.vala 2012-07-04 17:01:15 +0000
+++ db-build/libmenu.vala 2012-07-12 10:23:12 +0000
@@ -1,4 +1,3 @@
1
2namespace Menu {1namespace Menu {
3 class MenuDir : Object {2 class MenuDir : Object {
4 public string id { get; set; }3 public string id { get; set; }
@@ -55,8 +54,13 @@
55 54
56 public MenuDir[] parse () {55 public MenuDir[] parse () {
57 string file;56 string file;
58 FileUtils.get_contents (menu_file, out file, null);57 try {
59 context.parse (file, file.length);58 FileUtils.get_contents (menu_file, out file, null);
59 context.parse (file, file.length);
60 }
61 catch(GLib.Error e) {
62 GLib.error("Failed to parse file. %s\n", e.message);
63 }
60 64
61 return dirlist;65 return dirlist;
62 }66 }

Subscribers

People subscribed via source and target branches

to all changes: