diff options
author | Daniel Friesel <derf@finalrewind.org> | 2020-08-28 23:09:38 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2020-08-28 23:09:38 +0200 |
commit | e43916d7d1409e4031d56ee1704456bef55eeb1d (patch) | |
tree | 839a5a27874f5cdd77104f4b3bb4da7a84aca788 /src/timers.c | |
parent | bfea10205a9fd4cb02cd6c94d2d94baaefaed278 (diff) |
Fix segfault when closing a window in multi-window reload mode
Issue:
* start feh --multiwindow --reload 5
* close a window with "x"
* wait up to 5 seconds
* segfault
The issue was caused by the closed window's reload timer still being active
even after the winwidget was free'd.
Diffstat (limited to 'src/timers.c')
-rw-r--r-- | src/timers.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/timers.c b/src/timers.c index 4bdd64e..b2cdbc7 100644 --- a/src/timers.c +++ b/src/timers.c @@ -58,7 +58,37 @@ double feh_get_time(void) return((double) timev.tv_sec + (((double) timev.tv_usec) / 1000000)); } -void feh_remove_timer(char *name) +void feh_remove_timer_by_data(void *data) +{ + fehtimer ft, ptr, pptr; + + D(("removing timer for %p\n", data)); + pptr = NULL; + ptr = first_timer; + while (ptr) { + D(("Stepping through event list\n")); + ft = ptr; + if (ft->data == data) { + D(("Found it. Removing\n")); + if (pptr) + pptr->next = ft->next; + else + first_timer = ft->next; + if (ft->next) + ft->next->in += ft->in; + if (ft->name) + free(ft->name); + if (ft) + free(ft); + return; + } + pptr = ptr; + ptr = ptr->next; + } + return; +} + +static void feh_remove_timer(char *name) { fehtimer ft, ptr, pptr; @@ -88,6 +118,7 @@ void feh_remove_timer(char *name) return; } + void feh_add_timer(void (*func) (void *data), void *data, double in, char *name) { fehtimer ft, ptr, pptr; |