summaryrefslogtreecommitdiff
path: root/src/timers.c
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-08-28 23:09:38 +0200
committerDaniel Friesel <derf@finalrewind.org>2020-08-28 23:09:38 +0200
commite43916d7d1409e4031d56ee1704456bef55eeb1d (patch)
tree839a5a27874f5cdd77104f4b3bb4da7a84aca788 /src/timers.c
parentbfea10205a9fd4cb02cd6c94d2d94baaefaed278 (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.c33
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;