b=530921 use a marshaller for NotifyNotification::closed to avoid fc10 crashes r=roc
authorKarl Tomlinson <karlt+@karlt.net>
Wed, 02 Dec 2009 14:34:20 +1300
changeset 35423 4aad3da00bffa130c3c1f36756ffb09ca11d428e
parent 35422 ecc10a6d0a986691c1378bd57eeb2bd25a05d3c4
child 35424 bdcf3b21875505bb236cf6fb6e111e13a4e18a84
push id10581
push userktomlinson@mozilla.com
push dateWed, 02 Dec 2009 21:44:51 +0000
treeherdermozilla-central@4aad3da00bff [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs530921
milestone1.9.3a1pre
b=530921 use a marshaller for NotifyNotification::closed to avoid fc10 crashes r=roc
toolkit/system/gnome/nsAlertsIconListener.cpp
--- a/toolkit/system/gnome/nsAlertsIconListener.cpp
+++ b/toolkit/system/gnome/nsAlertsIconListener.cpp
@@ -51,22 +51,30 @@ static PRBool gHasActions = PR_FALSE;
 
 static void notify_action_cb(NotifyNotification *notification,
                              gchar *action, gpointer user_data)
 {
   nsAlertsIconListener* alert = static_cast<nsAlertsIconListener*> (user_data);
   alert->SendCallback();
 }
 
-static void notify_closed_cb(NotifyNotification *notification,
-                             gpointer user_data)
+static void notify_closed_marshal(GClosure* closure,
+                                  GValue* return_value,
+                                  guint n_param_values,
+                                  const GValue* param_values,
+                                  gpointer invocation_hint,
+                                  gpointer marshal_data)
 {
+  NS_ABORT_IF_FALSE(n_param_values >= 1, "No object in params");
+
+  gpointer notification = g_value_peek_pointer(param_values);
   g_object_unref(notification);
 
-  nsAlertsIconListener* alert = static_cast<nsAlertsIconListener*> (user_data);
+  nsAlertsIconListener* alert =
+    static_cast<nsAlertsIconListener*>(closure->data);
   alert->SendClosed();
   NS_RELEASE(alert);
 }
 
 NS_IMPL_ISUPPORTS2(nsAlertsIconListener, imgIContainerObserver, imgIDecoderObserver)
 
 nsAlertsIconListener::nsAlertsIconListener()
 : mLoadedFrame(PR_FALSE)
@@ -213,17 +221,23 @@ nsAlertsIconListener::ShowAlert(GdkPixbu
   if (mAlertHasAction) {
     // What we put as the label doesn't matter here, if the action
     // string is "default" then that makes the entire bubble clickable
     // rather than creating a button.
     notify_notification_add_action(notify, "default", "Activate",
                                    notify_action_cb, this, NULL);
   }
 
-  g_signal_connect(notify, "closed", G_CALLBACK(notify_closed_cb), this);
+  // Fedora 10 calls NotifyNotification "closed" signal handlers with a
+  // different signature, so a marshaller is used instead of a C callback to
+  // get the user_data (this) in a parseable format.  |closure| is created
+  // with a floating reference, which gets sunk by g_signal_connect_closure().
+  GClosure* closure = g_closure_new_simple(sizeof(GClosure), this);
+  g_closure_set_marshal(closure, notify_closed_marshal);
+  g_signal_connect_closure(notify, "closed", closure, FALSE);
   gboolean result = notify_notification_show(notify, NULL);
 
   return result ? NS_OK : NS_ERROR_FAILURE;
 }
 
 nsresult
 nsAlertsIconListener::StartRequest(const nsAString & aImageUrl)
 {