From 2c6a16a6a993f065105dcded59f883cec0cc6c19 Mon Sep 17 00:00:00 2001 From: Nathan Kinsinger Date: Sun, 20 Jun 2010 14:38:16 -0600 Subject: [PATCH] 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. --- PBViewController.h | 1 + PBViewController.m | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/PBViewController.h b/PBViewController.h index 9c15d69..6dae8af 100644 --- a/PBViewController.h +++ b/PBViewController.h @@ -16,6 +16,7 @@ NSString *status; BOOL isBusy; + BOOL hasViewLoaded; } @property (readonly) __weak PBGitRepository *repository; diff --git a/PBViewController.m b/PBViewController.m index d4c1832..717912e 100644 --- a/PBViewController.m +++ b/PBViewController.m @@ -27,14 +27,16 @@ return self; } -- (void) removeView +- (void)removeView { [self unbind:@"repository"]; - [[self view] removeFromSuperview]; // remove the current view + if (hasViewLoaded) + [[self view] removeFromSuperview]; // remove the current view } -- (void) awakeFromNib +- (void)awakeFromNib { + hasViewLoaded = YES; } - (NSResponder *)firstResponder;