Changeset 5044


Ignore:
Timestamp:
Feb 15, 2008, 6:20:56 PM (14 years ago)
Author:
charles
Message:

fix TrTorrent? reference count error

Location:
trunk/gtk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/file-list.c

    r5026 r5044  
    358358}
    359359
    360 static void
    361 torrentDestroyed( gpointer gdata, GObject * deadTorrent UNUSED )
    362 {
    363     FileData * data = gdata;
    364     data->gtor = NULL;
    365     file_list_set_torrent( data->top, NULL );
    366 }
    367 
    368 static void
    369 freeData( gpointer gdata )
    370 {
    371     FileData * data = gdata;
    372 
    373     if( data->timeout_tag ) {
    374         g_source_remove( data->timeout_tag );
    375         data->timeout_tag = 0;
    376     }
    377 
    378     if( data->gtor != NULL )
    379         g_object_weak_unref( G_OBJECT( data->gtor ), torrentDestroyed, data );
    380 
    381     g_free( data );
    382 }
    383 
    384360static gboolean
    385361refreshModel( gpointer gdata )
     
    406382}
    407383
     384static void
     385clearData( FileData * data )
     386{
     387    data->gtor = NULL;
     388
     389    if( data->timeout_tag ) {
     390        g_source_remove( data->timeout_tag );
     391        data->timeout_tag = 0;
     392    }
     393}
     394
    408395void
    409396file_list_set_torrent( GtkWidget * w, TrTorrent * gtor )
     
    413400
    414401    data = g_object_get_data( G_OBJECT( w ), "file-data" );
     402
     403    /* unset the old fields */
     404    clearData( data );
    415405
    416406    /* instantiate the model */
     
    428418    data->gtor = gtor;
    429419
    430     if( data->timeout_tag ) {
    431         g_source_remove( data->timeout_tag );
    432         data->timeout_tag = 0;
    433     }
    434420
    435421    /* populate the model */
     
    439425        const tr_info * inf = tr_torrent_info( gtor );
    440426        tr_torrent * tor = tr_torrent_handle( gtor );
    441         g_object_weak_ref( G_OBJECT( gtor ), torrentDestroyed, data );
    442427
    443428        for( i=0; inf && i<inf->fileCount; ++i )
     
    455440    gtk_tree_view_set_model( GTK_TREE_VIEW( data->view ), GTK_TREE_MODEL( store ) );
    456441    gtk_tree_view_expand_all( GTK_TREE_VIEW( data->view ) );
     442}
     443
     444static void
     445freeData( gpointer gdata )
     446{
     447    FileData * data = gdata;
     448    clearData( data );
     449    g_free( data );
    457450}
    458451
  • trunk/gtk/open.c

    r5036 r5044  
    3535    if( data->gtor )
    3636    {
    37         tr_torrent * tor = tr_torrent_handle( data->gtor );
     37        tr_torrent * tor;
     38
     39        file_list_set_torrent( data->list, NULL );
     40
     41        tor = tr_torrent_handle( data->gtor );
    3842        tr_torrentRemoveSaved( tor );
    3943        tr_torrentClose( tor );
     44
    4045        g_object_unref( G_OBJECT( data->gtor ) );
    4146        data->gtor = NULL;
Note: See TracChangeset for help on using the changeset viewer.