diff options
author | Yorhel <git@yorhel.nl> | 2013-10-28 21:20:56 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2013-10-28 21:20:56 +0100 |
commit | 80afb67567f6f2fb51b7f28bfb614aa9d861b932 (patch) | |
tree | b3ab51ae6a0e0c6b3140100f3adc033bd71f062d | |
parent | 43de0c586af07c1a2caa7e0fc98796b660d3a75b (diff) |
dl.c: Don't open file list before removing it from the dl queue
Otherwise the background thread may attemt to load the file list before
the download queue code has moved and finalized all file operations.
-rw-r--r-- | src/dl.c | 19 |
1 files changed, 12 insertions, 7 deletions
@@ -836,17 +836,22 @@ void dl_queue_rmuser(guint64 uid, char *tth) { void dl_finished(dl_t *dl) { g_debug("dl: download of `%s' finished, removing from queue", dl->dest); - // open the file list - if(dl->islist && dl->prio != DLP_ERR) { - g_return_if_fail(dl->u->len == 1); + gboolean opentab = dl->islist && dl->prio != DLP_ERR; + guint64 uid = opentab ? ((dl_user_dl_t *)g_sequence_get(g_ptr_array_index(dl->u, 0)))->u->uid : 0; + const char *flsel = dl->flsel; + ui_tab_t *flpar = dl->flpar; + gboolean flopen = dl->flopen; + gboolean flmatch = dl->flmatch; + + dl_queue_rm(dl); + + // open the file list (after dl_queue_rm(), since the file list should be truncated/closed first) + if(opentab) { // Ugly hack: make sure to not select the browse tab, if one is opened GList *cur = ui_tab_cur; - uit_fl_queue(((dl_user_dl_t *)g_sequence_get(g_ptr_array_index(dl->u, 0)))->u->uid, - FALSE, dl->flsel, dl->flpar, dl->flopen, dl->flmatch); + uit_fl_queue(uid, FALSE, flsel, flpar, flopen, flmatch); ui_tab_cur = cur; } - - dl_queue_rm(dl); } |