@@ -82,6 +82,20 @@ - (void) updateHistory
8282}
8383
8484
85+ - (void )cleanup
86+ {
87+ if (currentRevList) {
88+ [currentRevList removeObserver: self forKeyPath: @" commits" ];
89+ [currentRevList cancel ];
90+ }
91+ [graphQueue cancelAllOperations ];
92+
93+ [repository removeObserver: self forKeyPath: @" currentBranch" ];
94+ [repository removeObserver: self forKeyPath: @" currentBranchFilter" ];
95+ [repository removeObserver: self forKeyPath: @" hasChanged" ];
96+ }
97+
98+
8599- (NSArray *) projectCommits
86100{
87101 return [projectRevList.commits copy ];
@@ -137,12 +151,9 @@ - (void) resetGraphing
137151 resetCommits = YES ;
138152 self.isUpdating = YES ;
139153
140- [graphQueue setSuspended: YES ];
141- if (graphQueue)
142- [graphQueue removeObserver: self forKeyPath: @" operations" ];
154+ [graphQueue cancelAllOperations ];
143155 graphQueue = [[NSOperationQueue alloc ] init ];
144156 [graphQueue setMaxConcurrentOperationCount: 1 ];
145- [graphQueue addObserver: self forKeyPath: @" operations" options: 0 context: @" operations" ];
146157
147158 grapher = [self grapher ];
148159}
@@ -223,15 +234,12 @@ - (void) setCurrentRevList:(PBGitRevList *)parser
223234 if (currentRevList == parser)
224235 return ;
225236
226- if (currentRevList) {
237+ if (currentRevList)
227238 [currentRevList removeObserver: self forKeyPath: @" commits" ];
228- [currentRevList removeObserver: self forKeyPath: @" isParsing" ];
229- }
230239
231240 currentRevList = parser;
232241
233242 [currentRevList addObserver: self forKeyPath: @" commits" options: NSKeyValueObservingOptionNew context: @" commitsUpdated" ];
234- [currentRevList addObserver: self forKeyPath: @" isParsing" options: 0 context: @" revListParsing" ];
235243}
236244
237245
@@ -339,22 +347,6 @@ - (void) updateHistoryForRev:(PBGitRevSpecifier *)rev
339347#pragma mark -
340348#pragma mark Key Value Observing
341349
342- - (void ) removeObservers
343- {
344- [repository removeObserver: self forKeyPath: @" currentBranch" ];
345- [repository removeObserver: self forKeyPath: @" currentBranchFilter" ];
346- [repository removeObserver: self forKeyPath: @" hasChanged" ];
347-
348- if (currentRevList) {
349- [currentRevList removeObserver: self forKeyPath: @" commits" ];
350- [currentRevList removeObserver: self forKeyPath: @" isParsing" ];
351- }
352-
353- if (graphQueue)
354- [graphQueue removeObserver: self forKeyPath: @" operations" ];
355- }
356-
357-
358350- (void ) observeValueForKeyPath : (NSString *)keyPath ofObject : (id )object change : (NSDictionary *)change context : (void *)context
359351{
360352 if ([@" currentBranch" isEqualToString: context]) {
@@ -379,11 +371,6 @@ - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(
379371 return ;
380372 }
381373
382- if ([@" revListParsing" isEqualToString: context] || [@" operations" isEqualToString: context]) {
383- [self finishedGraphing ];
384- return ;
385- }
386-
387374 [super observeValueForKeyPath: keyPath ofObject: object change: change context: context];
388375}
389376
0 commit comments