[tracker] tracker-writeback: Cleanly handle errors of dispatcher's construction
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] tracker-writeback: Cleanly handle errors of dispatcher's construction
- Date: Tue, 1 Mar 2011 11:42:18 +0000 (UTC)
commit 59b778daea78f3d04e3cb4ab5542f89753a037ec
Author: Philip Van Hoof <philip codeminded be>
Date: Tue Mar 1 12:30:21 2011 +0100
tracker-writeback: Cleanly handle errors of dispatcher's construction
Fixes NB#231631.
src/tracker-writeback/tracker-main.c | 10 +++++++++-
.../tracker-writeback-dispatcher.c | 17 ++++++++++++++---
.../tracker-writeback-dispatcher.h | 3 ++-
3 files changed, 25 insertions(+), 5 deletions(-)
---
diff --git a/src/tracker-writeback/tracker-main.c b/src/tracker-writeback/tracker-main.c
index 66ab0f7..f5f66df 100644
--- a/src/tracker-writeback/tracker-main.c
+++ b/src/tracker-writeback/tracker-main.c
@@ -213,7 +213,15 @@ main (int argc,
* signals initialization. */
dispatcher_context = g_main_context_new ();
- dispatcher = tracker_writeback_dispatcher_new (dispatcher_context);
+ dispatcher = tracker_writeback_dispatcher_new (dispatcher_context,
+ &error);
+
+ if (error) {
+ g_critical ("Error creating dispatcher: %s", error->message);
+ g_error_free (error);
+
+ return EXIT_FAILURE;
+ }
g_thread_create (dispatcher_thread_func, dispatcher, FALSE, &error);
diff --git a/src/tracker-writeback/tracker-writeback-dispatcher.c b/src/tracker-writeback/tracker-writeback-dispatcher.c
index c57a496..065a1e4 100644
--- a/src/tracker-writeback/tracker-writeback-dispatcher.c
+++ b/src/tracker-writeback/tracker-writeback-dispatcher.c
@@ -392,10 +392,21 @@ tracker_writeback_dispatcher_set_property (GObject *object,
}
TrackerWritebackDispatcher *
-tracker_writeback_dispatcher_new (GMainContext *context)
+tracker_writeback_dispatcher_new (GMainContext *context,
+ GError **error)
{
- return g_initable_new (TRACKER_TYPE_WRITEBACK_DISPATCHER,
- NULL, NULL,
+ GError *internal_error = NULL;
+ TrackerWritebackDispatcher *ret;
+
+ ret = g_initable_new (TRACKER_TYPE_WRITEBACK_DISPATCHER,
+ NULL, &internal_error,
"context", context,
NULL);
+
+ if (internal_error) {
+ g_propagate_error (error, internal_error);
+ return NULL;
+ }
+
+ return ret;
}
diff --git a/src/tracker-writeback/tracker-writeback-dispatcher.h b/src/tracker-writeback/tracker-writeback-dispatcher.h
index 633e3b2..7f995e9 100644
--- a/src/tracker-writeback/tracker-writeback-dispatcher.h
+++ b/src/tracker-writeback/tracker-writeback-dispatcher.h
@@ -51,7 +51,8 @@ struct TrackerWritebackDispatcherClass {
GType tracker_writeback_dispatcher_get_type (void) G_GNUC_CONST;
-TrackerWritebackDispatcher * tracker_writeback_dispatcher_new (GMainContext *context);
+TrackerWritebackDispatcher * tracker_writeback_dispatcher_new (GMainContext *context,
+ GError **error);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]