From: David Elliott Date: Tue, 17 Jul 2007 05:14:36 +0000 (+0000) Subject: Don't use exceptions to determine lack of a method implementation. Exceptions X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/2465458c06734482c89d891114a7f113f8724eb9 Don't use exceptions to determine lack of a method implementation. Exceptions aren't designed for this in Cocoa. Instead, use respondsToSelector:. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47521 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/cocoa/control.mm b/src/cocoa/control.mm index 0e498cb529..475a372d5e 100644 --- a/src/cocoa/control.mm +++ b/src/cocoa/control.mm @@ -218,11 +218,8 @@ wxSize wxControl::DoGetBestSize() const wxASSERT(GetNSControl()); /* We can ask single-celled controls for their cell and get its size */ NSCell *cell = nil; -NS_DURING - cell = [GetNSControl() cell]; -NS_HANDLER - // TODO: if anything other than method not implemented, re-raise -NS_ENDHANDLER + if([GetNSControl() respondsToSelector:@selector(cell)]) + cell = [GetNSControl() cell]; if(cell) { NSSize cellSize = [cell cellSize]; @@ -232,16 +229,10 @@ NS_ENDHANDLER } /* multi-celled control? size to fit, get the size, then set it back */ - NSRect storedRect = [m_cocoaNSView frame]; - bool didFit = false; -NS_DURING - [GetNSControl() sizeToFit]; - didFit = true; -NS_HANDLER - // TODO: if anything other than method not implemented, re-raise -NS_ENDHANDLER - if(didFit) + if([GetNSControl() respondsToSelector:@selector(sizeToFit)]) { + NSRect storedRect = [m_cocoaNSView frame]; + [GetNSControl() sizeToFit]; NSRect cocoaRect = [m_cocoaNSView frame]; wxSize size((int)ceil(cocoaRect.size.width),(int)ceil(cocoaRect.size.height)); [m_cocoaNSView setFrame: storedRect];