EDataBook: Fix e_data_book_new_direct()
authorTristan Van Berkom <tristanvb@openismus.com>
Thu, 21 Feb 2013 11:14:49 +0000 (20:14 +0900)
committerTristan Van Berkom <tristanvb@openismus.com>
Thu, 21 Feb 2013 11:21:07 +0000 (20:21 +0900)
Since recent backends in master open thier persistance at initable_init()
time, it became necessary to splitup g_initable_new() into g_object_new()
and g_initable_init(), calling e_book_backend_configure_direct() in between.

Note: this fixes Direct Read Access where the XDG directories might not
be the same in the server context as in the client context.

addressbook/libedata-book/e-data-book.c

index ee7879c..7a168b4 100644 (file)
@@ -2227,17 +2227,23 @@ e_data_book_new_direct (ESourceRegistry *registry,
        backend_type  = E_BOOK_BACKEND_FACTORY_CLASS (factory_class)->backend_type;
        g_type_class_unref (factory_class);
 
-       backend = g_initable_new (backend_type, NULL, error,
+
+       backend = g_object_new (backend_type,
                                "registry", registry,
                                "source", source, NULL);
 
-       if (!backend) {
+       /* The backend must be configured for direct access
+        * before calling g_initable_init() because backends
+        * now can open thier content at initable_init() time.
+        */
+       e_book_backend_configure_direct (backend, config);
+
+       if (!g_initable_init (G_INITABLE (backend), NULL, error)) {
+               g_object_unref (backend);
                g_type_module_unuse (G_TYPE_MODULE (module));
                goto new_direct_finish;
        }
 
-       e_book_backend_configure_direct (backend, config);
-
        book = g_initable_new (E_TYPE_DATA_BOOK, NULL, error,
                               "backend", backend, NULL);
        g_object_unref (backend);