[evolution/wip/webkit2] Occasional runtime warning from EaMinicardView about invalid book client



commit 8fe2bc76f8d0e4268d2cb940f466fdf1f93d5c96
Author: Milan Crha <mcrha redhat com>
Date:   Thu Apr 28 18:26:57 2016 +0200

    Occasional runtime warning from EaMinicardView about invalid book client
    
    The book view could be set on the model after the call on the AtkAccessible,
    thus the ea_minicard_view_get_name() could write that runtime warning.

 .../gui/widgets/e-addressbook-reflow-adapter.c     |   24 +++++++++++-
 addressbook/gui/widgets/ea-minicard-view.c         |   38 ++++++++++++++++++++
 2 files changed, 60 insertions(+), 2 deletions(-)
---
diff --git a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c 
b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
index 97c46db..a531e33 100644
--- a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
+++ b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
@@ -39,8 +39,9 @@ struct _EAddressbookReflowAdapterPrivate {
 
        gboolean loading;
 
-       gint create_contact_id, remove_contact_id, modify_contact_id, model_changed_id;
-       gint search_started_id, search_result_id;
+       gulong create_contact_id, remove_contact_id, modify_contact_id, model_changed_id;
+       gulong search_started_id, search_result_id;
+       gulong notify_client_id;
 };
 
 #define d(x)
@@ -95,6 +96,10 @@ unlink_model (EAddressbookReflowAdapter *adapter)
                g_signal_handler_disconnect (
                        priv->model,
                        priv->search_result_id);
+       if (priv->model && priv->notify_client_id)
+               g_signal_handler_disconnect (
+                       priv->model,
+                       priv->notify_client_id);
 
        priv->create_contact_id = 0;
        priv->remove_contact_id = 0;
@@ -102,6 +107,7 @@ unlink_model (EAddressbookReflowAdapter *adapter)
        priv->model_changed_id = 0;
        priv->search_started_id = 0;
        priv->search_result_id = 0;
+       priv->notify_client_id = 0;
 
        if (priv->model)
                g_object_unref (priv->model);
@@ -416,6 +422,16 @@ search_result (EAddressbookModel *model,
 }
 
 static void
+notify_client_cb (EAddressbookModel *model,
+                 GParamSpec *param,
+                 GObject *adapter)
+{
+       g_return_if_fail (E_IS_ADDRESSBOOK_REFLOW_ADAPTER (adapter));
+
+       g_object_notify (adapter, "client");
+}
+
+static void
 addressbook_set_property (GObject *object,
                           guint property_id,
                           const GValue *value,
@@ -607,6 +623,10 @@ e_addressbook_reflow_adapter_construct (EAddressbookReflowAdapter *adapter,
        priv->search_result_id = g_signal_connect (
                priv->model, "search_result",
                G_CALLBACK (search_result), adapter);
+
+       priv->notify_client_id = g_signal_connect (
+               priv->model, "notify::client",
+               G_CALLBACK (notify_client_cb), adapter);
 }
 
 EReflowModel *
diff --git a/addressbook/gui/widgets/ea-minicard-view.c b/addressbook/gui/widgets/ea-minicard-view.c
index 1f3ca9e..ae130d1 100644
--- a/addressbook/gui/widgets/ea-minicard-view.c
+++ b/addressbook/gui/widgets/ea-minicard-view.c
@@ -132,9 +132,36 @@ ea_minicard_view_get_type (void)
 }
 
 static void
+adapter_notify_client_cb (EAddressbookReflowAdapter *adapter,
+                         GParamSpec *param,
+                         AtkObject *accessible)
+{
+       atk_object_set_name (accessible, ea_minicard_view_get_name (accessible));
+}
+
+static void
+ea_minicard_view_dispose (GObject *object)
+{
+       EMinicardView *card_view = NULL;
+       GObject *gobj;
+
+       gobj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (object));
+
+       if (E_IS_MINICARD_VIEW (gobj))
+               card_view = E_MINICARD_VIEW (gobj);
+
+       if (card_view && card_view->adapter) {
+               g_signal_handlers_disconnect_by_func (card_view->adapter, adapter_notify_client_cb, object);
+       }
+
+       G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
 ea_minicard_view_class_init (EaMinicardViewClass *klass)
 {
        AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+       GObjectClass *object_class;
 
        parent_class = g_type_class_peek_parent (klass);
 
@@ -143,6 +170,9 @@ ea_minicard_view_class_init (EaMinicardViewClass *klass)
        class->ref_state_set = ea_minicard_view_ref_state_set;
        class->get_n_children = ea_minicard_view_get_n_children;
        class->ref_child = ea_minicard_view_ref_child;
+
+       object_class = G_OBJECT_CLASS (klass);
+       object_class->dispose = ea_minicard_view_dispose;
 }
 
 static const gchar *
@@ -166,6 +196,8 @@ ea_minicard_view_get_name (AtkObject *accessible)
        /* Get the current name of minicard view*/
        card_view = E_MINICARD_VIEW (reflow);
        g_object_get (card_view->adapter, "client", &book_client, NULL);
+       if (!book_client)
+               return accessible->name;
        g_return_val_if_fail (E_IS_BOOK_CLIENT (book_client), NULL);
        source = e_client_get_source (E_CLIENT (book_client));
        display_name = e_source_get_display_name (source);
@@ -198,12 +230,18 @@ ea_minicard_view_new (GObject *obj)
 {
        GObject *object;
        AtkObject *accessible;
+       EMinicardView *card_view;
 
        g_return_val_if_fail (E_IS_MINICARD_VIEW (obj), NULL);
        object = g_object_new (EA_TYPE_MINICARD_VIEW, NULL);
        accessible = ATK_OBJECT (object);
        atk_object_initialize (accessible, obj);
        accessible->role = ATK_ROLE_PANEL;
+
+       card_view = E_MINICARD_VIEW (obj);
+       if (card_view->adapter)
+               g_signal_connect (card_view->adapter, "notify::client", G_CALLBACK 
(adapter_notify_client_cb), accessible);
+
        return accessible;
 }
 


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