[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-28 f02944f5a1: Prevent GC of window referenced from EmacsScroller
From: |
Eli Zaretskii |
Subject: |
emacs-28 f02944f5a1: Prevent GC of window referenced from EmacsScroller |
Date: |
Tue, 19 Jul 2022 09:04:57 -0400 (EDT) |
branch: emacs-28
commit f02944f5a1ad18ceed4ae40a0fbbdddc981b4893
Author: Gerd Moellmann <gerd.moellmann@gmail.com>
Commit: Eli Zaretskii <eliz@gnu.org>
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)
(cherry picked from commit 5f1bd872478927ad4bc635502e74628d39885286)
---
src/alloc.c | 5 +++++
src/nsterm.h | 4 ++++
src/nsterm.m | 30 ++++++++++++++++++++++++++++++
3 files changed, 39 insertions(+)
diff --git a/src/alloc.c b/src/alloc.c
index 5ad8097394..1fe5b8f3fb 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -6145,6 +6145,11 @@ garbage_collect (void)
mark_fringe_data ();
#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 911539844a..4cfed10982 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -683,6 +683,7 @@ typedef id instancetype;
int em_whole;
}
+- (void) mark;
- (instancetype) initFrame: (NSRect )r window: (Lisp_Object)win;
- (void)setFrame: (NSRect)r;
@@ -1347,4 +1348,7 @@ enum NSWindowTabbingMode
#define NSControlStateValueOff NSOffState
#define NSBezelStyleRounded NSRoundedBezelStyle
#endif
+
+extern void mark_nsterm (void);
+
#endif /* HAVE_NS */
diff --git a/src/nsterm.m b/src/nsterm.m
index 40540c47be..1643ba5427 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -9039,6 +9039,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
{
@@ -9780,6 +9790,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)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-28 f02944f5a1: Prevent GC of window referenced from EmacsScroller,
Eli Zaretskii <=