@@ -82,6 +82,20 @@ - (void) updateHistory
82
82
}
83
83
84
84
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
+
85
99
- (NSArray *) projectCommits
86
100
{
87
101
return [projectRevList.commits copy ];
@@ -137,12 +151,9 @@ - (void) resetGraphing
137
151
resetCommits = YES ;
138
152
self.isUpdating = YES ;
139
153
140
- [graphQueue setSuspended: YES ];
141
- if (graphQueue)
142
- [graphQueue removeObserver: self forKeyPath: @" operations" ];
154
+ [graphQueue cancelAllOperations ];
143
155
graphQueue = [[NSOperationQueue alloc ] init ];
144
156
[graphQueue setMaxConcurrentOperationCount: 1 ];
145
- [graphQueue addObserver: self forKeyPath: @" operations" options: 0 context: @" operations" ];
146
157
147
158
grapher = [self grapher ];
148
159
}
@@ -223,15 +234,12 @@ - (void) setCurrentRevList:(PBGitRevList *)parser
223
234
if (currentRevList == parser)
224
235
return ;
225
236
226
- if (currentRevList) {
237
+ if (currentRevList)
227
238
[currentRevList removeObserver: self forKeyPath: @" commits" ];
228
- [currentRevList removeObserver: self forKeyPath: @" isParsing" ];
229
- }
230
239
231
240
currentRevList = parser;
232
241
233
242
[currentRevList addObserver: self forKeyPath: @" commits" options: NSKeyValueObservingOptionNew context: @" commitsUpdated" ];
234
- [currentRevList addObserver: self forKeyPath: @" isParsing" options: 0 context: @" revListParsing" ];
235
243
}
236
244
237
245
@@ -339,22 +347,6 @@ - (void) updateHistoryForRev:(PBGitRevSpecifier *)rev
339
347
#pragma mark -
340
348
#pragma mark Key Value Observing
341
349
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
-
358
350
- (void ) observeValueForKeyPath : (NSString *)keyPath ofObject : (id )object change : (NSDictionary *)change context : (void *)context
359
351
{
360
352
if ([@" currentBranch" isEqualToString: context]) {
@@ -379,11 +371,6 @@ - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(
379
371
return ;
380
372
}
381
373
382
- if ([@" revListParsing" isEqualToString: context] || [@" operations" isEqualToString: context]) {
383
- [self finishedGraphing ];
384
- return ;
385
- }
386
-
387
374
[super observeValueForKeyPath: keyPath ofObject: object change: change context: context];
388
375
}
389
376
0 commit comments