From: Gerd Moellmann Date: Tue, 21 Jun 2022 13:49:44 +0000 (+0200) Subject: Prevent GC of window referenced from EmacsScroller X-Git-Tag: emacs-29.0.90~1447^2~1535 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5f1bd872478927ad4bc635502e74628d39885286;p=emacs.git Prevent GC of window referenced from EmacsScroller * src/nsterm.m (EmacsScroller.mark, mark_nsterm): New functions. * src/nsterm.h (EmacsScroller.mark, mark_nsterm): Declare. * src/alloc.c (garbage_collect) [MAVE_NS]: Call mark_nsterm. (Bug#56095) --- diff --git a/src/alloc.c b/src/alloc.c index 55e18ecd77e..f115a3cebaa 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -6204,6 +6204,10 @@ garbage_collect (void) mark_xterm (); #endif +#ifdef HAVE_NS + mark_nsterm (); +#endif + /* Everything is now marked, except for the data in font caches, undo lists, and finalizers. The first two are compacted by removing an items which aren't reachable otherwise. */ diff --git a/src/nsterm.h b/src/nsterm.h index c4fdc7054f7..7a097b32489 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -724,6 +724,7 @@ enum ns_return_frame_mode int em_whole; } +- (void) mark; - (instancetype) initFrame: (NSRect )r window: (Lisp_Object)win; - (void)setFrame: (NSRect)r; @@ -1373,4 +1374,7 @@ enum NSWindowTabbingMode #define NSBezelStyleRounded NSRoundedBezelStyle #define NSButtonTypeMomentaryPushIn NSMomentaryPushInButton #endif + +extern void mark_nsterm (void); + #endif /* HAVE_NS */ diff --git a/src/nsterm.m b/src/nsterm.m index 891d52ea3f0..ae44f808459 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -9924,6 +9924,16 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c) return ret; } +- (void) mark +{ + if (window) + { + Lisp_Object win; + XSETWINDOW (win, window); + mark_object (win); + } +} + - (void)resetCursorRects { @@ -10665,6 +10675,26 @@ ns_xlfd_to_fontname (const char *xlfd) return ret; } +void +mark_nsterm (void) +{ + NSTRACE ("mark_nsterm"); + Lisp_Object tail, frame; + FOR_EACH_FRAME (tail, frame) + { + struct frame *f = XFRAME (frame); + if (FRAME_NS_P (f)) + { + NSArray *subviews = [[FRAME_NS_VIEW (f) superview] subviews]; + for (int i = [subviews count] - 1; i >= 0; --i) + { + id scroller = [subviews objectAtIndex: i]; + if ([scroller isKindOfClass: [EmacsScroller class]]) + [scroller mark]; + } + } + } +} void syms_of_nsterm (void)