Fixed different issues spotted by the static code analysis.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@32477 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2011-03-06 22:58:56 +00:00
parent 2a5554ea97
commit eb6d527983
5 changed files with 74 additions and 23 deletions

View file

@ -1,3 +1,14 @@
2011-03-06 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSMatrix.m (-_privateFrame:...numberOfColumns): Change
the init helper method to conform with the Objective-C conventions,
* Source/GSGormLoading.m (GSNibItem-initWithCoder:): Retain the
shared application before returning it.
* Source/NSDataLink.m: Correct the init methods to return a
retained object.
* Source/NSAnimation.m: Implement the copy and coding methods.
Fixed issues spotted by the static code analysis.
2011-03-05 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSHelpManager.m:

View file

@ -546,7 +546,7 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
{
if(GSObjCIsKindOf(cls, [NSApplication class]))
{
obj = [cls sharedApplication];
obj = RETAIN([cls sharedApplication]);
}
else
{

View file

@ -445,7 +445,13 @@ nsanimation_progressMarkSorter(NSAnimationProgress first, NSAnimationProgress se
- (id) copyWithZone: (NSZone*)zone
{
return [self notImplemented: _cmd];
NSAnimation *c = (NSAnimation*)NSCopyObject (self, 0, zone);
c->_progressMarks = GSIArrayCopyWithZone(_progressMarks, zone);
c->_animator = nil;
c->_isANewAnimatorNeeded = YES;
c->_isAnimatingLock = [GSLazyRecursiveLock new];
return c;
}
- (void) dealloc
@ -910,14 +916,44 @@ nsanimation_progressMarkSorter(NSAnimationProgress first, NSAnimationProgress se
_NSANIMATION_UNLOCK;
}
- (void) encodeWithCoder: (NSCoder*)coder
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[self notImplemented: _cmd];
if ([aCoder allowsKeyedCoding])
{
[aCoder encodeInt: (int)[self animationCurve]
forKey: @"NSAnimationAnimationCurve"];
[aCoder encodeDouble: [self duration]
forKey: @"NSAnimationDuration"];
}
else
{
[self notImplemented: _cmd];
}
}
- (id) initWithCoder: (NSCoder*)coder
- (id) initWithCoder: (NSCoder*)aCoder
{
return [self notImplemented: _cmd];
if ([aCoder allowsKeyedCoding])
{
NSTimeInterval duration = 1.0;
NSAnimationCurve animationCurve = 0;
if ([aCoder containsValueForKey: @"NSAnimationAnimationCurve"])
{
animationCurve = [aCoder decodeIntForKey: @"NSAnimationAnimationCurve"];
}
if ([aCoder containsValueForKey: @"NSAnimationDuration"])
{
duration = [aCoder decodeDoubleForKey: @"NSAnimationDuration"];
}
return [self initWithDuration: duration
animationCurve: animationCurve];
}
else
{
[self notImplemented: _cmd];
}
return self;
}
/*

View file

@ -64,7 +64,7 @@
NSSelection *selection = [NSSelection selectionWithDescriptionData: data];
ASSIGN(sourceSelection, selection);
}
return nil;
return self;
}
- (id)initLinkedToSourceSelection:(NSSelection *)selection
@ -82,18 +82,21 @@
- (id)initWithContentsOfFile:(NSString *)filename
{
NSData *data = AUTORELEASE([[NSData alloc] initWithContentsOfFile: filename]);
NSData *data = [[NSData alloc] initWithContentsOfFile: filename];
id object = [NSUnarchiver unarchiveObjectWithData: data];
RELEASE(data);
RELEASE(self);
return object;
return RETAIN(object);
}
- (id)initWithPasteboard:(NSPasteboard *)pasteboard
{
NSData *data = [pasteboard dataForType: NSDataLinkPboardType];
id object = [NSUnarchiver unarchiveObjectWithData: data];
RELEASE(self);
return object;
return RETAIN(object);
}
//

View file

@ -262,10 +262,10 @@ static SEL getSel;
numberOfColumns: 0];
}
- (id) _privateFrame: (NSRect)frameRect
mode: (int)aMode
numberOfRows: (int)rows
numberOfColumns: (int)cols
- (void) _privateFrame: (NSRect)frameRect
mode: (int)aMode
numberOfRows: (int)rows
numberOfColumns: (int)cols
{
_myZone = [self zone];
[self _renewRows: rows columns: cols rowSpace: 0 colSpace: 0];
@ -327,7 +327,6 @@ static SEL getSel;
_selectedCell = nil;
_selectedRow = _selectedColumn = -1;
}
return self;
}
/**<p>Initializes and returns a new NSMatrix in the specified frame frameRect.
@ -346,10 +345,11 @@ static SEL getSel;
return nil;
[self setCellClass: classId];
return [self _privateFrame: frameRect
mode: aMode
numberOfRows: rowsHigh
numberOfColumns: colsWide];
[self _privateFrame: frameRect
mode: aMode
numberOfRows: rowsHigh
numberOfColumns: colsWide];
return self;
}
/**<p>Initializes and returns a new NSMatrix in the specified frame frameRect.
@ -368,10 +368,11 @@ static SEL getSel;
return nil;
[self setPrototype: aCell];
return [self _privateFrame: frameRect
mode: aMode
numberOfRows: rowsHigh
numberOfColumns: colsWide];
[self _privateFrame: frameRect
mode: aMode
numberOfRows: rowsHigh
numberOfColumns: colsWide];
return self;
}
- (void) dealloc