diff options
Diffstat (limited to 'libindicator')
-rw-r--r-- | libindicator/indicator-ng.c | 15 | ||||
-rw-r--r-- | libindicator/indicator-service.c | 25 |
2 files changed, 16 insertions, 24 deletions
diff --git a/libindicator/indicator-ng.c b/libindicator/indicator-ng.c index a502c50..507f979 100644 --- a/libindicator/indicator-ng.c +++ b/libindicator/indicator-ng.c @@ -240,9 +240,6 @@ indicator_ng_set_icon_from_variant (IndicatorNg *self, return; } - if (!self->entry.image) - self->entry.image = g_object_ref_sink (gtk_image_new ()); - gtk_widget_show (GTK_WIDGET (self->entry.image)); icon = g_icon_deserialize (variant); @@ -271,9 +268,6 @@ indicator_ng_set_label (IndicatorNg *self, return; } - if (!self->entry.label) - self->entry.label = g_object_ref_sink (gtk_label_new (NULL)); - gtk_label_set_label (GTK_LABEL (self->entry.label), label); gtk_widget_show (GTK_WIDGET (self->entry.label)); } @@ -498,7 +492,11 @@ indicator_ng_service_vanished (GDBusConnection *connection, /* take care not to start it if it repeatedly crashes */ now = g_get_monotonic_time (); if (now - self->last_service_restart < 1 * G_USEC_PER_SEC) - return; + { + g_warning ("The indicator '%s' vanished too quickly after appearing. It won't " + "be respawned anymore, as it could be crashing repeatedly.", self->name); + return; + } self->last_service_restart = now; @@ -654,6 +652,9 @@ indicator_ng_initable_iface_init (GInitableIface *initable) static void indicator_ng_init (IndicatorNg *self) { + self->entry.label = g_object_ref_sink (gtk_label_new (NULL)); + self->entry.image = g_object_ref_sink (gtk_image_new ()); + self->entry.menu = g_object_ref_sink (gtk_menu_new ()); /* work around IndicatorObject's warning that the accessible diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index 11171fc..1cd6964 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -25,6 +25,8 @@ License along with this library. If not, see #include "config.h" #endif +#include <stdlib.h> /* exit() */ + #include <gio/gio.h> #include "indicator-service.h" @@ -231,10 +233,7 @@ indicator_service_dispose (GObject *object) { IndicatorServicePrivate * priv = INDICATOR_SERVICE_GET_PRIVATE(object); - if (priv->watchers != NULL) { - g_hash_table_destroy(priv->watchers); - priv->watchers = NULL; - } + g_clear_pointer (&priv->watchers, g_hash_table_destroy); if (priv->timeout != 0) { g_source_remove(priv->timeout); @@ -247,10 +246,7 @@ indicator_service_dispose (GObject *object) priv->dbus_registration = 0; } - if (priv->bus != NULL) { - g_object_unref(priv->bus); - priv->bus = NULL; - } + g_clear_object (&priv->bus); if (priv->bus_cancel != NULL) { g_cancellable_cancel(priv->bus_cancel); @@ -269,14 +265,8 @@ indicator_service_finalize (GObject *object) { IndicatorServicePrivate * priv = INDICATOR_SERVICE_GET_PRIVATE(object); - if (priv->name != NULL) { - g_free(priv->name); - } - - if (priv->watchers != NULL) { - g_hash_table_destroy(priv->watchers); - priv->watchers = NULL; - } + g_free (priv->name); + g_clear_pointer (&priv->watchers, g_hash_table_destroy); G_OBJECT_CLASS (indicator_service_parent_class)->finalize (object); return; @@ -361,8 +351,9 @@ bus_get_cb (GObject * object, GAsyncResult * res, gpointer user_data) GDBusConnection * connection = g_bus_get_finish(res, &error); if (error != NULL) { - g_error("OMG! Unable to get a connection to DBus: %s", error->message); + g_warning("Unable to get a connection to the session DBus: %s", error->message); g_error_free(error); + exit (0); return; } |