diff --git a/ChangeLog b/ChangeLog index 88db93c2d..f3cdef501 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2011-03-06 Fred Kiefer + + * 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 * Source/NSHelpManager.m: diff --git a/Source/GSGormLoading.m b/Source/GSGormLoading.m index 37d8634d0..105741c48 100644 --- a/Source/GSGormLoading.m +++ b/Source/GSGormLoading.m @@ -546,7 +546,7 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN { if(GSObjCIsKindOf(cls, [NSApplication class])) { - obj = [cls sharedApplication]; + obj = RETAIN([cls sharedApplication]); } else { diff --git a/Source/NSAnimation.m b/Source/NSAnimation.m index cde56f1c6..4a782c5fa 100644 --- a/Source/NSAnimation.m +++ b/Source/NSAnimation.m @@ -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; } /* diff --git a/Source/NSDataLink.m b/Source/NSDataLink.m index b415ef921..7084d94ef 100644 --- a/Source/NSDataLink.m +++ b/Source/NSDataLink.m @@ -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); } // diff --git a/Source/NSMatrix.m b/Source/NSMatrix.m index 6b8348f62..c0b2077ba 100644 --- a/Source/NSMatrix.m +++ b/Source/NSMatrix.m @@ -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; } /**

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; } /**

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