Subject: bug#38031: 26.3; Trying to invoke the macOS File Open window causes Emacs to crash on macOS Catalina

From: Alan Third <[email-masked]>
Date: Tue, 14 Jan 2020 21:39:30 +0000

On Fri, Nov 08, 2019 at 06:17:30PM -0500, Michael Dixon wrote:
> I tried a whole variety of distributions. I tried the brew cask
> (26.3), the emacs-plus formula used for spacemacs (26.3), the
> prebuilt Emacs for Mac OSX (26.3), homebrew-emacs-head (another brew
> formula, both 26.3 and 27.0.50), and now the one I just built (I
> tried both with and without your patch, both 27.0.5.0, since that’s
> what I get with master).

Can you try the attached patch. It *completely* removes the
EmacsOpenPanel and EmacsSavePanel classes. It might do the trick.
-- 
Alan Third
>From b631a258e1171c377e193e010ceab42ea1958788 Mon Sep 17 00:00:00 2001
From: Alan Third <[email-masked]>
Date: Tue, 14 Jan 2020 21:36:14 +0000
Subject: [PATCH] Remove EmacsOpenPanel and EmacsSavePanel (bug#38031)

---
 src/nsfns.m  | 25 +------------------------
 src/nsterm.h | 16 ----------------
 2 files changed, 1 insertion(+), 40 deletions(-)

diff --git a/src/nsfns.m b/src/nsfns.m
index 42bd88eeb4..3be4e390e0 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -1634,7 +1634,7 @@ Frames are listed from topmost (first) to bottommost (last).  */)
     dirS = [dirS stringByExpandingTildeInPath];
 
   panel = isSave ?
-    (id)[EmacsSavePanel savePanel] : (id)[EmacsOpenPanel openPanel];
+    (id)[NSSavePanel savePanel] : (id)[NSOpenPanel openPanel];
 
   [panel setTitle: promptS];
 
@@ -3089,29 +3089,6 @@ The position is returned as a cons cell (X . Y) of the
   return ret;
 }
 
-@implementation EmacsSavePanel
-- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
-{
-  BOOL ret = handlePanelKeys (self, theEvent);
-  if (! ret)
-    ret = [super performKeyEquivalent:theEvent];
-  return ret;
-}
-@end
-
-
-@implementation EmacsOpenPanel
-- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
-{
-  // NSOpenPanel inherits NSSavePanel, so passing self is OK.
-  BOOL ret = handlePanelKeys (self, theEvent);
-  if (! ret)
-    ret = [super performKeyEquivalent:theEvent];
-  return ret;
-}
-@end
-
-
 @implementation EmacsFileDelegate
 /* --------------------------------------------------------------------------
    Delegate methods for Open/Save panels
diff --git a/src/nsterm.h b/src/nsterm.h
index 8baa65f578..7d12ecc243 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -597,22 +597,6 @@ #define NSTRACE_UNSILENCE()
 @end

-/* ==========================================================================
-
-   File open/save panels
-   This and next override methods to handle keyboard input in panels.
-
-   ========================================================================== */
-
-@interface EmacsSavePanel : NSSavePanel
-{
-}
-@end
-@interface EmacsOpenPanel : NSOpenPanel
-{
-}
-@end
-
 @interface EmacsFileDelegate : NSObject
 {
 }
-- 
2.24.0