# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1625993366 0 # Node ID 0bb974e70435cdd37dfd657d5b737ec0e3421fb9 # Parent 32728f6f7ccdfae40ece5e430b6c31d1a0115ca9 iOS: Fix crash by retaining the UIMenu returned in the block. Hopefully the UIMenu gets released by the system after use or we may leak. Remove some the debug code to dump the responder chain. Remove probably unused identifier and replace it with nil. Container context menus now work, but the window menu isn't showing. We no longer get the error anymore however at least. diff -r 32728f6f7ccd -r 0bb974e70435 ios/dw.m --- a/ios/dw.m Sat Jul 10 23:57:25 2021 +0000 +++ b/ios/dw.m Sun Jul 11 08:49:26 2021 +0000 @@ -269,15 +269,6 @@ CGContextRef _dw_draw_context(id image, bool antialias); typedef id (*DWIMP)(id, SEL, ...); -void _dw_display_responder_chain(id window) -{ - NSLog(@"=== Starting responder chain dump ===\n"); - do { - NSLog(@"%@\n", [window description]); - } while((window = [window nextResponder])); - NSLog(@"=== Responder chain dump complete ===\n"); -} - /* Internal function to queue a window redraw */ void _dw_redraw(id window, int skip) { @@ -1392,8 +1383,9 @@ if(windowmenu && !item.rightBarButtonItem) { + UIMenu *menu = [windowmenu menu]; UIBarButtonItem *options = [[UIBarButtonItem alloc] initWithImage:[UIImage systemImageNamed:@"list.bullet"] - menu:[windowmenu menu]]; + menu:menu]; item.rightBarButtonItem = options; } } else { @@ -2091,9 +2083,8 @@ if(window) { - __block UIMenu *popupmenu = [[window popupMenu] menu]; - _dw_display_responder_chain(tableView); - config = [UIContextMenuConfiguration configurationWithIdentifier:@"DWContextMenu" + __block UIMenu *popupmenu = [[[window popupMenu] menu] retain]; + config = [UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:nil actionProvider:^(NSArray* suggestedAction){return popupmenu;}]; [window setPopupMenu:nil];