Correct issues with missing or incorrect self

tests in initXXX methods pointed out by static analyser.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@32588 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2011-03-14 22:59:20 +00:00
parent a6086e2728
commit 8cf1cd3bab
23 changed files with 204 additions and 50 deletions

View file

@ -1,3 +1,29 @@
2011-03-14 Fred Kiefer <FredKiefer@gmx.de>
* ColorPickers/GSNamedColorPicker.m
* Source/NSBrowser.m
* Source/NSPanel.m
* Source/NSOpenPanel.m
* Source/GSDisplayServer.m
* Source/NSFormCell.m
* Source/NSBitmapImageRep.m
* Source/NSForm.m
* Source/GSVbox.m
* Source/NSSavePanel.m
* Source/GSMemoryPanel.m
* Source/NSScroller.m
* Source/NSMenuView.m
* Source/NSSecureTextField.m
* Source/NSHelpPanel.m
* Source/NSSegmentedCell.m
* Source/NSStepperCell.m
* Source/NSColorPanel.m
* Source/NSDataLinkPanel.m
* Source/GSTable.m
* Source/NSBrowserCell.m
* Source/GSHbox.m: Correct issues with missing or incorrect self
tests in initXXX methods pointed out by static analyser.
2011-03-14 Fred Kiefer <FredKiefer@gmx.de> 2011-03-14 Fred Kiefer <FredKiefer@gmx.de>
* Printing/GSCUPS/GSCUPSPrinter.m (+printerWithName:) Autorelease * Printing/GSCUPS/GSCUPSPrinter.m (+printerWithName:) Autorelease

View file

@ -49,9 +49,13 @@
{ {
if (aMask & NSColorPanelColorListModeMask) if (aMask & NSColorPanelColorListModeMask)
{ {
lists = [[NSColorList availableColorLists] mutableCopy]; self = [super initWithPickerMask: aMask
return [super initWithPickerMask: aMask
colorPanel: colorPanel]; colorPanel: colorPanel];
if (nil == self)
return nil;
lists = [[NSColorList availableColorLists] mutableCopy];
return self;
} }
RELEASE(self); RELEASE(self);
return nil; return nil;

View file

@ -213,7 +213,9 @@ GSCurrentServer(void)
*/ */
- (id) initWithAttributes: (NSDictionary *)attributes - (id) initWithAttributes: (NSDictionary *)attributes
{ {
[super init]; self = [super init];
if (nil == self)
return nil;
server_info = [attributes mutableCopy]; server_info = [attributes mutableCopy];
event_queue = [[NSMutableArray allocWithZone: [self zone]] event_queue = [[NSMutableArray allocWithZone: [self zone]]

View file

@ -39,21 +39,27 @@
if (self == [GSHbox class]) if (self == [GSHbox class])
[self setVersion: 1]; [self setVersion: 1];
} }
// //
// Instance Methods // Instance Methods
// //
-(id) init -(id) init
{ {
[super initWithNumberOfRows: 1 self = [super initWithNumberOfRows: 1
numberOfColumns: 1]; numberOfColumns: 1];
if (nil == self)
return nil;
_haveViews = NO; _haveViews = NO;
_defaultMinXMargin = 0; _defaultMinXMargin = 0;
return self; return self;
} }
-(void) dealloc -(void) dealloc
{ {
[super dealloc]; [super dealloc];
} }
// //
// Adding Views // Adding Views
// //
@ -63,6 +69,7 @@
enablingXResizing: YES enablingXResizing: YES
withMinXMargin: _defaultMinXMargin]; withMinXMargin: _defaultMinXMargin];
} }
-(void) addView: (NSView *)aView -(void) addView: (NSView *)aView
enablingXResizing: (BOOL)aFlag enablingXResizing: (BOOL)aFlag
{ {
@ -70,6 +77,7 @@ enablingXResizing: (BOOL)aFlag
enablingXResizing: aFlag enablingXResizing: aFlag
withMinXMargin: _defaultMinXMargin]; withMinXMargin: _defaultMinXMargin];
} }
-(void) addView: (NSView *)aView -(void) addView: (NSView *)aView
withMinXMargin: (float) aMargin withMinXMargin: (float) aMargin
{ {
@ -77,6 +85,7 @@ enablingXResizing: (BOOL)aFlag
enablingXResizing: YES enablingXResizing: YES
withMinXMargin: aMargin]; withMinXMargin: aMargin];
} }
-(void) addView: (NSView *)aView -(void) addView: (NSView *)aView
enablingXResizing: (BOOL)aFlag enablingXResizing: (BOOL)aFlag
withMinXMargin: (float)aMargin withMinXMargin: (float)aMargin
@ -115,6 +124,7 @@ enablingXResizing: (BOOL)aFlag
} }
} }
// //
// Adding a Separator // Adding a Separator
// //
@ -122,6 +132,7 @@ enablingXResizing: (BOOL)aFlag
{ {
[self addSeparatorWithMinXMargin: _defaultMinXMargin]; [self addSeparatorWithMinXMargin: _defaultMinXMargin];
} }
-(void) addSeparatorWithMinXMargin: (float)aMargin -(void) addSeparatorWithMinXMargin: (float)aMargin
{ {
NSBox *separator; NSBox *separator;
@ -136,6 +147,7 @@ enablingXResizing: (BOOL)aFlag
withMinXMargin: aMargin]; withMinXMargin: aMargin];
[separator release]; [separator release];
} }
// //
// Setting Margins // Setting Margins
// //
@ -175,7 +187,10 @@ enablingXResizing: (BOOL)aFlag
-(id) initWithCoder: (NSCoder*)aDecoder -(id) initWithCoder: (NSCoder*)aDecoder
{ {
[super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
if (nil == self)
return nil;
if ([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
{ {
_haveViews = [aDecoder decodeBoolForKey: @"GSHaveViews"]; _haveViews = [aDecoder decodeBoolForKey: @"GSHaveViews"];

View file

@ -193,8 +193,6 @@ static GSMemoryPanel *sharedGSMemoryPanel = nil;
/* Activate debugging of allocation. */ /* Activate debugging of allocation. */
GSDebugAllocationActive (YES); GSDebugAllocationActive (YES);
orderingBy = @selector(compareByCount:);
array = [NSMutableArray new];
hbox = [GSHbox new]; hbox = [GSHbox new];
[hbox setDefaultMinXMargin: 5]; [hbox setDefaultMinXMargin: 5];
[hbox setBorder: 5]; [hbox setBorder: 5];
@ -266,13 +264,12 @@ static GSMemoryPanel *sharedGSMemoryPanel = nil;
scrollView = [[NSScrollView alloc] scrollView = [[NSScrollView alloc]
initWithFrame: NSMakeRect (0, 0, 350, 300)]; initWithFrame: NSMakeRect (0, 0, 350, 300)];
[scrollView setDocumentView: table]; [scrollView setDocumentView: table];
RELEASE (table);
[scrollView setHasHorizontalScroller: YES]; [scrollView setHasHorizontalScroller: YES];
[scrollView setHasVerticalScroller: YES]; [scrollView setHasVerticalScroller: YES];
[scrollView setBorderType: NSBezelBorder]; [scrollView setBorderType: NSBezelBorder];
[scrollView setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)]; [scrollView setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)];
[table sizeToFit]; [table sizeToFit];
RELEASE (table);
vbox = [GSVbox new]; vbox = [GSVbox new];
[vbox setDefaultMinYMargin: 5]; [vbox setDefaultMinYMargin: 5];
@ -287,13 +284,18 @@ static GSMemoryPanel *sharedGSMemoryPanel = nil;
winFrame.origin = NSMakePoint (100, 200); winFrame.origin = NSMakePoint (100, 200);
self = [super initWithContentRect: winFrame self = [super initWithContentRect: winFrame
styleMask: (NSTitledWindowMask styleMask: (NSTitledWindowMask
| NSClosableWindowMask | NSClosableWindowMask
| NSMiniaturizableWindowMask | NSMiniaturizableWindowMask
| NSResizableWindowMask) | NSResizableWindowMask)
backing: NSBackingStoreBuffered backing: NSBackingStoreBuffered
defer: NO]; defer: NO];
if (nil == self)
return nil;
array = [NSMutableArray new];
orderingBy = @selector(compareByCount:);
[self setReleasedWhenClosed: NO]; [self setReleasedWhenClosed: NO];
[self setContentView: vbox]; [self setContentView: vbox];
RELEASE (vbox); RELEASE (vbox);

View file

@ -65,7 +65,10 @@
{ {
int i; int i;
[super init]; self = [super init];
if (nil == self)
return nil;
[super setAutoresizesSubviews: NO]; [super setAutoresizesSubviews: NO];
if (!(rows > 0)) if (!(rows > 0))
{ {
@ -134,11 +137,13 @@
return self; return self;
} }
-(id) init -(id) init
{ {
return [self initWithNumberOfRows: 2 return [self initWithNumberOfRows: 2
numberOfColumns: 2]; numberOfColumns: 2];
} }
-(void) dealloc -(void) dealloc
{ {
NSZoneFree (NSDefaultMallocZone (), _jails); NSZoneFree (NSDefaultMallocZone (), _jails);
@ -153,11 +158,13 @@
NSZoneFree (NSDefaultMallocZone (), _havePrisoner); NSZoneFree (NSDefaultMallocZone (), _havePrisoner);
[super dealloc]; [super dealloc];
} }
- (void) setAutoresizesSubviews: (BOOL)flag - (void) setAutoresizesSubviews: (BOOL)flag
{ {
NSLog (@"Warning: attempt to setAutoresizesSubviews for a GSTable!\n"); NSLog (@"Warning: attempt to setAutoresizesSubviews for a GSTable!\n");
return; return;
} }
// //
// Setting Border. // Setting Border.
// //
@ -169,16 +176,19 @@
[self setMaxYBorder: aBorder]; [self setMaxYBorder: aBorder];
} }
-(void) setXBorder: (float)aBorder -(void) setXBorder: (float)aBorder
{ {
[self setMinXBorder: aBorder]; [self setMinXBorder: aBorder];
[self setMaxXBorder: aBorder]; [self setMaxXBorder: aBorder];
} }
-(void) setYBorder: (float)aBorder -(void) setYBorder: (float)aBorder
{ {
[self setMinYBorder: aBorder]; [self setMinYBorder: aBorder];
[self setMaxYBorder: aBorder]; [self setMaxYBorder: aBorder];
} }
-(void) setMinXBorder: (float)aBorder -(void) setMinXBorder: (float)aBorder
{ {
float borderChange; float borderChange;
@ -202,6 +212,7 @@
_minXBorder = aBorder; _minXBorder = aBorder;
} }
-(void) setMaxXBorder: (float)aBorder -(void) setMaxXBorder: (float)aBorder
{ {
float borderChange; float borderChange;
@ -242,6 +253,7 @@
_minYBorder = aBorder; _minYBorder = aBorder;
} }
-(void) setMaxYBorder: (float)aBorder -(void) setMaxYBorder: (float)aBorder
{ {
float borderChange; float borderChange;
@ -258,6 +270,7 @@
_maxYBorder = aBorder; _maxYBorder = aBorder;
} }
// //
// Adding Views // Adding Views
// //
@ -273,6 +286,7 @@
minYMargin: 0 minYMargin: 0
maxYMargin: 0]; maxYMargin: 0];
} }
-(void) putView: (NSView *)aView -(void) putView: (NSView *)aView
atRow: (int)row atRow: (int)row
column: (int)column column: (int)column
@ -286,6 +300,7 @@
minYMargin: margins minYMargin: margins
maxYMargin: margins]; maxYMargin: margins];
} }
-(void) putView: (NSView *)aView -(void) putView: (NSView *)aView
atRow: (int)row atRow: (int)row
column: (int)column column: (int)column
@ -300,6 +315,7 @@
minYMargin: yMargins minYMargin: yMargins
maxYMargin: yMargins]; maxYMargin: yMargins];
} }
// The other methods are only wrappers for this one. // The other methods are only wrappers for this one.
-(void) putView: (NSView *)aView -(void) putView: (NSView *)aView
atRow: (int)row atRow: (int)row
@ -496,6 +512,7 @@
{ {
return _minimumSize; return _minimumSize;
} }
// //
// Resizing // Resizing
// //
@ -529,6 +546,7 @@
[self _updateWholeTable]; [self _updateWholeTable];
[super setFrameSize: _minimumSize]; [super setFrameSize: _minimumSize];
} }
// //
// Adding Rows and Columns // Adding Rows and Columns
// These should be used to add more rows and columns to the GSTable. // These should be used to add more rows and columns to the GSTable.
@ -574,6 +592,7 @@
_minRowDimension[_numberOfRows - 1] = 0; _minRowDimension[_numberOfRows - 1] = 0;
} }
// TODO: -(void) insertRow: (int)row; // TODO: -(void) insertRow: (int)row;
// TODO: -(void) removeRow: (int)row; // TODO: -(void) removeRow: (int)row;
-(void) addColumn -(void) addColumn
@ -652,6 +671,7 @@
_expandColumn[aColumn] = aFlag; _expandColumn[aColumn] = aFlag;
} }
} }
-(BOOL) isXResizingEnabledForColumn: (int)aColumn -(BOOL) isXResizingEnabledForColumn: (int)aColumn
{ {
if (aColumn > (_numberOfColumns - 1)) if (aColumn > (_numberOfColumns - 1))
@ -666,6 +686,7 @@
} }
return _expandColumn[aColumn]; return _expandColumn[aColumn];
} }
-(void) setYResizingEnabled: (BOOL)aFlag -(void) setYResizingEnabled: (BOOL)aFlag
forRow: (int)aRow forRow: (int)aRow
{ {
@ -690,6 +711,7 @@
_expandRow[aRow] = aFlag; _expandRow[aRow] = aFlag;
} }
} }
-(BOOL) isYResizingEnabledForRow: (int)aRow -(BOOL) isYResizingEnabledForRow: (int)aRow
{ {
if (aRow > (_numberOfRows - 1)) if (aRow > (_numberOfRows - 1))
@ -704,6 +726,7 @@
} }
return _expandRow[aRow]; return _expandRow[aRow];
} }
// //
// Getting Row and Column Number // Getting Row and Column Number
// //
@ -711,10 +734,12 @@
{ {
return _numberOfRows; return _numberOfRows;
} }
-(int) numberOfColumns -(int) numberOfColumns
{ {
return _numberOfColumns; return _numberOfColumns;
} }
// //
// NSCoding protocol // NSCoding protocol
// //
@ -790,7 +815,10 @@
{ {
int i; int i;
[super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
if (nil == self)
return self;
[super setAutoresizesSubviews: NO]; [super setAutoresizesSubviews: NO];
if ([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
@ -1066,7 +1094,6 @@
} }
} }
// //
// After computing new theoretical sizes/positions, // After computing new theoretical sizes/positions,
// use the following methods to update the real table view // use the following methods to update the real table view
@ -1089,6 +1116,7 @@
} }
} }
} }
-(void) _updateColumnSize: (int)column -(void) _updateColumnSize: (int)column
{ {
int i; int i;
@ -1103,6 +1131,7 @@
} }
} }
} }
-(void) _updateRowOrigin: (int)row -(void) _updateRowOrigin: (int)row
{ {
int i; int i;
@ -1118,6 +1147,7 @@
} }
} }
} }
-(void) _updateColumnOrigin: (int)column -(void) _updateColumnOrigin: (int)column
{ {
int i; int i;
@ -1132,6 +1162,7 @@
} }
} }
} }
-(void) _updateWholeTable -(void) _updateWholeTable
{ {
int i,j; int i,j;
@ -1153,4 +1184,3 @@
@end @end

View file

@ -40,21 +40,27 @@
if (self == [GSVbox class]) if (self == [GSVbox class])
[self setVersion: 1]; [self setVersion: 1];
} }
// //
// Instance Methods // Instance Methods
// //
-(id) init -(id) init
{ {
[super initWithNumberOfRows: 1 self = [super initWithNumberOfRows: 1
numberOfColumns: 1]; numberOfColumns: 1];
if (nil == self)
return nil;
_haveViews = NO; _haveViews = NO;
_defaultMinYMargin = 0; _defaultMinYMargin = 0;
return self; return self;
} }
-(void) dealloc -(void) dealloc
{ {
[super dealloc]; [super dealloc];
} }
// //
// Adding Views // Adding Views
// //
@ -64,6 +70,7 @@
enablingYResizing: YES enablingYResizing: YES
withMinYMargin: _defaultMinYMargin]; withMinYMargin: _defaultMinYMargin];
} }
-(void) addView: (NSView *)aView -(void) addView: (NSView *)aView
enablingYResizing: (BOOL)aFlag enablingYResizing: (BOOL)aFlag
{ {
@ -71,6 +78,7 @@ enablingYResizing: (BOOL)aFlag
enablingYResizing: aFlag enablingYResizing: aFlag
withMinYMargin: _defaultMinYMargin]; withMinYMargin: _defaultMinYMargin];
} }
-(void) addView: (NSView *)aView -(void) addView: (NSView *)aView
withMinYMargin: (float) aMargin withMinYMargin: (float) aMargin
{ {
@ -78,6 +86,7 @@ enablingYResizing: (BOOL)aFlag
enablingYResizing: YES enablingYResizing: YES
withMinYMargin: aMargin]; withMinYMargin: aMargin];
} }
-(void) addView: (NSView *)aView -(void) addView: (NSView *)aView
enablingYResizing: (BOOL)aFlag enablingYResizing: (BOOL)aFlag
withMinYMargin: (float)aMargin withMinYMargin: (float)aMargin
@ -116,6 +125,7 @@ enablingYResizing: (BOOL)aFlag
} }
} }
// //
// Adding a Separator // Adding a Separator
// //
@ -123,6 +133,7 @@ enablingYResizing: (BOOL)aFlag
{ {
[self addSeparatorWithMinYMargin: _defaultMinYMargin]; [self addSeparatorWithMinYMargin: _defaultMinYMargin];
} }
-(void) addSeparatorWithMinYMargin: (float)aMargin -(void) addSeparatorWithMinYMargin: (float)aMargin
{ {
NSBox *separator; NSBox *separator;
@ -177,7 +188,10 @@ enablingYResizing: (BOOL)aFlag
-(id) initWithCoder: (NSCoder*)aDecoder -(id) initWithCoder: (NSCoder*)aDecoder
{ {
[super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
if (nil == self)
return nil;
if ([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
{ {
_haveViews = [aDecoder decodeBoolForKey: @"GSHaveViews"]; _haveViews = [aDecoder decodeBoolForKey: @"GSHaveViews"];

View file

@ -618,12 +618,12 @@
- (int) incrementalLoadFromData: (NSData *)data complete: (BOOL)complete - (int) incrementalLoadFromData: (NSData *)data complete: (BOOL)complete
{ {
if (!complete) if (!complete)
{ {
// we don't implement it really // we don't implement it really
return NSImageRepLoadStatusWillNeedAllData; return NSImageRepLoadStatusWillNeedAllData;
} }
return [self initWithData:data] ? NSImageRepLoadStatusCompleted : NSImageRepLoadStatusUnexpectedEOF; return [self initWithData:data] ? NSImageRepLoadStatusCompleted : NSImageRepLoadStatusUnexpectedEOF;
} }
- (void) dealloc - (void) dealloc

View file

@ -95,7 +95,9 @@ static NSTextFieldCell *titleCell;
- (id) init - (id) init
{ {
[super init]; self = [super init];
if (nil == self)
return nil;
_isLoaded = NO; _isLoaded = NO;
@ -174,7 +176,6 @@ static NSTextFieldCell *titleCell;
{ {
if ([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
{ {
} }
else else
{ {

View file

@ -106,7 +106,10 @@ static NSFont *_leafFont;
*/ */
- (id) initTextCell: (NSString *)aString - (id) initTextCell: (NSString *)aString
{ {
[super initTextCell: aString]; self = [super initTextCell: aString];
if (nil == self)
return self;
//_alternateImage = nil; //_alternateImage = nil;
//_browsercell_is_leaf = NO; //_browsercell_is_leaf = NO;
//_browsercell_is_loaded = NO; //_browsercell_is_loaded = NO;
@ -120,7 +123,10 @@ static NSFont *_leafFont;
- (id) initImageCell: (NSImage *)anImage - (id) initImageCell: (NSImage *)anImage
{ {
[super initImageCell: anImage]; self = [super initImageCell: anImage];
if (nil == self)
return self;
//_alternateImage = nil; //_alternateImage = nil;
//_browsercell_is_leaf = NO; //_browsercell_is_leaf = NO;
//_browsercell_is_loaded = NO; //_browsercell_is_loaded = NO;
@ -357,7 +363,9 @@ static NSFont *_leafFont;
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
[super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
if (nil == self)
return self;
if ([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
{ {

View file

@ -231,6 +231,9 @@ static int _gs_gui_color_picker_mode = NSRGBModeColorPanel;
backing: NSBackingStoreRetained backing: NSBackingStoreRetained
defer: NO defer: NO
screen: nil]; screen: nil];
if (nil == self)
return nil;
[self setTitle: _(@"Colors")]; [self setTitle: _(@"Colors")];
[self setBecomesKeyOnlyIfNeeded: YES]; [self setBecomesKeyOnlyIfNeeded: YES];
[self setContentMinSize: contentRect.size]; [self setContentMinSize: contentRect.size];
@ -710,7 +713,9 @@ static int _gs_gui_color_picker_mode = NSRGBModeColorPanel;
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
[super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
if (nil == self)
return nil;
return self; return self;
} }

View file

@ -255,7 +255,9 @@ static NSDataLinkPanel *_sharedDataLinkPanel;
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
[super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
if (nil == self)
return nil;
return self; return self;
} }

View file

@ -69,6 +69,8 @@ static Class defaultCellClass = nil;
cellClass: (Class)class cellClass: (Class)class
numberOfRows: (int)rowsHigh numberOfRows: (int)rowsHigh
numberOfColumns: (int)colsWide]; numberOfColumns: (int)colsWide];
if (nil == self)
return nil;
[self setIntercellSpacing: NSMakeSize (0, 4)]; [self setIntercellSpacing: NSMakeSize (0, 4)];
return self; return self;
@ -85,6 +87,8 @@ static Class defaultCellClass = nil;
prototype: (NSCell*)prototype prototype: (NSCell*)prototype
numberOfRows: (int)rowsHigh numberOfRows: (int)rowsHigh
numberOfColumns: (int)colsWide]; numberOfColumns: (int)colsWide];
if (nil == self)
return nil;
[self setIntercellSpacing: NSMakeSize (0, 4)]; [self setIntercellSpacing: NSMakeSize (0, 4)];
return self; return self;
@ -413,7 +417,9 @@ static Class defaultCellClass = nil;
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
[super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
if (nil == self)
return nil;
return self; return self;
} }

View file

@ -61,7 +61,8 @@
*/ */
- (id) initTextCell: (NSString *)aString - (id) initTextCell: (NSString *)aString
{ {
if (! ( self = [super initTextCell: @""] ) ) self = [super initTextCell: @""];
if (nil == self)
return nil; return nil;
_cell.is_bezeled = YES; _cell.is_bezeled = YES;
@ -473,7 +474,10 @@
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
[super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
if (nil == self)
return nil;
if ([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
{ {
if ([aDecoder containsValueForKey: @"NSContents"]) if ([aDecoder containsValueForKey: @"NSContents"])

View file

@ -147,6 +147,9 @@ static NSHelpPanel *_sharedPanel = nil;
styleMask: NSTitledWindowMask|NSClosableWindowMask|NSResizableWindowMask styleMask: NSTitledWindowMask|NSClosableWindowMask|NSResizableWindowMask
backing: NSBackingStoreBuffered backing: NSBackingStoreBuffered
defer: NO]; defer: NO];
if (nil == self)
return nil;
[self setReleasedWhenClosed: NO]; [self setReleasedWhenClosed: NO];
[self setTitle: _(@"Help")]; [self setTitle: _(@"Help")];
s = [[NSScrollView alloc] initWithFrame: contentRect]; s = [[NSScrollView alloc] initWithFrame: contentRect];
@ -177,6 +180,7 @@ static NSHelpPanel *_sharedPanel = nil;
else else
{ {
RELEASE(self); RELEASE(self);
RETAIN(_sharedPanel);
} }
return _sharedPanel; return _sharedPanel;
} }
@ -220,7 +224,9 @@ static NSHelpPanel *_sharedPanel = nil;
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
[super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
if (nil == self)
return nil;
return self; return self;
} }

View file

@ -188,8 +188,8 @@ static NSMapTable *viewInfo = 0;
- (id) initAsTearOff - (id) initAsTearOff
{ {
[self initWithFrame: NSZeroRect]; self = [self initWithFrame: NSZeroRect];
if (!self) if (nil == self)
return nil; return nil;
if (_attachedMenu) if (_attachedMenu)

View file

@ -615,7 +615,9 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
[super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
if (nil == self)
return nil;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_canChooseDirectories]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_canChooseDirectories];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_canChooseFiles]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_canChooseFiles];

View file

@ -205,7 +205,10 @@
{ {
BOOL flag; BOOL flag;
[super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
if (nil == self)
return nil;
if ([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
{ {
// Nothing to do here, for keyed coding this is handled by NSWindowTemplate. // Nothing to do here, for keyed coding this is handled by NSWindowTemplate.

View file

@ -196,9 +196,12 @@ setPath(NSBrowser *browser, NSString *path)
// minimum size we want it to have. Then, we resize it at the // minimum size we want it to have. Then, we resize it at the
// comfortable size of (384, 426). // comfortable size of (384, 426).
// //
[super initWithContentRect: NSMakeRect (100, 100, 308, 317) self = [super initWithContentRect: NSMakeRect (100, 100, 308, 317)
styleMask: (NSTitledWindowMask | NSResizableWindowMask) styleMask: (NSTitledWindowMask | NSResizableWindowMask)
backing: 2 defer: YES]; backing: 2 defer: YES];
if (nil == self)
return nil;
[self setMinSize: [self frame].size]; [self setMinSize: [self frame].size];
r = NSMakeRect (0, 0, 308, 317); r = NSMakeRect (0, 0, 308, 317);
@ -709,7 +712,9 @@ selectCellWithString: (NSString*)title
// complicated initializations, you get a simple panel from super. // complicated initializations, you get a simple panel from super.
-(id) init -(id) init
{ {
[self _initWithoutGModel]; self = [self _initWithoutGModel];
if (nil == self)
return nil;
/* /*
* All these are set automatically * All these are set automatically
@ -1473,6 +1478,8 @@ selectCellWithString: (NSString*)title
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
self = [super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
if (nil == self)
return nil;
// TODO // TODO
return self; return self;

View file

@ -236,6 +236,8 @@ static float buttonsOffset = 1.0; // buttonsWidth = sw - 2*buttonsOffset
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
self = [super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
if(nil == self)
return nil;
if ([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
{ {
@ -352,17 +354,19 @@ static float buttonsOffset = 1.0; // buttonsWidth = sw - 2*buttonsOffset
- (id) initWithFrame: (NSRect)frameRect - (id) initWithFrame: (NSRect)frameRect
{ {
BOOL isHorizontal;
/* /*
* determine the orientation of the scroller and adjust it's size accordingly * determine the orientation of the scroller and adjust it's size accordingly
*/ */
if (frameRect.size.width > frameRect.size.height) if (frameRect.size.width > frameRect.size.height)
{ {
_scFlags.isHorizontal = YES; isHorizontal = YES;
frameRect.size.height = [[self class] scrollerWidth]; frameRect.size.height = [[self class] scrollerWidth];
} }
else else
{ {
_scFlags.isHorizontal = NO; isHorizontal = NO;
frameRect.size.width = [[self class] scrollerWidth]; frameRect.size.width = [[self class] scrollerWidth];
} }
@ -370,6 +374,7 @@ static float buttonsOffset = 1.0; // buttonsWidth = sw - 2*buttonsOffset
if (!self) if (!self)
return nil; return nil;
_scFlags.isHorizontal = isHorizontal;
if (_scFlags.isHorizontal) if (_scFlags.isHorizontal)
{ {
_arrowsPosition = NSScrollerArrowsMinEnd; _arrowsPosition = NSScrollerArrowsMinEnd;

View file

@ -97,6 +97,9 @@
- (id) initWithFrame:(NSRect)frameRect - (id) initWithFrame:(NSRect)frameRect
{ {
self = [super initWithFrame: frameRect]; self = [super initWithFrame: frameRect];
if (nil == self)
return nil;
[self setEchosBullets: YES]; [self setEchosBullets: YES];
return self; return self;
@ -216,6 +219,9 @@
- (id) initWithCoder: (NSCoder *)decoder - (id) initWithCoder: (NSCoder *)decoder
{ {
self = [super initWithCoder: decoder]; self = [super initWithCoder: decoder];
if (nil == self)
return nil;
if ([decoder allowsKeyedCoding]) if ([decoder allowsKeyedCoding])
{ {
_echosBullets = [decoder decodeBoolForKey: @"GSEchoBullets"]; _echosBullets = [decoder decodeBoolForKey: @"GSEchoBullets"];
@ -298,7 +304,9 @@
GSSimpleSecureLayoutManager *m; GSSimpleSecureLayoutManager *m;
/* Perform the normal init. */ /* Perform the normal init. */
[super initWithFrame: frameRect textContainer: aTextContainer]; self = [super initWithFrame: frameRect textContainer: aTextContainer];
if (nil == self)
return nil;
/* Then, replace the layout manager with a /* Then, replace the layout manager with a
* GSSimpleSecureLayoutManager. */ * GSSimpleSecureLayoutManager. */

View file

@ -74,7 +74,9 @@
- (id) init - (id) init
{ {
self = [super init]; self = [super init];
if (nil == self)
return nil;
_enabled = YES; _enabled = YES;
return self; return self;

View file

@ -365,7 +365,9 @@
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
[super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
if (nil == self)
return nil;
if ([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
{ {