From: <ho...@us...> - 2011-04-05 11:06:25
|
Revision: 7199 http://skim-app.svn.sourceforge.net/skim-app/?rev=7199&view=rev Author: hofman Date: 2011-04-05 11:06:16 +0000 (Tue, 05 Apr 2011) Log Message: ----------- refactor init, separate assignment from check of self Modified Paths: -------------- trunk/SKAnimatedBorderlessWindow.m trunk/SKDocumentController.m trunk/SKDownload.m trunk/SKDownloadController.m trunk/SKFileUpdateChecker.m trunk/SKFindController.m trunk/SKFullScreenWindow.m trunk/SKInfoWindowController.m trunk/SKLine.m trunk/SKLineInspector.m trunk/SKMainDocument.m trunk/SKMainWindowController.m trunk/SKNoteText.m trunk/SKNoteTypeSheetController.m trunk/SKNoteWindowController.m trunk/SKNotesDocument.m trunk/SKPDFSyncRecord.m trunk/SKPDFSynchronizerServer.m trunk/SKPreferenceController.m trunk/SKPresentationOptionsSheetController.m trunk/SKReadingBar.m trunk/SKRichTextFormat.m trunk/SKSnapshotWindowController.m trunk/SKTransitionController.m trunk/SKVersionNumber.m Modified: trunk/SKAnimatedBorderlessWindow.m =================================================================== --- trunk/SKAnimatedBorderlessWindow.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKAnimatedBorderlessWindow.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -50,7 +50,8 @@ @dynamic defaultAlphaValue, fadeInDuration, fadeOutDuration, autoHideTimeInterval; - (id)initWithContentRect:(NSRect)contentRect { - if (self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]) { + self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; + if (self) { [self setBackgroundColor:[NSColor clearColor]]; [self setOpaque:NO]; [self setAlphaValue:[self defaultAlphaValue]]; Modified: trunk/SKDocumentController.m =================================================================== --- trunk/SKDocumentController.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKDocumentController.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -98,7 +98,8 @@ } - (id)init { - if (self = [super init]) { + self = [super init]; + if (self) { [self setAutosavingDelay:[[NSUserDefaults standardUserDefaults] doubleForKey:SKAutosaveIntervalKey]]; } return self; Modified: trunk/SKDownload.m =================================================================== --- trunk/SKDownload.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKDownload.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -92,7 +92,8 @@ } - (id)initWithURL:(NSURL *)aURL delegate:(id <SKDownloadDelegate>)aDelegate { - if (self = [super init]) { + self = [super init]; + if (self) { URL = [aURL retain]; URLDownload = nil; filePath = nil; Modified: trunk/SKDownloadController.m =================================================================== --- trunk/SKDownloadController.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKDownloadController.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -82,7 +82,8 @@ - (id)init { if (sharedDownloadController) NSLog(@"Attempt to allocate second instance of %@", self); - if (self = [super initWithWindowNibName:@"DownloadsWindow"]) { + self = [super initWithWindowNibName:@"DownloadsWindow"]; + if (self) { downloads = [[NSMutableArray alloc] init]; } return self; Modified: trunk/SKFileUpdateChecker.m =================================================================== --- trunk/SKFileUpdateChecker.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKFileUpdateChecker.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -65,7 +65,8 @@ @synthesize document; - (id)initForDocument:(NSDocument *)aDocument { - if (self = [super init]) { + self = [super init]; + if (self) { document = aDocument; [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKey:SKAutoCheckFileUpdateKey context:&SKFileUpdateCheckerDefaultsObservationContext]; } Modified: trunk/SKFindController.m =================================================================== --- trunk/SKFindController.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKFindController.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -57,7 +57,8 @@ - (id)init { if (sharedFindController) NSLog(@"Attempt to allocate second instance of %@", self); - if (self = [super initWithWindowNibName:@"FindPanel"]) { + self = [super initWithWindowNibName:@"FindPanel"]; + if (self) { ignoreCase = YES; } return self; Modified: trunk/SKFullScreenWindow.m =================================================================== --- trunk/SKFullScreenWindow.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKFullScreenWindow.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -159,7 +159,8 @@ @implementation SKMainFullScreenWindow - (id)initWithScreen:(NSScreen *)screen backgroundColor:(NSColor *)backgroundColor level:(NSInteger)level { - if (self = [super initWithScreen:screen backgroundColor:backgroundColor level:level]) { + self = [super initWithScreen:screen backgroundColor:backgroundColor level:level]; + if (self) { [self setDisplaysWhenScreenProfileChanges:YES]; [self setAcceptsMouseMovedEvents:YES]; [self setExcludedFromWindowsMenu:NO]; Modified: trunk/SKInfoWindowController.m =================================================================== --- trunk/SKInfoWindowController.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKInfoWindowController.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -90,7 +90,8 @@ - (id)init { if (sharedInstance) NSLog(@"Attempt to allocate second instance of %@", self); - if (self = [super initWithWindowNibName:@"InfoWindow"]){ + self = [super initWithWindowNibName:@"InfoWindow"]; + if (self){ info = nil; summaryKeys = [[NSArray alloc] initWithObjects: SKInfoFileNameKey, Modified: trunk/SKLine.m =================================================================== --- trunk/SKLine.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKLine.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -46,7 +46,8 @@ @dynamic scriptingIndex; - (id)initWithIndex:(NSInteger)anIndex { - if (self = [super init]) { + self = [super init]; + if (self) { index = anIndex; } return self; Modified: trunk/SKLineInspector.m =================================================================== --- trunk/SKLineInspector.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKLineInspector.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -72,7 +72,8 @@ - (id)init { if (sharedLineInspector) NSLog(@"Attempt to allocate second instance of %@", self); - if (self = [super initWithWindowNibName:@"LineInspector"]) { + self = [super initWithWindowNibName:@"LineInspector"]; + if (self) { style = kPDFBorderStyleSolid; lineWidth = 1.0; dashPattern = nil; Modified: trunk/SKMainDocument.m =================================================================== --- trunk/SKMainDocument.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKMainDocument.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -153,7 +153,8 @@ + (BOOL)isPDFDocument { return YES; } - (id)init { - if (self = [super init]) { + self = [super init]; + if (self) { fileUpdateChecker = [[SKFileUpdateChecker alloc] initForDocument:self]; } return self; @@ -2014,7 +2015,8 @@ @synthesize pdfDocument, noteDicts, presentationOptions, openMetaTags, openMetaRating; - (id)init { - if (self = [super init]) { + self = [super init]; + if (self) { pdfDocument = nil; noteDicts = nil; presentationOptions = nil; Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKMainWindowController.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -220,7 +220,8 @@ } - (id)init { - if (self = [super initWithWindowNibName:@"MainWindow"]) { + self = [super initWithWindowNibName:@"MainWindow"]; + if (self) { interactionMode = SKNormalMode; searchResults = [[NSMutableArray alloc] init]; mwcFlags.findPanelFind = 0; Modified: trunk/SKNoteText.m =================================================================== --- trunk/SKNoteText.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKNoteText.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -46,7 +46,8 @@ @dynamic texts, type, page, pageIndex, string, text; - (id)initWithNote:(id)aNote { - if (self = [super init]) { + self = [super init]; + if (self) { note = aNote; } return self; Modified: trunk/SKNoteTypeSheetController.m =================================================================== --- trunk/SKNoteTypeSheetController.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKNoteTypeSheetController.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -57,7 +57,8 @@ @dynamic noteTypes; - (id)init { - if (self = [super initWithWindowNibName:@"NoteTypeSheet"]) { + self = [super initWithWindowNibName:@"NoteTypeSheet"]; + if (self) { noteTypeMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] init]; NSArray *noteTypes = [NSArray arrayWithObjects:SKNFreeTextString, SKNNoteString, SKNCircleString, SKNSquareString, SKNHighlightString, SKNUnderlineString, SKNStrikeOutString, SKNLineString, SKNInkString, nil]; NSMenuItem *menuItem; Modified: trunk/SKNoteWindowController.m =================================================================== --- trunk/SKNoteWindowController.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKNoteWindowController.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -104,7 +104,8 @@ } - (id)initWithNote:(PDFAnnotation *)aNote { - if (self = [super initWithWindowNibName:@"NoteWindow"]) { + self = [super initWithWindowNibName:@"NoteWindow"]; + if (self) { note = [aNote retain]; keepOnTop = [[NSUserDefaults standardUserDefaults] boolForKey:SKKeepNoteWindowsOnTopKey]; Modified: trunk/SKNotesDocument.m =================================================================== --- trunk/SKNotesDocument.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKNotesDocument.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -89,7 +89,8 @@ @synthesize outlineView, arrayController, searchField, notes, pdfDocument, sourceFileURL; - (id)init { - if (self = [super init]) { + self = [super init]; + if (self) { notes = [[NSArray alloc] init]; pdfDocument = nil; rowHeights = [[SKFloatMapTable alloc] init]; Modified: trunk/SKPDFSyncRecord.m =================================================================== --- trunk/SKPDFSyncRecord.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKPDFSyncRecord.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -46,7 +46,8 @@ @dynamic x, y; - (id)initWithRecordIndex:(NSInteger)aRecordIndex { - if (self = [super init]) { + self = [super init]; + if (self) { recordIndex = aRecordIndex; pageIndex = NSNotFound; point = NSZeroPoint; @@ -76,7 +77,8 @@ @implementation SKPDFSyncRecords - (id)init { - if (self = [super init]) { + self = [super init]; + if (self) { records = NSCreateMapTable(NSIntegerMapKeyCallBacks, NSObjectMapValueCallBacks, 0); } return self; Modified: trunk/SKPDFSynchronizerServer.m =================================================================== --- trunk/SKPDFSynchronizerServer.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKPDFSynchronizerServer.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -71,7 +71,8 @@ } - (id)init { - if (self = [super init]) { + self = [super init]; + if (self) { fileName = nil; syncFileName = nil; lastModDate = nil; Modified: trunk/SKPreferenceController.m =================================================================== --- trunk/SKPreferenceController.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKPreferenceController.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -74,7 +74,8 @@ - (id)init { if (sharedPrefenceController == nil) { - if (self = [super initWithWindowNibName:@"PreferenceWindow"]) { + self = [super initWithWindowNibName:@"PreferenceWindow"]; + if (self) { preferencePanes = [[NSArray alloc] initWithObjects: [[[SKGeneralPreferences alloc] init] autorelease], [[[SKDisplayPreferences alloc] init] autorelease], Modified: trunk/SKPresentationOptionsSheetController.m =================================================================== --- trunk/SKPresentationOptionsSheetController.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKPresentationOptionsSheetController.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -72,7 +72,8 @@ @dynamic pageTransitions, notesDocument, isScrolling; - (id)initForController:(SKMainWindowController *)aController { - if (self = [super init]) { + self = [super init]; + if (self) { controller = aController; separate = NO; transition = [[SKTransitionInfo alloc] init]; Modified: trunk/SKReadingBar.m =================================================================== --- trunk/SKReadingBar.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKReadingBar.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -46,7 +46,8 @@ @dynamic currentLastLine, currentBounds; - (id)initWithPage:(PDFPage *)aPage { - if (self = [super init]) { + self = [super init]; + if (self) { numberOfLines = 1; lineRects = nil; currentLine = -1; Modified: trunk/SKRichTextFormat.m =================================================================== --- trunk/SKRichTextFormat.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKRichTextFormat.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -54,7 +54,8 @@ } - (id)initWithData:(NSData *)aData { - if (self = [super init]) { + self = [super init]; + if (self) { if (aData) { data = [aData retain]; } else { Modified: trunk/SKSnapshotWindowController.m =================================================================== --- trunk/SKSnapshotWindowController.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKSnapshotWindowController.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -552,7 +552,8 @@ @implementation SKSnapshotWindow - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation { - if (self = [super initWithContentRect:contentRect styleMask:styleMask backing:bufferingType defer:deferCreation]) { + self = [super initWithContentRect:contentRect styleMask:styleMask backing:bufferingType defer:deferCreation]; + if (self) { [[self standardWindowButton:NSWindowMiniaturizeButton] setEnabled:YES]; } return self; Modified: trunk/SKTransitionController.m =================================================================== --- trunk/SKTransitionController.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKTransitionController.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -523,7 +523,8 @@ @dynamic currentImage; - (id)initWithFilter:(CIFilter *)aFilter duration:(NSTimeInterval)duration { - if (self = [super initWithDuration:duration animationCurve:NSAnimationEaseInOut]) { + self = [super initWithDuration:duration animationCurve:NSAnimationEaseInOut]; + if (self) { filter = [aFilter retain]; } return self; Modified: trunk/SKVersionNumber.m =================================================================== --- trunk/SKVersionNumber.m 2011-04-04 20:42:17 UTC (rev 7198) +++ trunk/SKVersionNumber.m 2011-04-05 11:06:16 UTC (rev 7199) @@ -57,7 +57,8 @@ - (id)initWithVersionString:(NSString *)versionString; { - if (self = [super init]) { + self = [super init]; + if (self) { // Input might be from a NSBundle info dictionary that could be misconfigured, so check at runtime too if (versionString == nil || [versionString isKindOfClass:[NSString class]] == NO) { [self release]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |