diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2013-04-03 17:26:02 -0700 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2013-04-03 17:26:02 -0700 |
commit | d9445f04b13c1d1523cd152cfb1d163702e66c14 (patch) | |
tree | c4ab9cca04433a1c6eaa2e3fff076b7cdda2565b /event.cpp | |
parent | 1543d02f96bdf96a067e96742577ea740dda4d89 (diff) |
Use the new input_common_add_callback mechanism to not execute callbacks while signals are blocked. Should fix https://github.com/fish-shell/fish-shell/issues/608
Diffstat (limited to 'event.cpp')
-rw-r--r-- | event.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
@@ -19,6 +19,7 @@ #include "wutil.h" #include "function.h" +#include "input_common.h" #include "proc.h" #include "parser.h" #include "common.h" @@ -441,6 +442,16 @@ static int event_is_killed(const event_t &e) return std::find(killme.begin(), killme.end(), &e) != killme.end(); } +/* Callback for firing (and then deleting) an event */ +static void fire_event_callback(void *arg) +{ + ASSERT_IS_MAIN_THREAD(); + assert(arg != NULL); + event_t *event = static_cast<event_t *>(arg); + event_fire(event); + delete event; +} + /** Perform the specified event. Since almost all event firings will not be matched by even a single event handler, we make sure to @@ -488,6 +499,14 @@ static void event_fire_internal(const event_t &event) if (fire.empty()) return; + if (signal_is_blocked()) + { + /* Fix for https://github.com/fish-shell/fish-shell/issues/608. Don't run event handlers while signals are blocked. */ + event_t *heap_event = new event_t(event); + input_common_add_callback(fire_event_callback, heap_event); + return; + } + /* Iterate over our list of matching events */ @@ -637,10 +656,10 @@ void event_fire_signal(int signal) } -void event_fire(event_t *event) +void event_fire(const event_t *event) { - if (event && (event->type == EVENT_SIGNAL)) + if (event && event->type == EVENT_SIGNAL) { event_fire_signal(event->param1.signal); } |