Index: /trunk/gtk/main.c =================================================================== --- /trunk/gtk/main.c (revision 8656) +++ /trunk/gtk/main.c (revision 8666) @@ -85,6 +85,6 @@ GSList * errqueue; GSList * dupqueue; + GSList * details; GtkTreeSelection * sel; - gpointer details; }; @@ -206,5 +206,5 @@ static void -refreshDetailsDialog( struct cbdata * data ) +refreshDetailsDialog( struct cbdata * data, GtkWidget * details ) { GtkTreeSelection * s = tr_window_get_selection( data->wind ); @@ -213,7 +213,4 @@ GList * selrows = NULL; GList * l; - - if( data->details == NULL ) - return; /* build a list of the selected torrents' ids */ @@ -228,5 +225,5 @@ } - torrent_inspector_set_torrents( GTK_WIDGET( data->details ), ids ); + torrent_inspector_set_torrents( details, ids ); /* cleanup */ @@ -240,5 +237,4 @@ { refreshActions( data ); - refreshDetailsDialog( data ); } @@ -622,6 +618,8 @@ /* shutdown the gui */ - if( cbdata->details ) - gtk_widget_destroy( GTK_WIDGET( cbdata->details ) ); + if( cbdata->details ) { + g_slist_foreach( cbdata->details, (GFunc)gtk_widget_destroy, NULL ); + g_slist_free( cbdata->details ); + } if( cbdata->prefs ) gtk_widget_destroy( GTK_WIDGET( cbdata->prefs ) ); @@ -926,7 +924,5 @@ if( !strcmp( key, TR_PREFS_KEY_ENCRYPTION ) ) { - const int encryption = pref_int_get( key ); - g_message( "setting encryption to %d", encryption ); - tr_sessionSetEncryption( tr, encryption ); + tr_sessionSetEncryption( tr, pref_int_get( key ) ); } else if( !strcmp( key, TR_PREFS_KEY_DOWNLOAD_DIR ) ) @@ -1284,4 +1280,11 @@ } +static void +detailsClosed( gpointer gdata, GObject * dead ) +{ + struct cbdata * data = gdata; + data->details = g_slist_remove( data->details, dead ); +} + void doAction( const char * action_name, gpointer user_data ) @@ -1343,10 +1346,9 @@ else if( !strcmp( action_name, "show-torrent-properties" ) ) { - if( data->details == NULL ) { - data->details = torrent_inspector_new( GTK_WINDOW( data->wind ), data->core ); - g_object_add_weak_pointer( G_OBJECT( data->details ), &data->details ); - } - refreshDetailsDialog( data ); - gtk_widget_show( GTK_WIDGET( data->details ) ); + GtkWidget * w = torrent_inspector_new( GTK_WINDOW( data->wind ), data->core ); + data->details = g_slist_prepend( data->details, w ); + g_object_weak_ref( G_OBJECT( w ), detailsClosed, data ); + refreshDetailsDialog( data, w ); + gtk_widget_show( w ); } else if( !strcmp( action_name, "update-tracker" ) ) Index: /trunk/gtk/details.c =================================================================== --- /trunk/gtk/details.c (revision 8433) +++ /trunk/gtk/details.c (revision 8666) @@ -1979,5 +1979,5 @@ GtkWidget * w = GTK_WIDGET( dialog ); torrent_inspector_set_torrents( w, NULL ); - gtk_widget_hide( w ); + gtk_widget_destroy( w ); }