[Xfce4-commits] <xfce4-panel:master> Delay allocation of event table until we use it.

Nick Schermer noreply at xfce.org
Tue Jul 27 20:24:02 CEST 2010


Updating branch refs/heads/master
         to 2dfd555df523a80328b03fe66bd7b741c0393d89 (commit)
       from 211d94da3dce2bd1d23329502de21c899cb8a95c (commit)

commit 2dfd555df523a80328b03fe66bd7b741c0393d89
Author: Nick Schermer <nick at xfce.org>
Date:   Tue Jul 27 20:21:41 2010 +0200

    Delay allocation of event table until we use it.

 panel/panel-dbus-service.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/panel/panel-dbus-service.c b/panel/panel-dbus-service.c
index 46e789a..1fa9e5a 100644
--- a/panel/panel-dbus-service.c
+++ b/panel/panel-dbus-service.c
@@ -132,8 +132,7 @@ panel_dbus_service_init (PanelDBusService *service)
   gint            result;
 
   service->is_owner = FALSE;
-  service->remote_events = g_hash_table_new_full (g_int_hash, g_int_equal, NULL,
-                                                  panel_dbus_service_plugin_event_free);
+  service->remote_events = NULL;
 
   service->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
   if (G_LIKELY (service->connection != NULL))
@@ -167,8 +166,6 @@ panel_dbus_service_finalize (GObject *object)
   PanelDBusService *service = PANEL_DBUS_SERVICE (object);
   DBusConnection   *connection;
 
-  panel_return_if_fail (g_hash_table_size (service->remote_events) == 0);
-
   if (G_LIKELY (service->connection != NULL))
     {
       /* release the org.xfce.Panel name */
@@ -179,7 +176,11 @@ panel_dbus_service_finalize (GObject *object)
       dbus_g_connection_unref (service->connection);
     }
 
-  g_hash_table_destroy (service->remote_events);
+  if (service->remote_events != NULL)
+    {
+      panel_return_if_fail (g_hash_table_size (service->remote_events) == 0);
+      g_hash_table_destroy (service->remote_events);
+    }
 
   (*G_OBJECT_CLASS (panel_dbus_service_parent_class)->finalize) (object);
 }
@@ -389,6 +390,11 @@ panel_dbus_service_plugin_event (PanelDBusService  *service,
           g_value_init (&event->value, G_VALUE_TYPE (value));
           g_value_copy (value, &event->value);
 
+          /* create hash table if needed */
+          if (service->remote_events == NULL)
+            service->remote_events = g_hash_table_new_full (g_int_hash, g_int_equal, NULL,
+                                                            panel_dbus_service_plugin_event_free);
+
           g_hash_table_insert (service->remote_events, &event->handle, event);
           g_signal_connect (G_OBJECT (li->data), "remote-event-result",
               G_CALLBACK (panel_dbus_service_plugin_event_result), service);



More information about the Xfce4-commits mailing list