aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-04-20 14:22:41 -0500
committerTed Gould <ted@canonical.com>2009-04-20 14:22:41 -0500
commit2b981cb37f805254ea140d106baa446876477090 (patch)
tree55a142b97d05c97e43eeb7c4d018a4b525f6193a
parentff58926771be367ff2fcbfcb5bc783dab5f00a96 (diff)
parentb5159bc66b25208344bb456f968cf6494815045b (diff)
downloadayatana-indicator-messages-2b981cb37f805254ea140d106baa446876477090.tar.gz
ayatana-indicator-messages-2b981cb37f805254ea140d106baa446876477090.tar.bz2
ayatana-indicator-messages-2b981cb37f805254ea140d106baa446876477090.zip
Some changes suggested by Cody Russell to make things a little bit safer.
-rw-r--r--src/app-menu-item.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/app-menu-item.c b/src/app-menu-item.c
index 7854b90..7dc0f9e 100644
--- a/src/app-menu-item.c
+++ b/src/app-menu-item.c
@@ -119,6 +119,14 @@ app_menu_item_init (AppMenuItem *self)
static void
app_menu_item_dispose (GObject *object)
{
+ AppMenuItem * self = APP_MENU_ITEM(object);
+ AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self);
+
+ g_signal_handlers_disconnect_by_func(G_OBJECT(priv->listener), G_CALLBACK(indicator_added_cb), self);
+ g_signal_handlers_disconnect_by_func(G_OBJECT(priv->listener), G_CALLBACK(indicator_removed_cb), self);
+
+ g_object_unref(priv->listener);
+
G_OBJECT_CLASS (app_menu_item_parent_class)->dispose (object);
}
@@ -128,8 +136,13 @@ app_menu_item_finalize (GObject *object)
AppMenuItem * self = APP_MENU_ITEM(object);
AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self);
- g_signal_handlers_disconnect_by_func(G_OBJECT(priv->listener), G_CALLBACK(indicator_added_cb), self);
- g_signal_handlers_disconnect_by_func(G_OBJECT(priv->listener), G_CALLBACK(indicator_removed_cb), self);
+ if (priv->type != NULL) {
+ g_free(priv->type);
+ }
+
+ if (priv->appinfo != NULL) {
+ g_object_unref(priv->appinfo);
+ }
G_OBJECT_CLASS (app_menu_item_parent_class)->finalize (object);
@@ -144,7 +157,9 @@ app_menu_item_new (IndicateListener * listener, IndicateListenerServer * server)
AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self);
priv->listener = listener;
+ g_object_ref(G_OBJECT(listener));
priv->server = server;
+ /* Can not ref as not real GObject */
g_signal_connect(G_OBJECT(listener), INDICATE_LISTENER_SIGNAL_INDICATOR_ADDED, G_CALLBACK(indicator_added_cb), self);
g_signal_connect(G_OBJECT(listener), INDICATE_LISTENER_SIGNAL_INDICATOR_REMOVED, G_CALLBACK(indicator_removed_cb), self);
@@ -174,8 +189,14 @@ type_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * v
if (priv->type != NULL) {
g_free(priv->type);
+ priv->type = NULL;
}
+ if (value == NULL) {
+ g_warning("Type value is NULL, that shouldn't really happen");
+ return;
+ }
+
priv->type = g_strdup(value);
if (!(!g_strcmp0(priv->type, "message.instant") || !g_strcmp0(priv->type, "message.micro") || !g_strcmp0(priv->type, "message.im"))) {