Subject: bug#30800: 26.0.91; unknown crash on macos

From: Alan Third <[email-masked]>
Date: Sat, 24 Mar 2018 14:12:29 +0000

On Sat, Mar 24, 2018 at 11:49:43AM +0100, Charles A. Roelli wrote:
> > Date: Fri, 23 Mar 2018 19:52:10 +0000
> > From: Alan Third <[email-masked]>
> >
> > I would like to revert it if only simplify the code, but I don’t feel
> > that strongly. It may have been fixed in later releases of 10.10. It
> > would be nice if someone using 10.10 could check, but I don’t know who
> > could do that.
> 
> What would you like to check?  I have a partition with 10.10.

Hi Charles, thanks for offering to check this.

I’ve attached a patch for the emacs-26 branch that reverts
d9d383147219f8e6a90d4c177e1b454e19acfac9. It doesn’t revert cleanly,
hence the patch. You could try reverting it on master if you want, but
I suspect it will be harder to do.

Once that’s applied try the reproduction steps in

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=18757#41

Basically the code in question has at least one reproducible bug and
looks as though it should have several more that we haven’t seen yet,
and although we have a work‐around we’re wondering if we can just get
rid of it completely as it appears to have been a work‐around for a
bug introduced in macOS 10.10 and fixed some time later, hopefully
before 10.10 stopped getting fixes.
-- 
Alan Third
>From 0e7da51a70ab7ea0dace246919a575890a061908 Mon Sep 17 00:00:00 2001
From: Alan Third <[email-masked]>
Date: Sat, 24 Mar 2018 13:50:17 +0000
Subject: [PATCH] Revert "More flicker fixes for OSX, related to bug 18757."

This reverts commit d9d383147219f8e6a90d4c177e1b454e19acfac9.
---
 src/ChangeLog.13 |  2 +-
 src/nsfns.m      |  9 ++++++++-
 src/nsterm.h     |  6 +++---
 src/nsterm.m     | 29 +----------------------------
 4 files changed, 13 insertions(+), 33 deletions(-)

diff --git a/src/ChangeLog.13 b/src/ChangeLog.13
index 31e01306a0..eddf85a367 100644
--- a/src/ChangeLog.13
+++ b/src/ChangeLog.13
@@ -13,7 +13,7 @@
 	outside of this function (Bug#16737).
 	(set_property_change_object): New function.
 
-2015-04-03  Jan Djärv  <[email-masked]>
+2014-11-27  Eli Zaretskii  <[email-masked]>
 
 	* xterm.c (handle_one_xevent): Always redraw tool tips on
 	MapNotify.  Update tool tip frame sizes on ConfigureNotify.
diff --git a/src/nsfns.m b/src/nsfns.m
index 7f2f060dda..83b5fc9541 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -578,11 +578,18 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
 
           fstr = [NSString stringWithUTF8String: SSDATA (encoded_filename)];
           if (fstr == nil) fstr = @"";
+#ifdef NS_IMPL_COCOA
+          /* work around a bug observed on 10.3 and later where
+             setTitleWithRepresentedFilename does not clear out previous state
+             if given filename does not exist */
+          if (! [[NSFileManager defaultManager] fileExistsAtPath: fstr])
+            [[view window] setRepresentedFilename: @""];
+#endif
         }
       else
         fstr = @"";
 
-      ns_set_represented_filename (fstr, f);
+      [[view window] setRepresentedFilename: fstr];
       [[view window] setTitle: str];
       fset_name (f, name);
     }
diff --git a/src/nsterm.h b/src/nsterm.h
index 588b9fc644..2308e0a994 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -1230,11 +1230,11 @@ struct input_event;
 extern void ns_init_events (struct input_event *);
 extern void ns_finish_events (void);
 
+/* From nsterm.m, needed in nsfont.m. */
 #ifdef __OBJC__
-/* Needed in nsfns.m.  */
 extern void
-ns_set_represented_filename (NSString *fstr, struct frame *f);
-
+ns_draw_text_decoration (struct glyph_string *s, struct face *face,
+                         NSColor *defaultCol, CGFloat width, CGFloat x);
 #endif
 
 #ifdef NS_IMPL_GNUSTEP
diff --git a/src/nsterm.m b/src/nsterm.m
index 3d58cd5ec6..2530a86ab6 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -322,9 +322,6 @@ - (NSColor *)colorUsingDefaultColorSpace
   NULL, 0, 0
 };
 
-static NSString *represented_filename = nil;
-static struct frame *represented_frame = 0;
-
 #ifdef NS_IMPL_COCOA
 /*
  * State for pending menu activation:
@@ -442,13 +439,6 @@ - (NSColor *)colorUsingDefaultColorSpace
 
    ========================================================================== */
 
-void
-ns_set_represented_filename (NSString *fstr, struct frame *f)
-{
-  represented_filename = [fstr retain];
-  represented_frame = f;
-}
-
 void
 ns_init_events (struct input_event *ev)
 {
@@ -3323,7 +3313,7 @@ Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.

-static void
+void
 ns_draw_text_decoration (struct glyph_string *s, struct face *face,
                          NSColor *defaultCol, CGFloat width, CGFloat x)
 /* --------------------------------------------------------------------------
@@ -5443,23 +5433,6 @@ - (void)sendEvent: (NSEvent *)theEvent
     }
 #endif
 
-  if (represented_filename != nil && represented_frame)
-    {
-      NSString *fstr = represented_filename;
-      NSView *view = FRAME_NS_VIEW (represented_frame);
-#ifdef NS_IMPL_COCOA
-      /* work around a bug observed on 10.3 and later where
-         setTitleWithRepresentedFilename does not clear out previous state
-         if given filename does not exist */
-      if (! [[NSFileManager defaultManager] fileExistsAtPath: fstr])
-        [[view window] setRepresentedFilename: @""];
-#endif
-      [[view window] setRepresentedFilename: fstr];
-      [represented_filename release];
-      represented_filename = nil;
-      represented_frame = NULL;
-    }
-
   if (type == NSEventTypeApplicationDefined)
     {
       switch ([theEvent data2])
-- 
2.16.1