comparison ios/dw.m @ 2820:b6ae5b017b28

iOS: Fix a crash in HandyFTP, an additional check I put in for dw_window_get_text() made it return NULL on 0 length strings. Also fix main thread API check warnings for calling updateMenu: by creating a safeCall: method to do it from any thread. Add code to cleanup after splitbar and notebook controls.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 02 Aug 2022 07:27:13 +0000
parents a2fc275fa9bb
children 0adf73d5d8c2
comparison
equal deleted inserted replaced
2819:a2fc275fa9bb 2820:b6ae5b017b28
1390 [self performSelector:sel withObject:param]; 1390 [self performSelector:sel withObject:param];
1391 else 1391 else
1392 [self performSelectorOnMainThread:sel withObject:param waitUntilDone:YES]; 1392 [self performSelectorOnMainThread:sel withObject:param waitUntilDone:YES];
1393 } 1393 }
1394 } 1394 }
1395 -(void)updateMenu:(id)param
1396 {
1397 for(id obj in _dw_toplevel_windows)
1398 [obj updateMenu];
1399 }
1395 -(void)doBitBlt:(id)param 1400 -(void)doBitBlt:(id)param
1396 { 1401 {
1397 NSValue *bi = (NSValue *)param; 1402 NSValue *bi = (NSValue *)param;
1398 DWBitBlt *bltinfo = (DWBitBlt *)[bi pointerValue]; 1403 DWBitBlt *bltinfo = (DWBitBlt *)[bi pointerValue];
1399 id bltdest = bltinfo->dest; 1404 id bltdest = bltinfo->dest;
2154 } 2159 }
2155 -(void)dealloc { 2160 -(void)dealloc {
2156 UserData *root = userdata; 2161 UserData *root = userdata;
2157 _dw_remove_userdata(&root, NULL, TRUE); 2162 _dw_remove_userdata(&root, NULL, TRUE);
2158 dw_signal_disconnect_by_window(self); 2163 dw_signal_disconnect_by_window(self);
2164 [tabs removeFromSuperview];
2159 [tabs release]; 2165 [tabs release];
2160 [views release]; 2166 [views release];
2161 [super dealloc]; 2167 [super dealloc];
2162 } 2168 }
2163 @end 2169 @end
2258 [bottomright setFrame:half]; 2264 [bottomright setFrame:half];
2259 _dw_do_resize(box, half.size.width, half.size.height); 2265 _dw_do_resize(box, half.size.width, half.size.height);
2260 _dw_handle_resize_events(box); 2266 _dw_handle_resize_events(box);
2261 } 2267 }
2262 } 2268 }
2263 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; } 2269 -(void)dealloc
2270 {
2271 UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE);
2272 dw_signal_disconnect_by_window(self);
2273 if(topleft)
2274 {
2275 [topleft removeFromSuperview];
2276 [topleft release];
2277 }
2278 if(bottomright)
2279 {
2280 [bottomright removeFromSuperview];
2281 [bottomright release];
2282 }
2283 [super dealloc];
2284 }
2264 @end 2285 @end
2265 2286
2266 /* Subclass for a slider type */ 2287 /* Subclass for a slider type */
2267 @interface DWSlider : UISlider 2288 @interface DWSlider : UISlider
2268 { 2289 {
8659 UIMenuElementState state = [item state] == UIMenuElementStateOn ? UIMenuElementStateOff : UIMenuElementStateOn; 8680 UIMenuElementState state = [item state] == UIMenuElementStateOn ? UIMenuElementStateOff : UIMenuElementStateOn;
8660 [item setState:state]; 8681 [item setState:state];
8661 } 8682 }
8662 [DWObj menuHandler:item]; 8683 [DWObj menuHandler:item];
8663 if(check) 8684 if(check)
8664 { 8685 [DWObj safeCall:@selector(updateMenu:) withObject:nil];
8665 for(id obj in _dw_toplevel_windows)
8666 [obj updateMenu];
8667 }
8668 }]; 8686 }];
8669 /* Don't set the tag if the ID is 0 or -1 */ 8687 /* Don't set the tag if the ID is 0 or -1 */
8670 if(itemid != DW_MENU_AUTO && itemid != DW_MENU_POPUP) 8688 if(itemid != DW_MENU_AUTO && itemid != DW_MENU_POPUP)
8671 [item setTag:itemid]; 8689 [item setTag:itemid];
8672 [menu addItem:item]; 8690 [menu addItem:item];
8710 8728
8711 /* Only force the menus to repopulate if something changed */ 8729 /* Only force the menus to repopulate if something changed */
8712 if(newstate != [menuitem state]) 8730 if(newstate != [menuitem state])
8713 { 8731 {
8714 [menuitem setState:newstate]; 8732 [menuitem setState:newstate];
8715 for(id obj in _dw_toplevel_windows) 8733 [DWObj safeCall:@selector(updateMenu:) withObject:nil];
8716 [obj updateMenu];
8717 } 8734 }
8718 } 8735 }
8719 } 8736 }
8720 8737
8721 /* 8738 /*
8766 else if(state & DW_MIS_DISABLED) 8783 else if(state & DW_MIS_DISABLED)
8767 [menuitem setEnabled:NO]; 8784 [menuitem setEnabled:NO];
8768 8785
8769 /* Only force the menus to repopulate if something changed */ 8786 /* Only force the menus to repopulate if something changed */
8770 if(oldstate != [menuitem state] || oldenabled != [menuitem enabled]) 8787 if(oldstate != [menuitem state] || oldenabled != [menuitem enabled])
8771 { 8788 [DWObj safeCall:@selector(updateMenu:) withObject:nil];
8772 for(id obj in _dw_toplevel_windows)
8773 [obj updateMenu];
8774 }
8775 } 8789 }
8776 } 8790 }
8777 8791
8778 /* Gets the notebook page from associated ID */ 8792 /* Gets the notebook page from associated ID */
8779 DWNotebookPage *_dw_notepage_from_id(DWNotebook *notebook, unsigned long pageid) 8793 DWNotebookPage *_dw_notepage_from_id(DWNotebook *notebook, unsigned long pageid)
9291 else if(style & DW_MIS_DISABLED) 9305 else if(style & DW_MIS_DISABLED)
9292 [menuitem setEnabled:NO]; 9306 [menuitem setEnabled:NO];
9293 } 9307 }
9294 /* Only force the menus to repopulate if something changed */ 9308 /* Only force the menus to repopulate if something changed */
9295 if(oldstate != [menuitem state] || oldenabled != [menuitem enabled]) 9309 if(oldstate != [menuitem state] || oldenabled != [menuitem enabled])
9296 { 9310 [DWObj safeCall:@selector(updateMenu:) withObject:nil];
9297 for(id obj in _dw_toplevel_windows)
9298 [obj updateMenu];
9299 }
9300 } 9311 }
9301 DW_FUNCTION_RETURN_NOTHING; 9312 DW_FUNCTION_RETURN_NOTHING;
9302 } 9313 }
9303 9314
9304 /* 9315 /*
9516 if([object isKindOfClass:[UIWindow class]]) 9527 if([object isKindOfClass:[UIWindow class]])
9517 { 9528 {
9518 DWWindow *window = handle; 9529 DWWindow *window = handle;
9519 [window setHidden:YES]; 9530 [window setHidden:YES];
9520 [_dw_toplevel_windows removeObject:window]; 9531 [_dw_toplevel_windows removeObject:window];
9532 for(id object in [[[window rootViewController] view] subviews])
9533 {
9534 [object removeFromSuperview];
9535 [object release];
9536 }
9521 [[[window rootViewController] view] removeFromSuperview]; 9537 [[[window rootViewController] view] removeFromSuperview];
9522 [window setRootViewController:nil]; 9538 [window setRootViewController:nil];
9523 } 9539 }
9524 /* Handle removing menu items from menus */ 9540 /* Handle removing menu items from menus */
9525 else if([object isMemberOfClass:[DWMenuItem class]]) 9541 else if([object isMemberOfClass:[DWMenuItem class]])
9628 9644
9629 nsstr = [item title]; 9645 nsstr = [item title];
9630 } 9646 }
9631 } 9647 }
9632 } 9648 }
9633 if(nsstr && [nsstr length] > 0) 9649 if(nsstr)
9634 retval = strdup([nsstr UTF8String]); 9650 retval = strdup([nsstr UTF8String]);
9635 DW_FUNCTION_RETURN_THIS(retval); 9651 DW_FUNCTION_RETURN_THIS(retval);
9636 } 9652 }
9637 9653
9638 /* 9654 /*