Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3dd6385

Browse files
committedNov 26, 2008
Fix memory leaks
1 parent 2bab86c commit 3dd6385

8 files changed

+34
-0
lines changed
 

‎PBGitCommitController.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ - (void)awakeFromNib
3030
[cachedFilesController setSortDescriptors:[NSArray arrayWithObject:
3131
[[NSSortDescriptor alloc] initWithKey:@"path" ascending:true]]];
3232
}
33+
- (void) removeView
34+
{
35+
[webController closeView];
36+
[super finalize];
37+
}
3338

3439
- (void) setAmend:(BOOL)newAmend
3540
{

‎PBGitHistoryController.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ - (BOOL) hasNonlinearPath
190190
- (void) removeView
191191
{
192192
[webView close];
193+
[commitController removeObserver:self forKeyPath:@"selection"];
194+
[treeController removeObserver:self forKeyPath:@"selection"];
195+
[repository removeObserver:self forKeyPath:@"currentBranch"];
196+
193197
[super removeView];
194198
}
195199

‎PBGitRepository.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,4 +375,9 @@ - (NSString*) parseSymbolicReference:(NSString*) reference
375375
return nil;
376376
}
377377

378+
- (void) finalize
379+
{
380+
NSLog(@"Dealloc of repository");
381+
[super finalize];
382+
}
378383
@end

‎PBGitWindowController.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ - (id)initWithRepository:(PBGitRepository*)theRepository displayDefault:(BOOL)di
3333
return self;
3434
}
3535

36+
- (void)windowWillClose:(NSNotification *)notification
37+
{
38+
[viewController removeView];
39+
}
40+
3641
- (void) setSelectedViewIndex: (int) i
3742
{
3843
selectedViewIndex = i;
@@ -70,6 +75,7 @@ - (void)changeViewController:(NSInteger)whichViewTag
7075

7176
- (void)awakeFromNib
7277
{
78+
[[self window] setDelegate:self];
7379
[[self window] setAutorecalculatesContentBorderThickness:NO forEdge:NSMinYEdge];
7480
[[self window] setContentBorderThickness:35.0f forEdge:NSMinYEdge];
7581
[self showHistoryView:nil];

‎PBViewController.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ - (id)initWithRepository:(PBGitRepository *)theRepository superController:(PBGit
2727

2828
- (void) removeView
2929
{
30+
[self unbind:@"repository"];
3031
[[self view] removeFromSuperview]; // remove the current view
3132
}
3233

‎PBWebController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@
2525
@property (retain) id repository;
2626

2727
- (WebScriptObject *) script;
28+
- (void) closeView;
2829
@end

‎PBWebController.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ - (WebScriptObject *) script
3535
return [view windowScriptObject];
3636
}
3737

38+
- (void) closeView
39+
{
40+
if (view)
41+
[view close];
42+
}
43+
3844
# pragma mark Delegate methods
3945

4046
- (void) webView:(id) v didFinishLoadForFrame:(id) frame

‎PBWebHistoryController.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,10 @@ - (void)webView:(WebView *)sender decidePolicyForNewWindowAction:(NSDictionary
108108
return [historyController valueForKeyPath:[@"repository.config." stringByAppendingString:config]];
109109
}
110110

111+
- (void) finalize
112+
{
113+
[historyController removeObserver:self forKeyPath:@"webCommit"];
114+
[super finalize];
115+
}
116+
111117
@end

0 commit comments

Comments
 (0)
Please sign in to comment.