[evolution-data-server] EDataBook: Fix e_data_book_new_direct()



commit 2dfbaff8e96ae31efde08b68af125aedb7bdc2a8
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Thu Feb 21 20:14:49 2013 +0900

    EDataBook: Fix e_data_book_new_direct()
    
    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 |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/addressbook/libedata-book/e-data-book.c b/addressbook/libedata-book/e-data-book.c
index ee7879c..7a168b4 100644
--- a/addressbook/libedata-book/e-data-book.c
+++ b/addressbook/libedata-book/e-data-book.c
@@ -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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]