summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlan Third <alan@idiocy.org>2023-04-27 20:08:23 +0100
committerAlan Third <alan@idiocy.org>2023-05-07 23:52:46 +0100
commit3adc1e7f37901235bda83ea65a90644b7b0a8dbf (patch)
treea476d64523d63f2c82f746cf0d45befa34f0e5e4 /src
parentd5ab8b6f2459b0c0111edc1ac7da20e1452c1f33 (diff)
downloademacs-3adc1e7f37901235bda83ea65a90644b7b0a8dbf.tar.gz
Fix crash when creating a child frame in NS (bug#63107)
* src/nsterm.m ([EmacsView initFrameFromEmacs:]): Have a second go at creating the toolbar. ([EmacsWindow createToolbar:]): If there is already a toolbar or the EmacsView's layer is not an EmacsLayer, then do nothing.
Diffstat (limited to 'src')
-rw-r--r--src/nsterm.m13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/nsterm.m b/src/nsterm.m
index ecbf80ff72d..b9e3cbf81a1 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7930,6 +7930,10 @@ ns_in_echo_area (void)
[self setLayerContentsRedrawPolicy:
NSViewLayerContentsRedrawOnSetNeedsDisplay];
[self setLayerContentsPlacement:NSViewLayerContentsPlacementTopLeft];
+
+ /* initWithEmacsFrame can't create the toolbar before the layer is
+ set, so have another go at creating the toolbar here. */
+ [(EmacsWindow*)[self window] createToolbar:f];
#endif
if (ns_drag_types)
@@ -9174,11 +9178,18 @@ ns_in_echo_area (void)
- (void)createToolbar: (struct frame *)f
{
- if (FRAME_UNDECORATED (f) || !FRAME_EXTERNAL_TOOL_BAR (f))
+ if (FRAME_UNDECORATED (f) || !FRAME_EXTERNAL_TOOL_BAR (f) || [self toolbar] != nil)
return;
EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f);
+#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
+ /* If the view's layer isn't an EmacsLayer then we can't create the
+ toolbar yet. */
+ if (! [[view layer] isKindOfClass:[EmacsLayer class]])
+ return;
+#endif
+
EmacsToolbar *toolbar = [[EmacsToolbar alloc]
initForView:view
withIdentifier:[NSString stringWithFormat:@"%p", f]];