Mercurial > dwindows
comparison ios/dw.m @ 2817:5000a8a43825
iOS: Fix some memory leaks and remove unnecessary code.
Like on Mac we need to release the item being packed in dw_box_pack_*().
However we don't need the retains or autoreleases since we use ARC on iOS.
The UIWindow release is not necessary, garbage collection will remove it.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 02 Aug 2022 03:07:52 +0000 |
parents | 9c9b680f7772 |
children | d5d09bdd61d6 |
comparison
equal
deleted
inserted
replaced
2816:4521f014bb17 | 2817:5000a8a43825 |
---|---|
1869 menu = [UIMenu menuWithChildren:menuchildren]; | 1869 menu = [UIMenu menuWithChildren:menuchildren]; |
1870 else | 1870 else |
1871 menu = [UIMenu menuWithTitle:@"" children:menuchildren]; | 1871 menu = [UIMenu menuWithTitle:@"" children:menuchildren]; |
1872 } | 1872 } |
1873 [menu retain]; | 1873 [menu retain]; |
1874 [menuchildren release]; | |
1874 if(oldmenu) | 1875 if(oldmenu) |
1875 [oldmenu release]; | 1876 [oldmenu release]; |
1876 return menu; | 1877 return menu; |
1877 } | 1878 } |
1878 -(void)addItem:(id)item | 1879 -(void)addItem:(id)item |
4738 /* Update the item count */ | 4739 /* Update the item count */ |
4739 thisbox->count++; | 4740 thisbox->count++; |
4740 | 4741 |
4741 /* Add the item to the box */ | 4742 /* Add the item to the box */ |
4742 [view addSubview:this]; | 4743 [view addSubview:this]; |
4743 /* Enable autorelease on the item... | 4744 [this release]; |
4744 * so it will get destroyed when the parent is. | 4745 |
4745 */ | |
4746 [this autorelease]; | |
4747 /* If we are packing a button... */ | 4746 /* If we are packing a button... */ |
4748 if([this isMemberOfClass:[DWButton class]]) | 4747 if([this isMemberOfClass:[DWButton class]]) |
4749 { | 4748 { |
4750 DWButton *button = (DWButton *)this; | 4749 DWButton *button = (DWButton *)this; |
4751 | 4750 |
9489 DWWindow *window = handle; | 9488 DWWindow *window = handle; |
9490 [window setHidden:YES]; | 9489 [window setHidden:YES]; |
9491 [_dw_toplevel_windows removeObject:window]; | 9490 [_dw_toplevel_windows removeObject:window]; |
9492 [[[window rootViewController] view] removeFromSuperview]; | 9491 [[[window rootViewController] view] removeFromSuperview]; |
9493 [window setRootViewController:nil]; | 9492 [window setRootViewController:nil]; |
9494 /* Releasing the window is causing crashes.... | |
9495 * TODO: Figure out if this is needed... or why it is crashing. | |
9496 * [window release]; | |
9497 */ | |
9498 } | 9493 } |
9499 /* Handle removing menu items from menus */ | 9494 /* Handle removing menu items from menus */ |
9500 else if([object isMemberOfClass:[DWMenuItem class]]) | 9495 else if([object isMemberOfClass:[DWMenuItem class]]) |
9501 { | 9496 { |
9502 DWMenuItem *item = object; | 9497 DWMenuItem *item = object; |