[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/ns/refactor 982ecc5 1/3: Prevent NS run loop from running recurs
From: |
Alan Third |
Subject: |
scratch/ns/refactor 982ecc5 1/3: Prevent NS run loop from running recursively |
Date: |
Wed, 23 Jun 2021 12:05:13 -0400 (EDT) |
branch: scratch/ns/refactor
commit 982ecc5aa9d7741aa6b3995d646131e7b521b53c
Author: Alan Third <alan@idiocy.org>
Commit: Alan Third <alan@idiocy.org>
Prevent NS run loop from running recursively
* src/nsterm.m (ns_read_socket):
(ns_select): Return if already inside the run loop.
---
src/nsterm.m | 23 +++++++----------------
1 file changed, 7 insertions(+), 16 deletions(-)
diff --git a/src/nsterm.m b/src/nsterm.m
index b5bfb24..3bfc4b4 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -4446,7 +4446,7 @@ ns_read_socket (struct terminal *terminal, struct
input_event *hold_quit)
return i;
}
- if ([NSThread isMainThread])
+ if ([NSThread isMainThread] && ![NSApp isRunning])
{
block_input ();
n_emacs_events_pending = 0;
@@ -4524,6 +4524,10 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds,
return -1;
}
+ /* If we're already inside the run loop just return. */
+ if ([NSApp isRunning])
+ return -1;
+
eassert (nfds <= FD_SETSIZE);
for (k = 0; k < nfds; k++)
{
@@ -4542,22 +4546,9 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds,
thread_select(pselect, 0, NULL, NULL, NULL, &t, sigmask);
}
- /* FIXME: This draining of outerpool causes a crash when a buffer
- running over tramp is displayed and the user tries to use the
- menus. I believe some other autorelease pool's lifetime
- straddles this call causing a violation of autorelease pool
- nesting. There's no good reason to keep these here since the
- pool will be drained some other time anyway, but removing them
- leaves the menus sometimes not opening until the user moves their
- mouse pointer, but that's better than a crash.
-
- There must be something about running external processes like
- tramp that interferes with the modal menu code.
- See bugs 24472, 37557, 37922. */
-
- // [outerpool release];
- // outerpool = [[NSAutoreleasePool alloc] init];
+ [outerpool release];
+ outerpool = [[NSAutoreleasePool alloc] init];
send_appdefined = YES;