Mercurial > dwindows
diff ios/dw.m @ 2616:a256caa5034c
iOS: Fix a context menu related crash by removing autorelease from DWMenuItem.
Something is stil not quite right here, the popup menu lingering from a long
touch on another DWRender and causing the popup to show on a DWRender that
doesn't respond to the popup. However the crash was critical and the
current misbehavior is not. Also check the pointer passed to dw_menu_popup().
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 23 Jul 2021 19:26:01 +0000 |
parents | ac51cbdcfbe5 |
children | 07c504257e42 |
line wrap: on
line diff
--- a/ios/dw.m Fri Jul 23 15:28:42 2021 +0000 +++ b/ios/dw.m Fri Jul 23 19:26:01 2021 +0000 @@ -7661,12 +7661,14 @@ */ void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) { - DWMenu *thismenu = (DWMenu *)*menu; - id object = parent; - DWWindow *window = [object isMemberOfClass:[DWWindow class]] ? object : (DWWindow *)[object window]; - [thismenu autorelease]; - [window setPopupMenu:thismenu]; - *menu = nil; + if(menu) + { + DWMenu *thismenu = (DWMenu *)*menu; + id object = parent; + DWWindow *window = [object isMemberOfClass:[DWWindow class]] ? object : (DWWindow *)[object window]; + [window setPopupMenu:thismenu]; + *menu = nil; + } } char _dw_removetilde(char *dest, const char *src) @@ -7720,10 +7722,10 @@ nstr = [NSString stringWithUTF8String:newtitle]; free(newtitle); - item = [[DWMenuItem actionWithTitle:nstr image:nil identifier:nil + item = [DWMenuItem actionWithTitle:nstr image:nil identifier:nil handler:^(__kindof UIAction * _Nonnull action) { [DWObj menuHandler:item]; - }] autorelease]; + }]; /* Don't set the tag if the ID is 0 or -1 */ if(itemid != DW_MENU_AUTO && itemid != DW_MENU_POPUP) [item setTag:itemid];