diff --git a/src/html/htmlctrl/webkit/webkit.mm b/src/html/htmlctrl/webkit/webkit.mm index bfd0a466e7..0fb20442c6 100644 --- a/src/html/htmlctrl/webkit/webkit.mm +++ b/src/html/htmlctrl/webkit/webkit.mm @@ -460,8 +460,10 @@ void wxWebKitCtrl::MacVisibilityChanged(){ - (id)initWithWxWindow: (wxWebKitCtrl*)inWindow { - self = [super init]; - webKitWindow = inWindow; // non retained + if ( self = [super init] ) + { + webKitWindow = inWindow; // non retained + } return self; } @@ -541,8 +543,10 @@ void wxWebKitCtrl::MacVisibilityChanged(){ - (id)initWithWxWindow: (wxWebKitCtrl*)inWindow { - self = [super init]; - webKitWindow = inWindow; // non retained + if ( self = [super init] ) + { + webKitWindow = inWindow; // non retained + } return self; } @@ -592,8 +596,10 @@ void wxWebKitCtrl::MacVisibilityChanged(){ - (id)initWithWxWindow: (wxWebKitCtrl*)inWindow { - self = [super init]; - webKitWindow = inWindow; // non retained + if ( self = [super init] ) + { + webKitWindow = inWindow; // non retained + } return self; } diff --git a/src/osx/carbon/colordlgosx.mm b/src/osx/carbon/colordlgosx.mm index 9d3fddd0e2..495584f7f1 100644 --- a/src/osx/carbon/colordlgosx.mm +++ b/src/osx/carbon/colordlgosx.mm @@ -56,9 +56,10 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog); - (id)init { - self = [super init]; - m_bIsClosed = false; - + if ( self = [super init] ) + { + m_bIsClosed = false; + } return self; } diff --git a/src/osx/carbon/fontdlgosx.mm b/src/osx/carbon/fontdlgosx.mm index d253a0a641..7168b5a484 100644 --- a/src/osx/carbon/fontdlgosx.mm +++ b/src/osx/carbon/fontdlgosx.mm @@ -61,9 +61,11 @@ - (id)init { - [super init]; - m_isUnderline = false; - m_isStrikethrough = false; + if (self = [super init]) + { + m_isUnderline = false; + m_isStrikethrough = false; + } return self; } @@ -118,37 +120,38 @@ @implementation wxMacFontPanelAccView : NSView - (id)initWithFrame:(NSRect)rectBox { - [super initWithFrame:rectBox]; + if ( self = [super initWithFrame:rectBox] ) + { + wxCFStringRef cfOkString( wxT("OK"), wxLocale::GetSystemEncoding() ); + wxCFStringRef cfCancelString( wxT("Cancel"), wxLocale::GetSystemEncoding() ); - wxCFStringRef cfOkString( wxT("OK"), wxLocale::GetSystemEncoding() ); - wxCFStringRef cfCancelString( wxT("Cancel"), wxLocale::GetSystemEncoding() ); + NSRect rectCancel = NSMakeRect( (CGFloat) 10.0 , (CGFloat)10.0 , (CGFloat)82 , (CGFloat)24 ); + NSRect rectOK = NSMakeRect( (CGFloat)100.0 , (CGFloat)10.0 , (CGFloat)82 , (CGFloat)24 ); - NSRect rectCancel = NSMakeRect( (CGFloat) 10.0 , (CGFloat)10.0 , (CGFloat)82 , (CGFloat)24 ); - NSRect rectOK = NSMakeRect( (CGFloat)100.0 , (CGFloat)10.0 , (CGFloat)82 , (CGFloat)24 ); + NSButton* cancelButton = [[NSButton alloc] initWithFrame:rectCancel]; + [cancelButton setTitle:(NSString*)wxCFRetain((CFStringRef)cfCancelString)]; + [cancelButton setBezelStyle:NSRoundedBezelStyle]; + [cancelButton setButtonType:NSMomentaryPushInButton]; + [cancelButton setAction:@selector(cancelPressed:)]; + [cancelButton setTarget:self]; + m_cancelButton = cancelButton ; - NSButton* cancelButton = [[NSButton alloc] initWithFrame:rectCancel]; - [cancelButton setTitle:(NSString*)wxCFRetain((CFStringRef)cfCancelString)]; - [cancelButton setBezelStyle:NSRoundedBezelStyle]; - [cancelButton setButtonType:NSMomentaryPushInButton]; - [cancelButton setAction:@selector(cancelPressed:)]; - [cancelButton setTarget:self]; - m_cancelButton = cancelButton ; - - NSButton* okButton = [[NSButton alloc] initWithFrame:rectOK]; - [okButton setTitle:(NSString*)wxCFRetain((CFStringRef)cfOkString)]; - [okButton setBezelStyle:NSRoundedBezelStyle]; - [okButton setButtonType:NSMomentaryPushInButton]; - [okButton setAction:@selector(okPressed:)]; - [okButton setTarget:self]; - // doesn't help either, the button is not highlighted after a color dialog has been used - // [okButton setKeyEquivalent:@"\r"]; - m_okButton = okButton ; + NSButton* okButton = [[NSButton alloc] initWithFrame:rectOK]; + [okButton setTitle:(NSString*)wxCFRetain((CFStringRef)cfOkString)]; + [okButton setBezelStyle:NSRoundedBezelStyle]; + [okButton setButtonType:NSMomentaryPushInButton]; + [okButton setAction:@selector(okPressed:)]; + [okButton setTarget:self]; + // doesn't help either, the button is not highlighted after a color dialog has been used + // [okButton setKeyEquivalent:@"\r"]; + m_okButton = okButton ; - [self addSubview:cancelButton]; - [self addSubview:okButton]; + [self addSubview:cancelButton]; + [self addSubview:okButton]; - [self resetFlags]; + [self resetFlags]; + } return self; } @@ -318,9 +321,11 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog); - (id)init { - [super init]; - m_bIsClosed = false; - + if ( self = [super init] ) + { + m_bIsClosed = false; + } + return self; } @@ -362,10 +367,11 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog); - (id)init { - [super init]; - m_bIsClosed = false; - m_bIsOpen = false; - + if ( self = [super init] ) + { + m_bIsClosed = false; + m_bIsOpen = false; + } return self; } diff --git a/src/osx/cocoa/dataview.mm b/src/osx/cocoa/dataview.mm index 9d8a5d26d4..ee1e7ff180 100644 --- a/src/osx/cocoa/dataview.mm +++ b/src/osx/cocoa/dataview.mm @@ -196,7 +196,7 @@ inline wxDataViewItem wxDataViewItemFromMaybeNilItem(id item) -(id) initWithColumnPointer:(const wxDataViewColumn*)column { - [self initWithIdentifier: [wxDVCNSTableColumn identifierForColumnPointer:column]]; + self = [self initWithIdentifier: [wxDVCNSTableColumn identifierForColumnPointer:column]]; return self; } diff --git a/src/osx/cocoa/dnd.mm b/src/osx/cocoa/dnd.mm index b63834a714..5f1059253a 100644 --- a/src/osx/cocoa/dnd.mm +++ b/src/osx/cocoa/dnd.mm @@ -73,11 +73,13 @@ wxDragResult NSDragOperationToWxDragResult(NSDragOperation code) - (id)init { - self = [super init]; - dragFinished = NO; - resultCode = NSDragOperationNone; - impl = 0; - m_dragFlags = wxDrag_CopyOnly; + if ( self = [super init] ) + { + dragFinished = NO; + resultCode = NSDragOperationNone; + impl = 0; + m_dragFlags = wxDrag_CopyOnly; + } return self; } diff --git a/src/osx/cocoa/filedlg.mm b/src/osx/cocoa/filedlg.mm index 3316b3e414..29ef2e531b 100644 --- a/src/osx/cocoa/filedlg.mm +++ b/src/osx/cocoa/filedlg.mm @@ -68,8 +68,10 @@ - (id) init { - self = [super init]; - _dialog = NULL; + if ( self = [super init] ) + { + _dialog = NULL; + } return self; } diff --git a/src/osx/cocoa/listbox.mm b/src/osx/cocoa/listbox.mm index cad11b0f2e..df6b080595 100644 --- a/src/osx/cocoa/listbox.mm +++ b/src/osx/cocoa/listbox.mm @@ -160,8 +160,10 @@ protected : - (id) init { - self = [super init]; - column = nil; + if ( self = [super init] ) + { + column = nil; + } return self; } @@ -223,8 +225,10 @@ protected: - (id) init { - self = [super init]; - impl = nil; + if ( self = [super init] ) + { + impl = nil; + } return self; } diff --git a/src/osx/cocoa/mediactrl.mm b/src/osx/cocoa/mediactrl.mm index aeb7f0da7f..db53f99778 100644 --- a/src/osx/cocoa/mediactrl.mm +++ b/src/osx/cocoa/mediactrl.mm @@ -134,13 +134,13 @@ private: - (id) init { - self = [super init]; - - [self addObserver:self forKeyPath:@"currentItem.status" + if ( self = [super init] ) + { + [self addObserver:self forKeyPath:@"currentItem.status" options:NSKeyValueObservingOptionNew context:AVSPPlayerItemStatusContext]; - [self addObserver:self forKeyPath:@"rate" + [self addObserver:self forKeyPath:@"rate" options:NSKeyValueObservingOptionNew context:AVSPPlayerRateContext]; - + } return self; } @@ -257,13 +257,12 @@ private: - (id) initWithFrame:(CGRect)rect player:(wxAVPlayer*) player { - if ( !(self=[super initWithFrame:rect]) ) - return nil; - - AVPlayerLayer* playerLayer = (AVPlayerLayer*) [self layer]; - [playerLayer setPlayer: player]; - [player setPlayerLayer:playerLayer]; - + if ( self = [super initWithFrame:rect] ) + { + AVPlayerLayer* playerLayer = (AVPlayerLayer*) [self layer]; + [playerLayer setPlayer: player]; + [player setPlayerLayer:playerLayer]; + } return self; } @@ -297,11 +296,10 @@ private: - (id) initWithFrame:(NSRect)rect player:(wxAVPlayer*) player { - if ( !(self=[super initWithFrame:rect]) ) - return nil; - - self.player = player; - + if ( self = [super initWithFrame:rect] ) + { + self.player = player; + } return self; } @@ -334,17 +332,17 @@ private: - (id) initWithFrame:(NSRect)rect player:(wxAVPlayer*) player { - if ( !(self=[super initWithFrame:rect]) ) - return nil; + if ( self = [super initWithFrame:rect] ) + { + [self setWantsLayer:YES]; + AVPlayerLayer* playerlayer = [[AVPlayerLayer playerLayerWithPlayer: player] retain]; + [player setPlayerLayer:playerlayer]; + + [playerlayer setFrame:[[self layer] bounds]]; + [playerlayer setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable]; + [[self layer] addSublayer:playerlayer]; + } - [self setWantsLayer:YES]; - AVPlayerLayer* playerlayer = [[AVPlayerLayer playerLayerWithPlayer: player] retain]; - [player setPlayerLayer:playerlayer]; - - [playerlayer setFrame:[[self layer] bounds]]; - [playerlayer setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable]; - [[self layer] addSublayer:playerlayer]; - return self; } diff --git a/src/osx/cocoa/menu.mm b/src/osx/cocoa/menu.mm index 8b6be54d26..0ec0225098 100644 --- a/src/osx/cocoa/menu.mm +++ b/src/osx/cocoa/menu.mm @@ -37,8 +37,10 @@ - (id) initWithTitle:(NSString*) title { - self = [super initWithTitle:title]; - impl = NULL; + if ( self = [super initWithTitle:title] ) + { + impl = NULL; + } return self; } diff --git a/src/osx/cocoa/notebook.mm b/src/osx/cocoa/notebook.mm index f0d810275a..0a3862ac24 100644 --- a/src/osx/cocoa/notebook.mm +++ b/src/osx/cocoa/notebook.mm @@ -112,8 +112,11 @@ @implementation WXCTabViewImageItem : NSTabViewItem - (id)init { - m_image = nil; - return [super initWithIdentifier:nil]; + if (self = [super initWithIdentifier:nil]) + { + m_image = nil; + } + return self; } - (void)dealloc { diff --git a/src/osx/cocoa/textctrl.mm b/src/osx/cocoa/textctrl.mm index 8d19af1e56..4f288f2375 100644 --- a/src/osx/cocoa/textctrl.mm +++ b/src/osx/cocoa/textctrl.mm @@ -130,9 +130,11 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil; - (id)init { - self = [super init]; - maxLength = 0; - forceUpper = false; + if ( self = [super init] ) + { + maxLength = 0; + forceUpper = false; + } return self; } @@ -495,8 +497,10 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil; - (id) initWithFrame:(NSRect) frame { - self = [super initWithFrame:frame]; - fieldEditor = nil; + if ( self = [super initWithFrame:frame] ) + { + fieldEditor = nil; + } return self; } diff --git a/src/osx/cocoa/toolbar.mm b/src/osx/cocoa/toolbar.mm index c449501144..209209fe10 100644 --- a/src/osx/cocoa/toolbar.mm +++ b/src/osx/cocoa/toolbar.mm @@ -368,10 +368,12 @@ private: - (id)initWithItemIdentifier: (NSString*) identifier { - self = [super initWithItemIdentifier:identifier]; - impl = NULL; - [self setTarget: self]; - [self setAction: @selector(clickedAction:)]; + if ( self = [super initWithItemIdentifier:identifier] ) + { + impl = NULL; + [self setTarget: self]; + [self setAction: @selector(clickedAction:)]; + } return self; } @@ -406,8 +408,11 @@ private: - (id)init { - m_isSelectable = false; - return [super init]; + if ( self = [super init] ) + { + m_isSelectable = false; + } + return self; } - (void)setSelectable:(bool) value @@ -469,8 +474,7 @@ private: - (id)initWithIdentifier:(NSString *)identifier { - self = [super initWithIdentifier:identifier]; - if (self) + if (self = [super initWithIdentifier:identifier]) { toolbarDelegate = [[wxNSToolbarDelegate alloc] init]; [self setDelegate:toolbarDelegate]; @@ -492,10 +496,12 @@ private: - (id)initWithFrame:(NSRect)frame { - self = [super initWithFrame:frame]; - impl = NULL; - [self setTarget: self]; - [self setAction: @selector(clickedAction:)]; + if ( self = [super initWithFrame:frame] ) + { + impl = NULL; + [self setTarget: self]; + [self setAction: @selector(clickedAction:)]; + } return self; } diff --git a/src/osx/cocoa/utils.mm b/src/osx/cocoa/utils.mm index 7636672002..385abccefb 100644 --- a/src/osx/cocoa/utils.mm +++ b/src/osx/cocoa/utils.mm @@ -232,10 +232,12 @@ void wxBell() @implementation ModalDialogDelegate - (id)init { - self = [super init]; - sheetFinished = NO; - resultCode = -1; - impl = 0; + if ( self = [super init] ) + { + sheetFinished = NO; + resultCode = -1; + impl = 0; + } return self; } @@ -336,8 +338,10 @@ void wxBell() - (id)init { - self = [super init]; - firstPass = YES; + if ( self = [super init] ) + { + firstPass = YES; + } return self; } diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index e1375beee7..3eb68e4a2d 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -1916,11 +1916,11 @@ double wxWidgetCocoaImpl::GetContentScaleFactor() const - (id)init:(wxWindow *)win { - self = [super init]; - - m_win = win; - m_isDone = false; - + if ( self = [super init] ) + { + m_win = win; + m_isDone = false; + } return self; } diff --git a/src/osx/webview_webkit.mm b/src/osx/webview_webkit.mm index 5eb143ed84..134b64d999 100644 --- a/src/osx/webview_webkit.mm +++ b/src/osx/webview_webkit.mm @@ -690,8 +690,10 @@ void wxWebViewWebKit::RegisterHandler(wxSharedPtr handler) - (id)initWithWxWindow: (wxWebViewWebKit*)inWindow { - [super init]; - webKitWindow = inWindow; // non retained + if (self = [super init]) + { + webKitWindow = inWindow; // non retained + } return self; } @@ -878,8 +880,10 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out) - (id)initWithWxWindow: (wxWebViewWebKit*)inWindow { - [super init]; - webKitWindow = inWindow; // non retained + if (self = [super init]) + { + webKitWindow = inWindow; // non retained + } return self; } @@ -1036,8 +1040,10 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out) - (id)initWithWxWindow: (wxWebViewWebKit*)inWindow { - [super init]; - webKitWindow = inWindow; // non retained + if (self = [super init]) + { + webKitWindow = inWindow; // non retained + } return self; }