From dec4847b3f4a892ea81d04fdf3074bfccbd341f9 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 5 Jun 2008 20:41:32 +0000 Subject: [PATCH] (gtk) #998: gtk client crashes if you quit while the stats window is still up --- gtk/stats.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gtk/stats.c b/gtk/stats.c index a5af2aaf5..9cdbdde17 100644 --- a/gtk/stats.c +++ b/gtk/stats.c @@ -76,6 +76,12 @@ updateStats( gpointer gdata ) return TRUE; } +static void +dialogDestroyed( gpointer p, GObject * dialog UNUSED ) +{ + g_source_remove( GPOINTER_TO_UINT( p ) ); +} + static void dialogResponse( GtkDialog * dialog, gint response, gpointer gdata ) { @@ -90,7 +96,6 @@ dialogResponse( GtkDialog * dialog, gint response, gpointer gdata ) if( response == GTK_RESPONSE_CLOSE ) { - g_source_remove( GPOINTER_TO_UINT( g_object_get_data( G_OBJECT(dialog), "TrTimer" ) ) ); gtk_widget_destroy( GTK_WIDGET( dialog ) ); } } @@ -143,6 +148,6 @@ stats_dialog_create( GtkWindow * parent, TrCore * core ) g_object_set_data_full( G_OBJECT(d), "data", ui, g_free ); g_signal_connect( d, "response", G_CALLBACK(dialogResponse), ui ); i = g_timeout_add( 1000, updateStats, ui ); - g_object_set_data( G_OBJECT(d), "TrTimer", GUINT_TO_POINTER(i) ); + g_object_weak_ref( G_OBJECT( d ), dialogDestroyed, GUINT_TO_POINTER( i ) ); return d; }