Mercurial > dwindows
comparison ios/dw.m @ 2600:0bb974e70435
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.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 11 Jul 2021 08:49:26 +0000 |
parents | 32728f6f7ccd |
children | 3201f9e9067b |
comparison
equal
deleted
inserted
replaced
2599:32728f6f7ccd | 2600:0bb974e70435 |
---|---|
267 int _dw_remove_userdata(UserData **root, const char *varname, int all); | 267 int _dw_remove_userdata(UserData **root, const char *varname, int all); |
268 int _dw_main_iteration(NSDate *date); | 268 int _dw_main_iteration(NSDate *date); |
269 CGContextRef _dw_draw_context(id image, bool antialias); | 269 CGContextRef _dw_draw_context(id image, bool antialias); |
270 typedef id (*DWIMP)(id, SEL, ...); | 270 typedef id (*DWIMP)(id, SEL, ...); |
271 | 271 |
272 void _dw_display_responder_chain(id window) | |
273 { | |
274 NSLog(@"=== Starting responder chain dump ===\n"); | |
275 do { | |
276 NSLog(@"%@\n", [window description]); | |
277 } while((window = [window nextResponder])); | |
278 NSLog(@"=== Responder chain dump complete ===\n"); | |
279 } | |
280 | |
281 /* Internal function to queue a window redraw */ | 272 /* Internal function to queue a window redraw */ |
282 void _dw_redraw(id window, int skip) | 273 void _dw_redraw(id window, int skip) |
283 { | 274 { |
284 static id lastwindow = nil; | 275 static id lastwindow = nil; |
285 id redraw = lastwindow; | 276 id redraw = lastwindow; |
1390 DWMenu *windowmenu = [window menu]; | 1381 DWMenu *windowmenu = [window menu]; |
1391 UINavigationItem *item = [[nav items] firstObject]; | 1382 UINavigationItem *item = [[nav items] firstObject]; |
1392 | 1383 |
1393 if(windowmenu && !item.rightBarButtonItem) | 1384 if(windowmenu && !item.rightBarButtonItem) |
1394 { | 1385 { |
1386 UIMenu *menu = [windowmenu menu]; | |
1395 UIBarButtonItem *options = [[UIBarButtonItem alloc] initWithImage:[UIImage systemImageNamed:@"list.bullet"] | 1387 UIBarButtonItem *options = [[UIBarButtonItem alloc] initWithImage:[UIImage systemImageNamed:@"list.bullet"] |
1396 menu:[windowmenu menu]]; | 1388 menu:menu]; |
1397 item.rightBarButtonItem = options; | 1389 item.rightBarButtonItem = options; |
1398 } | 1390 } |
1399 } else { | 1391 } else { |
1400 // Fallback on earlier versions | 1392 // Fallback on earlier versions |
1401 } | 1393 } |
2089 | 2081 |
2090 _dw_event_handler(self, (id)params, 10); | 2082 _dw_event_handler(self, (id)params, 10); |
2091 | 2083 |
2092 if(window) | 2084 if(window) |
2093 { | 2085 { |
2094 __block UIMenu *popupmenu = [[window popupMenu] menu]; | 2086 __block UIMenu *popupmenu = [[[window popupMenu] menu] retain]; |
2095 _dw_display_responder_chain(tableView); | 2087 config = [UIContextMenuConfiguration configurationWithIdentifier:nil |
2096 config = [UIContextMenuConfiguration configurationWithIdentifier:@"DWContextMenu" | |
2097 previewProvider:nil | 2088 previewProvider:nil |
2098 actionProvider:^(NSArray* suggestedAction){return popupmenu;}]; | 2089 actionProvider:^(NSArray* suggestedAction){return popupmenu;}]; |
2099 [window setPopupMenu:nil]; | 2090 [window setPopupMenu:nil]; |
2100 } | 2091 } |
2101 return config; | 2092 return config; |