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-08 09:49:03 +0100
commitc1363a04bb201f8444072903a89a77f8203a9e3a (patch)
tree7c15f948f9ddffb87bb15330ccb25bb4769e5fcc /src
parent7d6855c9ab6e0d5128d81b4bcb685799a3c316e9 (diff)
downloademacs-c1363a04bb201f8444072903a89a77f8203a9e3a.tar.gz
emacs-c1363a04bb201f8444072903a89a77f8203a9e3a.tar.bz2
emacs-c1363a04bb201f8444072903a89a77f8203a9e3a.zip
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. (cherry picked from commit 3adc1e7f37901235bda83ea65a90644b7b0a8dbf)
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 37462cf49e2..c26528e0154 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7938,6 +7938,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)
@@ -9182,11 +9186,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]];