Changeset 10505


Ignore:
Timestamp:
Apr 21, 2010, 4:38:54 AM (9 years ago)
Author:
charles
Message:

(trunk gtk) #3143 "remote RPC calls cause gtk+ API calls to be made from the wrong thread" -- fixed in trunk for 2.00

Location:
trunk/gtk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/add-dialog.c

    r10464 r10505  
    134134
    135135            if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( data->trash_check ) ) )
    136 
    137                 tr_file_trash_or_remove( data->filename );
     136                gtr_file_trash_or_remove( data->filename );
     137
    138138            save_recent_destination( data->core, data->downloadDir );
    139139        }
  • trunk/gtk/main.c

    r10490 r10505  
    402402}
    403403
     404struct remove_torrent_idle_data
     405{
     406    TrCore * core;
     407    int id;
     408};
     409
     410static gboolean
     411remove_torrent_idle( gpointer gdata )
     412{
     413    struct remove_torrent_idle_data * data = gdata;
     414    tr_core_remove_torrent_from_id( data->core, data->id, FALSE );
     415    g_free( data );
     416    return FALSE; /* tell g_idle not to call this func twice */
     417}
     418
    404419static void
    405420setupsighandlers( void )
     
    415430              void                  * gdata )
    416431{
     432    tr_rpc_callback_status status = TR_RPC_OK;
    417433    struct cbdata * cbdata = gdata;
    418434    gdk_threads_enter( );
     
    424440            break;
    425441
    426         case TR_RPC_TORRENT_REMOVING:
    427             tr_core_torrent_destroyed( cbdata->core, tr_torrentId( tor ) );
     442        case TR_RPC_TORRENT_REMOVING: {
     443            struct remove_torrent_idle_data * data = g_new0( struct remove_torrent_idle_data, 1 );
     444            data->id = tr_torrentId( tor );
     445            data->core = cbdata->core;
     446            gtr_idle_add( remove_torrent_idle, data );
     447            status = TR_RPC_NOREMOVE;
    428448            break;
     449        }
    429450
    430451        case TR_RPC_SESSION_CHANGED:
     
    441462
    442463    gdk_threads_leave( );
    443     return TR_RPC_OK;
     464    return status;
    444465}
    445466
     
    14391460
    14401461static void
    1441 accumulateSelectedTorrents( GtkTreeModel *      model,
     1462accumulateSelectedTorrents( GtkTreeModel * model,
    14421463                            GtkTreePath  * path UNUSED,
    1443                             GtkTreeIter *      iter,
    1444                             gpointer            gdata )
    1445 {
    1446     GSList **   data = ( GSList** ) gdata;
    1447     TrTorrent * tor = NULL;
    1448 
    1449     gtk_tree_model_get( model, iter, MC_TORRENT, &tor, -1 );
    1450     *data = g_slist_prepend( *data, tor );
    1451 }
    1452 
    1453 static void
    1454 removeSelected( struct cbdata * data,
    1455                 gboolean        delete_files )
     1464                            GtkTreeIter  * iter,
     1465                            gpointer       gdata )
     1466{
     1467    GSList ** data = ( GSList** ) gdata;
     1468    TrTorrent * gtor = NULL;
     1469
     1470    gtk_tree_model_get( model, iter, MC_TORRENT, &gtor, -1 );
     1471    *data = g_slist_prepend( *data, gtor );
     1472    g_object_unref( G_OBJECT( gtor ) );
     1473}
     1474
     1475static void
     1476removeSelected( struct cbdata * data, gboolean delete_files )
    14561477{
    14571478    GSList *           l = NULL;
  • trunk/gtk/torrent-cell-renderer.c

    r10451 r10505  
    901901    p->icon_renderer = gtk_cell_renderer_pixbuf_new(  );
    902902    g_object_set( p->text_renderer_err, "foreground", "red", NULL );
    903     tr_object_ref_sink( p->text_renderer );
    904     tr_object_ref_sink( p->text_renderer_err );
    905     tr_object_ref_sink( p->progress_renderer );
    906     tr_object_ref_sink( p->icon_renderer );
     903    gtr_object_ref_sink( p->text_renderer );
     904    gtr_object_ref_sink( p->text_renderer_err );
     905    gtr_object_ref_sink( p->progress_renderer );
     906    gtr_object_ref_sink( p->icon_renderer );
    907907
    908908    p->bar_height = DEFAULT_BAR_HEIGHT;
  • trunk/gtk/tr-core.c

    r10490 r10505  
    11821182
    11831183void
    1184 tr_core_torrent_destroyed( TrCore * core,
    1185                            int      id )
     1184tr_core_remove_torrent( TrCore * core, TrTorrent * gtor, gboolean deleteFiles )
     1185{
     1186    const tr_torrent * tor = tr_torrent_handle( gtor );
     1187
     1188    if( tor != NULL )
     1189        tr_core_remove_torrent_from_id( core, tr_torrentId( tor ), deleteFiles );
     1190}
     1191
     1192void
     1193tr_core_remove_torrent_from_id( TrCore * core, int id, gboolean deleteFiles )
    11861194{
    11871195    GtkTreeIter iter;
     
    11891197    if( findTorrentInModel( core, id, &iter ) )
    11901198    {
    1191         TrTorrent * gtor;
     1199        TrTorrent * gtor = NULL;
     1200        tr_torrent * tor = NULL;
    11921201        GtkTreeModel * model = tr_core_model( core );
    1193         gtk_tree_model_get( model, &iter, MC_TORRENT, &gtor, -1 );
    1194         tr_torrent_clear( gtor );
     1202
     1203        gtk_tree_model_get( model, &iter, MC_TORRENT, &gtor,
     1204                                          MC_TORRENT_RAW, &tor,
     1205                                          -1 );
     1206
     1207        /* remove from the gui */
    11951208        gtk_list_store_remove( GTK_LIST_STORE( model ), &iter );
    1196         g_object_unref( G_OBJECT( gtor ) );
    1197     }
    1198 }
    1199 
    1200 void
    1201 tr_core_remove_torrent( TrCore *    core,
    1202                         TrTorrent * gtor,
    1203                         int         deleteFiles )
    1204 {
    1205     const tr_torrent * tor = tr_torrent_handle( gtor );
    1206 
    1207     if( tor )
    1208     {
    1209         int         id = tr_torrentId( tor );
    1210         GtkTreeIter iter;
    1211         if( findTorrentInModel( core, id, &iter ) )
    1212         {
    1213             GtkTreeModel * model = tr_core_model( core );
    1214 
    1215             /* remove from the gui */
    1216             gtk_list_store_remove( GTK_LIST_STORE( model ), &iter );
    1217 
    1218             /* maybe delete the downloaded files */
    1219             if( deleteFiles )
    1220                 tr_torrent_delete_files( gtor );
    1221 
    1222             /* remove the torrent */
    1223             tr_torrent_set_remove_flag( gtor, TRUE );
    1224             g_object_unref( G_OBJECT( gtor ) );
    1225         }
     1209
     1210        /* maybe delete the downloaded files */
     1211        if( deleteFiles )
     1212            tr_torrentDeleteLocalData( tor, gtr_file_trash_or_remove );
     1213
     1214        /* remove the torrent */
     1215        tr_torrent_set_remove_flag( gtor, TRUE );
     1216        g_warn_if_fail( G_OBJECT( gtor )->ref_count == 1 );
     1217        g_object_unref( G_OBJECT( gtor ) ); /* remove the last refcount */
    12261218    }
    12271219}
  • trunk/gtk/tr-core.h

    r10374 r10505  
    160160******/
    161161
    162 /* we've gotten notice from RPC that a torrent has been destroyed;
    163    update our gui accordingly */
    164 void  tr_core_torrent_destroyed( TrCore * self, int torrentId );
    165 
    166162/* remove a torrent */
    167 void  tr_core_remove_torrent( TrCore * self, TrTorrent * gtor, int deleteFiles );
     163void  tr_core_remove_torrent( TrCore * self, TrTorrent * gtor, gboolean deleteFiles );
     164void  tr_core_remove_torrent_from_id( TrCore * self, int id, gboolean deleteFiles );
    168165
    169166/* update the model with current torrent status */
  • trunk/gtk/tr-torrent.c

    r10451 r10505  
    8989    parent = g_type_class_peek( g_type_parent( TR_TORRENT_TYPE ) );
    9090    parent->dispose( o );
    91 }
    92 
    93 void
    94 tr_torrent_clear( TrTorrent * tor )
    95 {
    96     g_return_if_fail( tor );
    97     g_return_if_fail( tor->priv );
    98 
    99     tor->priv->handle = NULL;
    10091}
    10192
     
    210201        /* #1294: don't delete the source .torrent file if it's our internal copy */
    211202        if( !is_internal )
    212             tr_file_trash_or_remove( source );
     203            gtr_file_trash_or_remove( source );
    213204    }
    214205
     
    222213    if( !isDisposed( gtor ) )
    223214        gtor->priv->do_remove = do_remove;
    224 }
    225 
    226 void
    227 tr_torrent_delete_files( TrTorrent * gtor )
    228 {
    229     tr_torrentDeleteLocalData( tr_torrent_handle( gtor ), tr_file_trash_or_remove );
    230215}
    231216
  • trunk/gtk/tr-torrent.h

    r10451 r10505  
    5858GType          tr_torrent_get_type( void );
    5959
    60 void           tr_torrent_clear( TrTorrent * tor );
    61 
    6260tr_torrent *   tr_torrent_handle( TrTorrent *tor );
    6361
     
    6563
    6664const tr_info *tr_torrent_info( TrTorrent *tor );
    67 
    68 void           tr_torrent_delete_files( TrTorrent * tor );
    6965
    7066void           tr_torrent_open_folder( TrTorrent * tor );
  • trunk/gtk/util.c

    r10404 r10505  
    465465
    466466gpointer
    467 tr_object_ref_sink( gpointer object )
     467gtr_object_ref_sink( gpointer object )
    468468{
    469469#if GLIB_CHECK_VERSION( 2, 10, 0 )
     
    477477
    478478int
    479 tr_file_trash_or_remove( const char * filename )
     479gtr_file_trash_or_remove( const char * filename )
    480480{
    481481    if( filename && *filename )
  • trunk/gtk/util.h

    r10404 r10505  
    118118
    119119/* backwards-compatible wrapper around g_object_ref_sink() */
    120 gpointer tr_object_ref_sink( gpointer object );
     120gpointer gtr_object_ref_sink( gpointer object );
    121121
    122122/***
     
    163163
    164164/* move a file to the trashcan if GIO is available; otherwise, delete it */
    165 int tr_file_trash_or_remove( const char * filename );
     165int gtr_file_trash_or_remove( const char * filename );
    166166
    167167#endif /* GTR_UTIL_H */
Note: See TracChangeset for help on using the changeset viewer.