summaryrefslogtreecommitdiff
path: root/src/haikumenu.c
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2022-03-26 12:01:58 +0000
committerPo Lu <luangruo@yahoo.com>2022-03-26 12:01:58 +0000
commit0549adb4bb7c31c99f99bd295a7cb65b380b83f8 (patch)
tree5fe99dc088651ddb4d196b1763bda8d7a8ba9bd8 /src/haikumenu.c
parenta3ed1d2590c2acd041dfc9a783daa240fddfc11d (diff)
downloademacs-0549adb4bb7c31c99f99bd295a7cb65b380b83f8.tar.gz
emacs-0549adb4bb7c31c99f99bd295a7cb65b380b83f8.tar.bz2
emacs-0549adb4bb7c31c99f99bd295a7cb65b380b83f8.zip
Fix crash when timer signals or throws inside a popup menu on Haiku
* src/haikumenu.c (haiku_process_pending_signals_for_menu_1) (haiku_process_pending_signals_for_menu_2): New functions. (haiku_process_pending_signals_for_menu): Catch non local exits around `timer_check'.
Diffstat (limited to 'src/haikumenu.c')
-rw-r--r--src/haikumenu.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/haikumenu.c b/src/haikumenu.c
index 8da00ffcb05..4cee69826da 100644
--- a/src/haikumenu.c
+++ b/src/haikumenu.c
@@ -29,6 +29,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include "haiku_support.h"
static Lisp_Object *volatile menu_item_selection;
+static struct timespec menu_timer_timespec;
int popup_activated_p = 0;
@@ -340,12 +341,35 @@ haiku_menu_show_help (void *help, void *data)
show_help_echo (Qnil, Qnil, Qnil, Qnil);
}
+static Lisp_Object
+haiku_process_pending_signals_for_menu_1 (void *ptr)
+{
+ menu_timer_timespec = timer_check ();
+
+ return Qnil;
+}
+
+static Lisp_Object
+haiku_process_pending_signals_for_menu_2 (enum nonlocal_exit exit, Lisp_Object error)
+{
+ menu_timer_timespec.tv_sec = 0;
+ menu_timer_timespec.tv_nsec = -1;
+
+ return Qnil;
+}
+
static struct timespec
haiku_process_pending_signals_for_menu (void)
{
process_pending_signals ();
- return timer_check ();
+ /* The original idea was to let timers throw so that timeouts can
+ work correctly, but there's no way to pop down a BPopupMenu
+ that's currently popped up. */
+ internal_catch_all (haiku_process_pending_signals_for_menu_1, NULL,
+ haiku_process_pending_signals_for_menu_2);
+
+ return menu_timer_timespec;
}
Lisp_Object