Permalink
Browse files

Don't store the windowcontroller in an iVar

There's no need to, as we can just retrieve it from
the WindowControllers array.
  • Loading branch information...
1 parent b255fb3 commit 95c4bcbaba87b1b2f7d70ac30f4e6802fc57e147 @pieter committed Sep 28, 2008
Showing with 12 additions and 8 deletions.
  1. +0 −1 PBGitRepository.h
  2. +12 −7 PBGitRepository.m
View
@@ -14,7 +14,6 @@ extern NSString* PBGitRepositoryErrorDomain;
@interface PBGitRepository : NSDocument {
PBGitRevList* revisionList;
- NSWindowController *windowController;
BOOL hasChanged;
NSMutableArray* branches;
View
@@ -19,7 +19,7 @@
@implementation PBGitRepository
-@synthesize revisionList, branches, currentBranch, refs, windowController, hasChanged;
+@synthesize revisionList, branches, currentBranch, refs, hasChanged;
static NSString* gitPath;
+ (void) initialize
@@ -149,8 +149,7 @@ - (id) initWithURL: (NSURL*) path
// 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 @@ - (NSString*)displayName
// 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 @@ - (PBGitRevSpecifier*) addBranch: (PBGitRevSpecifier*) rev
- (void) showHistoryView
{
- if (!windowController)
+ if (!self.windowController)
return;
- [((PBGitWindowController *)windowController) showHistoryView:self];
+ [((PBGitWindowController *)self.windowController) showHistoryView:self];
}
- (void) selectBranch: (PBGitRevSpecifier*) rev

0 comments on commit 95c4bcb

Please sign in to comment.