diff options
author | Daniel Friesel <derf@finalrewind.org> | 2020-08-28 22:46:58 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2020-08-28 22:46:58 +0200 |
commit | bfea10205a9fd4cb02cd6c94d2d94baaefaed278 (patch) | |
tree | 069ce9cb5bcaf01cebd8f499cc850110c8ea06f9 /src | |
parent | 5c59089f12b7b07d46626ecdccf0cfcd4e875e26 (diff) |
Fix segmentation fault when combining --multiwindow and --reload
Introduced in 3fa39154f089a6fadc1a14eb6b206e2d2875be71
Diffstat (limited to 'src')
-rw-r--r-- | src/slideshow.c | 79 |
1 files changed, 43 insertions, 36 deletions
diff --git a/src/slideshow.c b/src/slideshow.c index 03e8e06..07a1e94 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -135,47 +135,54 @@ void cb_reload_timer(void *data) winwidget w = (winwidget) data; - /* save the current filename for refinding it in new list */ - current_filename = estrdup(FEH_FILE(current_file->data)->filename); + /* + * multi-window mode has no concept of a "current file" and + * dynamically adding/removing windows is not implemented at the moment. + * So don't reload filelists in multi-window mode. + */ + if (current_file != NULL) { + /* save the current filename for refinding it in new list */ + current_filename = estrdup(FEH_FILE(current_file->data)->filename); - for (l = filelist; l; l = l->next) { - feh_file_free(l->data); - l->data = NULL; - } - gib_list_free_and_data(filelist); - filelist = NULL; - filelist_len = 0; - current_file = NULL; - - /* rebuild filelist from original_file_items */ - if (gib_list_length(original_file_items) > 0) - for (l = gib_list_last(original_file_items); l; l = l->prev) - add_file_to_filelist_recursively(l->data, FILELIST_FIRST); - else if (!opt.filelistfile && !opt.bgmode) - add_file_to_filelist_recursively(".", FILELIST_FIRST); - - if (opt.filelistfile) { - filelist = gib_list_cat(filelist, feh_read_filelist(opt.filelistfile)); - } - - if (!(filelist_len = gib_list_length(filelist))) { - eprintf("No files found to reload."); - } + for (l = filelist; l; l = l->next) { + feh_file_free(l->data); + l->data = NULL; + } + gib_list_free_and_data(filelist); + filelist = NULL; + filelist_len = 0; + current_file = NULL; + + /* rebuild filelist from original_file_items */ + if (gib_list_length(original_file_items) > 0) + for (l = gib_list_last(original_file_items); l; l = l->prev) + add_file_to_filelist_recursively(l->data, FILELIST_FIRST); + else if (!opt.filelistfile && !opt.bgmode) + add_file_to_filelist_recursively(".", FILELIST_FIRST); + + if (opt.filelistfile) { + filelist = gib_list_cat(filelist, feh_read_filelist(opt.filelistfile)); + } + + if (!(filelist_len = gib_list_length(filelist))) { + eprintf("No files found to reload."); + } - feh_prepare_filelist(); + feh_prepare_filelist(); - /* find the previously current file */ - for (l = filelist; l; l = l->next) - if (strcmp(FEH_FILE(l->data)->filename, current_filename) == 0) { - current_file = l; - break; - } + /* find the previously current file */ + for (l = filelist; l; l = l->next) + if (strcmp(FEH_FILE(l->data)->filename, current_filename) == 0) { + current_file = l; + break; + } - free(current_filename); + free(current_filename); - if (!current_file) - current_file = filelist; - w->file = current_file; + if (!current_file) + current_file = filelist; + w->file = current_file; + } feh_reload_image(w, 1, 0); feh_add_unique_timer(cb_reload_timer, w, opt.reload); |