[evolution-data-server] EDataBook: Attach to EBookBackend during initialization.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] EDataBook: Attach to EBookBackend during initialization.
- Date: Mon, 25 Mar 2013 17:05:06 +0000 (UTC)
commit 6f922729ba47c789552b5a4153d2b548acee2602
Author: Matthew Barnes <mbarnes redhat com>
Date: Mon Mar 25 12:37:41 2013 -0400
EDataBook: Attach to EBookBackend during initialization.
The EDataBook will automatically attach itself to the EBookBackend,
like a parasite at birth. This ensures the EBookBackend is able to
invoke class methods earlier during EDataBook initialization.
addressbook/libedata-book/e-data-book-factory.c | 5 +--
addressbook/libedata-book/e-data-book.c | 26 +++++++++++-----------
2 files changed, 15 insertions(+), 16 deletions(-)
---
diff --git a/addressbook/libedata-book/e-data-book-factory.c b/addressbook/libedata-book/e-data-book-factory.c
index a9bb5da..900e3e2 100644
--- a/addressbook/libedata-book/e-data-book-factory.c
+++ b/addressbook/libedata-book/e-data-book-factory.c
@@ -328,14 +328,13 @@ data_book_factory_open (EDataBookFactory *factory,
} else {
object_path = construct_book_factory_path ();
+ /* The EDataBook will attach itself to EBookBackend,
+ * so no need to call e_book_backend_set_data_book(). */
data_book = e_data_book_new (
E_BOOK_BACKEND (backend),
connection, object_path, error);
if (data_book != NULL) {
- e_book_backend_set_data_book (
- E_BOOK_BACKEND (backend), data_book);
-
data_book_factory_watched_names_add (
factory, connection, sender);
diff --git a/addressbook/libedata-book/e-data-book.c b/addressbook/libedata-book/e-data-book.c
index c302cf8..85c5bc6 100644
--- a/addressbook/libedata-book/e-data-book.c
+++ b/addressbook/libedata-book/e-data-book.c
@@ -1935,16 +1935,19 @@ data_book_initable_init (GInitable *initable,
GCancellable *cancellable,
GError **error)
{
+ EBookBackend *backend;
EDataBook *book;
OperationData *op;
+ gboolean success = TRUE;
book = E_DATA_BOOK (initable);
+ backend = e_data_book_ref_backend (book);
+
if (book->priv->connection != NULL && book->priv->object_path != NULL) {
- EBookBackend *backend;
- backend = e_data_book_ref_backend (book);
- g_warn_if_fail (backend != NULL);
+ /* Attach ourselves to the EBookBackend. */
+ e_book_backend_set_data_book (backend, book);
book->priv->dbus_interface =
e_dbus_address_book_skeleton_new ();
@@ -1986,17 +1989,13 @@ data_book_initable_init (GInitable *initable,
e_book_backend_get_direct_book (backend);
if (book->priv->direct_book != NULL) {
- gboolean success;
-
success = e_data_book_direct_register_gdbus_object (
book->priv->direct_book,
book->priv->connection,
book->priv->object_path,
error);
- if (!success) {
- g_object_unref (backend);
- return FALSE;
- }
+ if (!success)
+ goto exit;
}
g_object_bind_property (
@@ -2046,16 +2045,17 @@ data_book_initable_init (GInitable *initable,
op->cancellable, op->d.prop_name);
op_unref (op);
- g_object_unref (backend);
-
- return g_dbus_interface_skeleton_export (
+ success = g_dbus_interface_skeleton_export (
G_DBUS_INTERFACE_SKELETON (book->priv->dbus_interface),
book->priv->connection,
book->priv->object_path,
error);
}
- return TRUE;
+exit:
+ g_clear_object (&backend);
+
+ return success;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]