[PATCH] : About the crash just signaled



	Hi all,
here is a patch that cures the crash I described a few minutes ago. In 
fact I've just connected the "destroy" message of the displayed message to 
a callback that destroys the window so that the window disappear whenever 
the message is destroyed. Note that you can delete the message and still 
have the window opened : indeed deleting the message does not mean 
destroying the GtkObject underlying it.
Note on the patch : I also removed a line that seemed to lead to a double 
gtk_widget_destroy on the window.
Bye
Manu
--- ../../balsa-cvs/balsa/src/message-window.c	Mon Feb  4 10:16:51 2002
+++ balsa-new/src/message-window.c	Tue May 21 15:17:10 2002
@@ -41,13 +41,14 @@
 struct BalsaMRUEntry
 {
     LibBalsaMailbox *mailbox;
-    gchar *url; /* FIXME: purpose (copied from mailbox?) */
-    char *name; /* FIXME: purpose (copied from mailbox?) */
-    gpointer mw; /* FIXME: purpose? more descriptive name? */
+    gchar *url; /* Just a ref on the mailbox url, not a copy */
+    char *name; /* same here : it's only a ref not a copy */
+    gpointer mw; /* The message window : this is needed by callbacks*/
 };
 
 /* callbacks */
 static void destroy_message_window(GtkWidget * widget, gpointer data);
+static void message_destroyed_cb(GtkWidget * widget, gpointer data);
 static void close_message_window(GtkWidget * widget, gpointer data);
 
 static void replyto_message_cb(GtkWidget * widget, gpointer data);
@@ -304,6 +305,13 @@
     gtk_signal_connect(GTK_OBJECT(mw->window),
 		       "destroy",
 		       GTK_SIGNAL_FUNC(destroy_message_window), mw);
+    /* We connect the destroy signal of the displayed message to a callback
+       that'll destroy the window.
+       This insures that whenever the message gets destroyed that we don't
+       do things on ghosts ;-) */
+    gtk_signal_connect(GTK_OBJECT(message), "destroy",
+		       GTK_SIGNAL_FUNC(message_destroyed_cb),
+		       (gpointer) mw->window);
     
     gnome_app_create_menus_with_data(GNOME_APP(mw->window), main_menu, mw);
 
@@ -370,7 +378,6 @@
     release_toolbars(mw->window);
     g_hash_table_remove(displayed_messages, mw->message);
 
-    gtk_widget_destroy(mw->window);
     gtk_widget_destroy(mw->bmessage);
 
     if(mw->mru_list) {
@@ -379,6 +386,13 @@
     }
 
     g_free(mw);
+}
+
+static void message_destroyed_cb(GtkWidget * widget, gpointer data)
+{
+    GtkWidget * window = GTK_WIDGET(data);
+
+    gtk_widget_destroy(window);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]