Skip to content

Commit 2c6a16a

Browse files
committed
Stop a view that was not loaded from being loaded while being removed.
Example: If GitX started in stage view and the window was closed without ever looking at the history view, then [self view] will cause the history view's nib to be loaded which kicks off loading in the rev list. Wastes a lot of CPU cycles for no reason.
1 parent e4f6f96 commit 2c6a16a

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

PBViewController.h

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
NSString *status;
1818
BOOL isBusy;
19+
BOOL hasViewLoaded;
1920
}
2021

2122
@property (readonly) __weak PBGitRepository *repository;

PBViewController.m

+5-3
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,16 @@ - (id)initWithRepository:(PBGitRepository *)theRepository superController:(PBGit
2727
return self;
2828
}
2929

30-
- (void) removeView
30+
- (void)removeView
3131
{
3232
[self unbind:@"repository"];
33-
[[self view] removeFromSuperview]; // remove the current view
33+
if (hasViewLoaded)
34+
[[self view] removeFromSuperview]; // remove the current view
3435
}
3536

36-
- (void) awakeFromNib
37+
- (void)awakeFromNib
3738
{
39+
hasViewLoaded = YES;
3840
}
3941

4042
- (NSResponder *)firstResponder;

0 commit comments

Comments
 (0)