Disconnect the idle sound handler in notes during finalization
authorClaudio Saavedra <csaavedra@igalia.com>
Thu, 14 May 2009 10:56:37 +0000 (13:56 +0300)
committerClaudio Saavedra <csaavedra@igalia.com>
Thu, 14 May 2009 10:56:37 +0000 (13:56 +0300)
* hildon/hildon-note-private.h: Add idle_handler to the private data.
* hildon/hildon-note.c (hildon_note_init), (hildon_note_finalize),
(on_show_cb), (sound_handling): Disconnect the idle handler for
the sound when the note is finalized to avoid possible crashes.

Fixes: NB#116786 (Image viewer crases whie trying to launch menu,
in a scenario)

ChangeLog
hildon/hildon-note-private.h
hildon/hildon-note.c

index 8dec0af..c1178b9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-05-14  Claudio Saavedra  <csaavedra@igalia.com>
+
+       * hildon/hildon-note-private.h: Add idle_handler to the private data.
+       * hildon/hildon-note.c (hildon_note_init), (hildon_note_finalize),
+       (on_show_cb), (sound_handling): Disconnect the idle handler for
+       the sound when the note is finalized to avoid possible crashes.
+
+       Fixes: NB#116786 (Image viewer crases whie trying to launch menu,
+       in a scenario)
+
 2009-05-13  Artem Egorkine  <ext-artem.egorkine@nokia.com>
 
        * src/hildon-animation-actor.c,
index f8e235e..298411c 100644 (file)
@@ -47,6 +47,7 @@ struct                                          _HildonNotePrivate
     gint button_width;
 
     gchar *original_description;
+    guint idle_handler;
 
   /* These strings stored for backwards compatibility */
     gchar *icon;
index b2160c7..53ca1e9 100644 (file)
@@ -415,6 +415,7 @@ hildon_note_init                                (HildonNote *dialog)
     priv->event_box = gtk_event_box_new ();
     priv->icon = NULL;
     priv->stock_icon = NULL;
+    priv->idle_handler = 0;
 
     gtk_event_box_set_visible_window (GTK_EVENT_BOX (priv->event_box), FALSE);
     gtk_event_box_set_above_child (GTK_EVENT_BOX (priv->event_box), TRUE);
@@ -463,6 +464,10 @@ hildon_note_finalize                            (GObject *obj_self)
         g_free (priv->stock_icon);
         priv->stock_icon = NULL;
     }
+    if (priv->idle_handler) {
+        g_source_remove (priv->idle_handler);
+        priv->idle_handler = 0;
+    }
 
     if (priv->progressbar)
         g_object_unref (priv->progressbar);
@@ -1025,7 +1030,10 @@ static void
 on_show_cb                                      (GtkWidget *widget,
                                                  gpointer data)
 {
-    g_idle_add (sound_handling, widget);
+    HildonNotePrivate *priv;
+
+    priv = HILDON_NOTE_GET_PRIVATE (widget);
+    priv->idle_handler = g_idle_add (sound_handling, widget);
 }
 
 /* We play a system sound when the note comes visible */
@@ -1051,5 +1059,7 @@ sound_handling                                  (gpointer data)
             break;
     };
 
+    priv->idle_handler = 0;
+
     return FALSE;
 }