From 95c4bcbaba87b1b2f7d70ac30f4e6802fc57e147 Mon Sep 17 00:00:00 2001 From: Pieter de Bie Date: Sun, 28 Sep 2008 13:31:47 +0200 Subject: [PATCH] Don't store the windowcontroller in an iVar There's no need to, as we can just retrieve it from the WindowControllers array. --- PBGitRepository.h | 1 - PBGitRepository.m | 19 ++++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/PBGitRepository.h b/PBGitRepository.h index 509a0a6..c636e79 100644 --- a/PBGitRepository.h +++ b/PBGitRepository.h @@ -14,7 +14,6 @@ extern NSString* PBGitRepositoryErrorDomain; @interface PBGitRepository : NSDocument { PBGitRevList* revisionList; - NSWindowController *windowController; BOOL hasChanged; NSMutableArray* branches; diff --git a/PBGitRepository.m b/PBGitRepository.m index 637058e..a561cf6 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -19,7 +19,7 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; @implementation PBGitRepository -@synthesize revisionList, branches, currentBranch, refs, windowController, hasChanged; +@synthesize revisionList, branches, currentBranch, refs, hasChanged; static NSString* gitPath; + (void) initialize @@ -149,8 +149,7 @@ static NSString* gitPath; // We don't want the window controller to display anything yet.. // We'll leave that to the caller of this method. - windowController = [[PBGitWindowController alloc] initWithRepository:self displayDefault:NO]; - [self addWindowController:windowController]; + [self addWindowController:[[PBGitWindowController alloc] initWithRepository:self displayDefault:NO]]; [self showWindows]; return self; @@ -169,10 +168,16 @@ static NSString* gitPath; // Overridden to create our custom window controller - (void)makeWindowControllers { - windowController = [[PBGitWindowController alloc] initWithRepository:self displayDefault:YES]; - [self addWindowController:windowController]; + [self addWindowController: [[PBGitWindowController alloc] initWithRepository:self displayDefault:YES]]; } +- (NSWindowController *)windowController +{ + if ([[self windowControllers] count] == 0) + return NULL; + + return [[self windowControllers] objectAtIndex:0]; +} - (void) addRef: (PBGitRef *) ref fromParameters: (NSArray *) components { @@ -263,10 +268,10 @@ static NSString* gitPath; - (void) showHistoryView { - if (!windowController) + if (!self.windowController) return; - [((PBGitWindowController *)windowController) showHistoryView:self]; + [((PBGitWindowController *)self.windowController) showHistoryView:self]; } - (void) selectBranch: (PBGitRevSpecifier*) rev