From f90e3ebd13de8169ada56274f3abaa1ea8dc6d05 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Dj=C3=A4rv?= Date: Sun, 11 Aug 2013 17:34:26 +0200 Subject: [PATCH] Fix crash on OSX >= 10.7. * nsmenu.m (ns_update_menubar): Call fillWithWidgetValue:frame: (initWithTitle:): Initialize frame to 0. (fillWithWidgetValue:): Call fillWithWidgetValue:frame. (fillWithWidgetValue:frame:): Renamed from fillWithWidgetValue:setDelegate, call initWithTile:frame: if f. * nsterm.h (EmacsMenu): fillWithWidgetValue:setDelegate renamed to fillWithWidgetValue:frame: --- src/ChangeLog | 9 +++++++++ src/nsmenu.m | 17 ++++++++++------- src/nsterm.h | 2 +- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index f8aea1dc83b..fce45d37447 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,14 @@ 2013-08-11 Jan Djärv + * nsmenu.m (ns_update_menubar): Call fillWithWidgetValue:frame: + (initWithTitle:): Initialize frame to 0. + (fillWithWidgetValue:): Call fillWithWidgetValue:frame. + (fillWithWidgetValue:frame:): Renamed from + fillWithWidgetValue:setDelegate, call initWithTile:frame: if f. + + * nsterm.h (EmacsMenu): fillWithWidgetValue:setDelegate renamed to + fillWithWidgetValue:frame: + * nsfns.m (Fns_convert_utf8_nfd_to_nfc): Allocate and release pool to remove memory leak warnings. diff --git a/src/nsmenu.m b/src/nsmenu.m index 1ae2a34ab92..2850f0ed97d 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -366,7 +366,7 @@ ns_update_menubar (struct frame *f, bool deep_p, EmacsMenu *submenu) } else { - [menu fillWithWidgetValue: first_wv->contents setDelegate:YES]; + [menu fillWithWidgetValue: first_wv->contents frame: f]; } } @@ -527,6 +527,7 @@ x_activate_menubar (struct frame *f) /* override designated initializer */ - initWithTitle: (NSString *)title { + frame = 0; if ((self = [super initWithTitle: title])) [self setAutoenablesItems: NO]; return self; @@ -725,10 +726,10 @@ extern NSString *NSMenuDidBeginTrackingNotification; - (void)fillWithWidgetValue: (void *)wvptr { - [self fillWithWidgetValue: wvptr setDelegate:NO]; + [self fillWithWidgetValue: wvptr frame:nil]; } -- (void)fillWithWidgetValue: (void *)wvptr setDelegate: (BOOL)set +- (void)fillWithWidgetValue: (void *)wvptr frame: (struct frame *)f { widget_value *wv = (widget_value *)wvptr; @@ -743,11 +744,13 @@ extern NSString *NSMenuDidBeginTrackingNotification; if (wv->contents) { - EmacsMenu *submenu = [[EmacsMenu alloc] initWithTitle: [item title]]; + EmacsMenu *submenu; + + if (f) + submenu = [[EmacsMenu alloc] initWithTitle: [item title] frame:f]; + else + submenu = [[EmacsMenu alloc] initWithTitle: [item title]]; -#ifdef NS_IMPL_COCOA - if (set) [submenu setDelegate: submenu]; -#endif [self setSubmenu: submenu forItem: item]; [submenu fillWithWidgetValue: wv->contents]; [submenu release]; diff --git a/src/nsterm.h b/src/nsterm.h index cf8e26d14a6..7843f369d24 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -196,7 +196,7 @@ typedef float EmacsCGFloat; - (NSString *)parseKeyEquiv: (const char *)key; - (NSMenuItem *)addItemWithWidgetValue: (void *)wvptr; - (void)fillWithWidgetValue: (void *)wvptr; -- (void)fillWithWidgetValue: (void *)wvptr setDelegate: (BOOL)set; +- (void)fillWithWidgetValue: (void *)wvptr frame: (struct frame *)f; - (EmacsMenu *)addSubmenuWithTitle: (const char *)title forFrame: (struct frame *)f; - (void) clear; - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f -- 2.39.2