Changeset 269 for trunk/gtk/tr_backend.c


Ignore:
Timestamp:
May 31, 2006, 11:20:59 PM (16 years ago)
Author:
joshe
Message:

Wait and try to send a stopped event when removing a torrent.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/tr_backend.c

    r261 r269  
    202202tr_backend_save_state(TrBackend *back, char **errstr) {
    203203  benc_val_t state;
    204   int ii;
    205   GList *jj;
     204  GList *ii;
    206205
    207206  TR_IS_BACKEND(back);
     
    209208  bzero(&state, sizeof(state));
    210209  state.type = TYPE_LIST;
    211   state.val.l.alloc = state.val.l.count = g_list_length(back->torrents);
     210  state.val.l.alloc = g_list_length(back->torrents);
    212211  state.val.l.vals = g_new0(benc_val_t, state.val.l.alloc);
    213212
    214   for(ii = 0, jj = back->torrents; NULL != jj; ii++, jj = jj->next)
    215     tr_torrent_get_state(jj->data, state.val.l.vals + ii);
     213  for(ii = back->torrents; NULL != ii; ii = ii->next) {
     214    tr_torrent_get_state(ii->data, state.val.l.vals + state.val.l.count);
     215    if(0 != state.val.l.vals[state.val.l.count].type)
     216      state.val.l.count++;
     217  }
    216218
    217219  cf_savestate(&state, errstr);
     
    269271
    270272  for(ii = back->torrents; NULL != ii; ii = ii->next)
    271     if(TR_STATUS_ACTIVE & tr_torrent_stat(ii->data)->status)
    272       tr_torrentStop(tr_torrent_handle(ii->data));
     273    tr_torrent_stop_politely(ii->data);
    273274}
    274275
    275276gboolean
    276277tr_backend_torrents_stopped(TrBackend *back) {
    277   GList *ii;
    278 
    279   TR_IS_BACKEND(back);
    280 
    281   for(ii = back->torrents; NULL != ii; ii = ii->next)
    282     if(TR_STATUS_ACTIVE & tr_torrent_stat(ii->data)->status)
    283       return FALSE;
    284 
    285   return TRUE;
    286 }
     278  GList *ii, *list;
     279  gboolean ret = TRUE;
     280
     281  TR_IS_BACKEND(back);
     282
     283  list = g_list_copy(back->torrents);
     284  for(ii = list; NULL != ii; ii = ii->next)
     285    if(!(TR_STATUS_PAUSE & tr_torrent_stat_polite(ii->data)->status))
     286      ret = FALSE;
     287  g_list_free(list);
     288
     289  return ret;
     290}
Note: See TracChangeset for help on using the changeset viewer.