]> git.0d.be Git - empathy.git/commitdiff
Don't try to free NULL pixbufs.
authorWill Thompson <will.thompson@collabora.co.uk>
Tue, 4 Aug 2009 21:29:56 +0000 (22:29 +0100)
committerWill Thompson <will.thompson@collabora.co.uk>
Tue, 4 Aug 2009 21:35:54 +0000 (22:35 +0100)
It's all very well to ensure that we don't pass a NULL pixbuf to
libnotify, but we shouldn't then try to g_object_unref () the pointer
without checking it's not NULL.

src/empathy-chat-window.c
src/empathy-status-icon.c

index 3e77553b37f47c8f159c0ede4a9bc76614f90aa6..bde0e215e889b46efdf4353e14bd68ba7acaa245 100644 (file)
@@ -969,28 +969,26 @@ chat_window_show_or_update_notification (EmpathyChatWindow *window,
        body = empathy_message_get_body (message);
        escaped = g_markup_escape_text (body, -1);
 
-       pixbuf = empathy_misc_get_pixbuf_for_notification (sender, EMPATHY_IMAGE_NEW_MESSAGE);
-
        if (priv->notification != NULL) {
                notify_notification_update (priv->notification,
                                            header, escaped, NULL);
-               /* if icon doesn't exist libnotify will crash */
-               if (pixbuf != NULL)
-                       notify_notification_set_icon_from_pixbuf (priv->notification, pixbuf);
        } else {
                priv->notification = notify_notification_new (header, escaped, NULL, NULL);
                notify_notification_set_timeout (priv->notification, NOTIFY_EXPIRES_DEFAULT);
-               /* if icon doesn't exist libnotify will crash */
-               if (pixbuf != NULL)
-                       notify_notification_set_icon_from_pixbuf (priv->notification, pixbuf);
 
                g_signal_connect (priv->notification, "closed",
                                  G_CALLBACK (chat_window_notification_closed_cb), cb_data);
        }
 
+       pixbuf = empathy_misc_get_pixbuf_for_notification (sender, EMPATHY_IMAGE_NEW_MESSAGE);
+
+       if (pixbuf != NULL) {
+               notify_notification_set_icon_from_pixbuf (priv->notification, pixbuf);
+               g_object_unref (pixbuf);
+       }
+
        notify_notification_show (priv->notification, NULL);
 
-       g_object_unref (pixbuf);
        g_free (escaped);
 }
 
index 1f6a32c954ef90a4c8e2346398e88379deefbbb0..79e59c5f5368abc2d25d8262df6ae4414a92b7ca 100644 (file)
@@ -140,9 +140,6 @@ status_icon_update_notification (EmpathyStatusIcon *icon)
        if (priv->event) {
                gchar *message_esc = g_markup_escape_text (priv->event->message, -1);
 
-               pixbuf = empathy_misc_get_pixbuf_for_notification (priv->event->contact,
-                                                                  priv->event->icon_name);
-
                if (priv->notification) {
                        notify_notification_update (priv->notification,
                                                    priv->event->header, message_esc,
@@ -155,15 +152,19 @@ status_icon_update_notification (EmpathyStatusIcon *icon)
 
                        g_signal_connect (priv->notification, "closed",
                                          G_CALLBACK (status_icon_notification_closed_cb), icon);
+               }
 
-               }
-               /* if icon doesn't exist libnotify will crash */
-               if (pixbuf != NULL)
+               pixbuf = empathy_misc_get_pixbuf_for_notification (priv->event->contact,
+                                                                  priv->event->icon_name);
+
+               if (pixbuf != NULL) {
                        notify_notification_set_icon_from_pixbuf (priv->notification,
                                                          pixbuf);
+                       g_object_unref (pixbuf);
+               }
+
                notify_notification_show (priv->notification, NULL);
 
-               g_object_unref (pixbuf);
                g_free (message_esc);
        } else {
                notification_close_helper (priv);