aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Third2023-09-08 19:33:06 +0100
committerAlan Third2023-09-11 17:22:01 +0100
commitc19a2dff5ab0d16a1aed62c68baf1d23dd1649b5 (patch)
tree8d5a557d9fa0320948446a679097510055e10380
parentfa24bbb631fce7c5110dc322264224842cbb28d8 (diff)
downloademacs-c19a2dff5ab0d16a1aed62c68baf1d23dd1649b5.tar.gz
emacs-c19a2dff5ab0d16a1aed62c68baf1d23dd1649b5.zip
Fix crash on child frame creation (bug#65817)
* src/nsterm.m ([EmacsView initFrameFromEmacs:]): Reorder the way the frame and layers are created. ([EmacsView makeBackingLayer]): Change to the newly renamed method below. ([EmacsLayer initWithColorSpace:doubleBuffered:]): ([EmacsLayer initWithDoubleBuffered:]): Rename the method and remove the colorspace argument as it's no longer able to be set on initial creation. * src/nsterm.h: Use new method prototype.
-rw-r--r--src/nsterm.h2
-rw-r--r--src/nsterm.m27
2 files changed, 16 insertions, 13 deletions
diff --git a/src/nsterm.h b/src/nsterm.h
index 8d6c58290cc..cb162039ad8 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -748,7 +748,7 @@ enum ns_return_frame_mode
748 CGContextRef context; 748 CGContextRef context;
749 bool doubleBuffered; 749 bool doubleBuffered;
750} 750}
751- (id) initWithColorSpace: (CGColorSpaceRef)cs doubleBuffered: (bool)db; 751- (id) initWithDoubleBuffered: (bool)db;
752- (void) setColorSpace: (CGColorSpaceRef)cs; 752- (void) setColorSpace: (CGColorSpaceRef)cs;
753- (void) setDoubleBuffered: (bool)db; 753- (void) setDoubleBuffered: (bool)db;
754- (CGContextRef) getContext; 754- (CGContextRef) getContext;
diff --git a/src/nsterm.m b/src/nsterm.m
index 28502ad1a2a..c0b5e1b898f 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7921,8 +7921,6 @@ ns_in_echo_area (void)
7921 maximizing_resize = NO; 7921 maximizing_resize = NO;
7922#endif 7922#endif
7923 7923
7924 [[EmacsWindow alloc] initWithEmacsFrame:f];
7925
7926#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 7924#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
7927 /* These settings mean AppKit will retain the contents of the frame 7925 /* These settings mean AppKit will retain the contents of the frame
7928 on resize. Unfortunately it also means the frame will not be 7926 on resize. Unfortunately it also means the frame will not be
@@ -7933,9 +7931,16 @@ ns_in_echo_area (void)
7933 NSViewLayerContentsRedrawOnSetNeedsDisplay]; 7931 NSViewLayerContentsRedrawOnSetNeedsDisplay];
7934 [self setLayerContentsPlacement:NSViewLayerContentsPlacementTopLeft]; 7932 [self setLayerContentsPlacement:NSViewLayerContentsPlacementTopLeft];
7935 7933
7936 /* initWithEmacsFrame can't create the toolbar before the layer is 7934 [[EmacsWindow alloc] initWithEmacsFrame:f];
7937 set, so have another go at creating the toolbar here. */ 7935
7938 [(EmacsWindow*)[self window] createToolbar:f]; 7936 /* Now the NSWindow has been created, we can finish up configuring
7937 the layer. */
7938 [(EmacsLayer *)[self layer] setColorSpace:
7939 [[[self window] colorSpace] CGColorSpace]];
7940 [(EmacsLayer *)[self layer] setContentsScale:
7941 [[self window] backingScaleFactor]];
7942#else
7943 [[EmacsWindow alloc] initWithEmacsFrame:f];
7939#endif 7944#endif
7940 7945
7941 if (ns_drag_types) 7946 if (ns_drag_types)
@@ -8606,10 +8611,9 @@ ns_in_echo_area (void)
8606- (CALayer *)makeBackingLayer 8611- (CALayer *)makeBackingLayer
8607{ 8612{
8608 EmacsLayer *l = [[EmacsLayer alloc] 8613 EmacsLayer *l = [[EmacsLayer alloc]
8609 initWithColorSpace:[[[self window] colorSpace] CGColorSpace] 8614 initWithDoubleBuffered:FRAME_DOUBLE_BUFFERED (emacsframe)];
8610 doubleBuffered:FRAME_DOUBLE_BUFFERED (emacsframe)]; 8615
8611 [l setDelegate:(id)self]; 8616 [l setDelegate:(id)self];
8612 [l setContentsScale:[[self window] backingScaleFactor]];
8613 8617
8614 return l; 8618 return l;
8615} 8619}
@@ -10437,15 +10441,14 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c)
10437 cache. If no free surfaces are found in the cache then a new one 10441 cache. If no free surfaces are found in the cache then a new one
10438 is created. */ 10442 is created. */
10439 10443
10440- (id) initWithColorSpace: (CGColorSpaceRef)cs 10444- (id) initWithDoubleBuffered: (bool)db
10441 doubleBuffered: (bool)db
10442{ 10445{
10443 NSTRACE ("[EmacsLayer initWithColorSpace:doubleBuffered:]"); 10446 NSTRACE ("[EmacsLayer initWithDoubleBuffered:]");
10444 10447
10445 self = [super init]; 10448 self = [super init];
10446 if (self) 10449 if (self)
10447 { 10450 {
10448 [self setColorSpace:cs]; 10451 [self setColorSpace:nil];
10449 [self setDoubleBuffered:db]; 10452 [self setDoubleBuffered:db];
10450 cache = [[NSMutableArray arrayWithCapacity:(doubleBuffered ? 2 : 1)] retain]; 10453 cache = [[NSMutableArray arrayWithCapacity:(doubleBuffered ? 2 : 1)] retain];
10451 } 10454 }