Skip to content

Commit 64bf8d1

Browse files
committed
Massive retain cycle breaking so view controllers and PBGitRepository get released when closing a document.
1 parent 83307f6 commit 64bf8d1

29 files changed

+73
-52
lines changed

Controller/PBGitResetController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
@protocol PBGitRefish;
1414

1515
@interface PBGitResetController : NSObject {
16-
PBGitRepository *repository;
16+
__unsafe_unretained PBGitRepository *repository;
1717
}
1818
- (id) initWithRepository:(PBGitRepository *) repo;
1919

Controller/PBSubmoduleController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
@interface PBSubmoduleController : NSObject {
1616
@private
17-
PBGitRepository *repository;
17+
__unsafe_unretained PBGitRepository *repository;
1818
NSArray *submodules;
1919
}
2020

GLFileView.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
@class PBGitGradientBarView;
1919

2020
@interface GLFileView : PBWebController <MGScopeBarDelegate> {
21-
IBOutlet PBGitHistoryController* historyController;
22-
IBOutlet MGScopeBar *typeBar;
21+
__unsafe_unretained PBGitHistoryController* historyController;
22+
__unsafe_unretained MGScopeBar *typeBar;
2323
NSMutableArray *groups;
2424
NSString *logFormat;
2525
NSString *diffType;
@@ -29,6 +29,9 @@
2929
PBGitTree *lastFile;
3030
}
3131

32+
@property(nonatomic, unsafe_unretained) IBOutlet PBGitHistoryController *historyController;
33+
@property(nonatomic, unsafe_unretained) IBOutlet MGScopeBar *typeBar;
34+
3235
- (void)showFile;
3336
- (void)didLoad;
3437
- (NSString *)parseBlame:(NSString *)txt;

GLFileView.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ + (NSString *)parseBinaryDiff:(NSString *)txt;
3030

3131
@implementation GLFileView
3232

33+
@synthesize historyController, typeBar;
34+
3335
- (void) awakeFromNib
3436
{
3537
NSString *formatFile = [[NSBundle mainBundle] pathForResource:@"format" ofType:@"html" inDirectory:@"html/views/log"];

PBCommitList.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,18 @@
1818
// delegate: PBGitHistoryController
1919
@interface PBCommitList : NSTableView {
2020
IBOutlet WebView* webView;
21-
IBOutlet PBWebHistoryController *webController;
22-
IBOutlet PBGitHistoryController *controller;
23-
IBOutlet PBHistorySearchController *searchController;
21+
__unsafe_unretained PBWebHistoryController *webController;
22+
__unsafe_unretained PBGitHistoryController *controller;
23+
__unsafe_unretained PBHistorySearchController *searchController;
2424

2525
BOOL useAdjustScroll;
2626
NSPoint mouseDownPoint;
2727
}
2828

29+
@property(nonatomic, unsafe_unretained) IBOutlet PBWebHistoryController *webController;
30+
@property(nonatomic, unsafe_unretained) IBOutlet PBGitHistoryController *controller;
31+
@property(nonatomic, unsafe_unretained) IBOutlet PBHistorySearchController *searchController;
32+
2933
@property (readonly) NSPoint mouseDownPoint;
3034
@property (assign) BOOL useAdjustScroll;
3135
@end

PBCommitList.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
@implementation PBCommitList
1515

16+
@synthesize webController, controller, searchController;
1617
@synthesize mouseDownPoint;
1718
@synthesize useAdjustScroll;
1819

PBGitCommit.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extern NSString * const kGitXCommitType;
2929
int timestamp;
3030
char sign;
3131
id lineInfo;
32-
PBGitRepository* repository;
32+
__unsafe_unretained PBGitRepository* repository;
3333
}
3434

3535
+ (PBGitCommit *)commitWithRepository:(PBGitRepository*)repo andSha:(NSString *)newSha;
@@ -65,6 +65,6 @@ extern NSString * const kGitXCommitType;
6565
@property (readonly) NSString* details;
6666
@property (readonly) PBGitTree* tree;
6767
@property (readonly) NSArray* treeContents;
68-
@property (strong) PBGitRepository* repository;
68+
@property (unsafe_unretained) PBGitRepository* repository;
6969
@property (strong) id lineInfo;
7070
@end

PBGitHistoryController.h

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,12 @@
2323

2424
// Controls the split history view from PBGitHistoryView.xib
2525
@interface PBGitHistoryController : PBViewController PROTOCOL_10_6(NSOutlineViewDelegate){
26-
IBOutlet PBRefController *refController;
2726
IBOutlet NSSearchField *searchField;
28-
IBOutlet NSArrayController* commitController;
2927
IBOutlet NSSearchField *filesSearchField;
30-
IBOutlet NSTreeController* treeController;
3128
IBOutlet NSOutlineView* fileBrowser;
3229
NSArray *currentFileBrowserSelectionPath;
33-
IBOutlet PBCommitList* commitList;
34-
IBOutlet NSSplitView *historySplitView;
3530
IBOutlet PBWebHistoryController *webHistoryController;
3631
QLPreviewPanel* previewPanel;
37-
IBOutlet PBHistorySearchController *searchController;
3832
IBOutlet GLFileView *fileView;
3933

4034
IBOutlet PBGitGradientBarView *upperToolbarView;
@@ -57,15 +51,15 @@
5751
PBGitCommit *selectedCommitBeforeRefresh;
5852
}
5953

60-
@property (readonly) NSTreeController* treeController;
61-
@property (readonly) NSSplitView *historySplitView;
54+
@property (unsafe_unretained) IBOutlet NSTreeController* treeController;
55+
@property (unsafe_unretained) IBOutlet NSSplitView *historySplitView;
6256
@property (nonatomic,assign) int selectedCommitDetailsIndex;
6357
@property (strong) PBGitCommit *webCommit;
6458
@property (strong) PBGitTree* gitTree;
65-
@property (readonly) NSArrayController *commitController;
66-
@property (readonly) PBRefController *refController;
67-
@property (readonly) PBHistorySearchController *searchController;
68-
@property (readonly) PBCommitList *commitList;
59+
@property (unsafe_unretained) IBOutlet NSArrayController *commitController;
60+
@property (unsafe_unretained) IBOutlet PBRefController *refController;
61+
@property (unsafe_unretained) IBOutlet PBHistorySearchController *searchController;
62+
@property (unsafe_unretained) PBCommitList *commitList;
6963

7064
- (IBAction) setDetailedView:(id)sender;
7165
- (IBAction) setTreeView:(id)sender;

PBGitHistoryController.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,11 +483,12 @@ - (void)closeView
483483
{
484484
[self saveSplitViewPosition];
485485

486-
if (commitController) {
487-
[commitController removeObserver:self forKeyPath:@"selection"];
488-
[commitController removeObserver:self forKeyPath:@"arrangedObjects.@count"];
489-
[treeController removeObserver:self forKeyPath:@"selection"];
486+
[commitController removeObserver:self forKeyPath:@"selection"];
487+
[commitController removeObserver:self forKeyPath:@"arrangedObjects.@count"];
488+
[treeController removeObserver:self forKeyPath:@"selection"];
490489

490+
//Only stop these observations if the nib got loaded
491+
if ([self treeController]) {
491492
[repository.revisionList removeObserver:self forKeyPath:@"isUpdating"];
492493
[repository removeObserver:self forKeyPath:@"currentBranch"];
493494
[repository removeObserver:self forKeyPath:@"refs"];

PBGitHistoryGrapher.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
@interface PBGitHistoryGrapher : NSObject {
20-
id delegate;
20+
__unsafe_unretained id delegate;
2121
NSOperationQueue *currentQueue;
2222

2323
NSMutableSet *searchSHAs;

0 commit comments

Comments
 (0)