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

Diff for: Controller/PBGitResetController.h

+1-1
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

Diff for: Controller/PBSubmoduleController.h

+1-1
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

Diff for: GLFileView.h

+5-2
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;

Diff for: GLFileView.m

+2
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"];

Diff for: PBCommitList.h

+7-3
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

Diff for: PBCommitList.m

+1
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

Diff for: PBGitCommit.h

+2-2
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

Diff for: PBGitHistoryController.h

+6-12
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;

Diff for: PBGitHistoryController.m

+5-4
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"];

Diff for: PBGitHistoryGrapher.h

+1-1
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;

Diff for: PBGitHistoryList.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
@class PBGitHistoryGrapher;
1717

1818
@interface PBGitHistoryList : NSObject {
19-
PBGitRepository *repository;
19+
__unsafe_unretained PBGitRepository *repository;
2020

2121
PBGitRevList *projectRevList;
2222
PBGitRevList *currentRevList;

Diff for: PBGitHistoryList.m

+3-4
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,9 @@ - (void) updateHistory
8585

8686
- (void)cleanup
8787
{
88-
if (currentRevList) {
89-
[currentRevList removeObserver:self forKeyPath:@"commits"];
90-
[currentRevList cancel];
91-
}
88+
[currentRevList removeObserver:self forKeyPath:@"commits"];
89+
[currentRevList cancel];
90+
9291
[graphQueue cancelAllOperations];
9392

9493
[repository removeObserver:self forKeyPath:@"currentBranch"];

Diff for: PBGitRepository.m

-5
Original file line numberDiff line numberDiff line change
@@ -1965,9 +1965,4 @@ - (NSString*) parseSymbolicReference:(NSString*) reference
19651965
return nil;
19661966
}
19671967

1968-
- (void) finalize
1969-
{
1970-
//DLog(@"Dealloc of repository");
1971-
[super finalize];
1972-
}
19731968
@end

Diff for: PBGitRevList.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@interface PBGitRevList : NSObject {
1515
NSMutableArray *commits;
1616

17-
PBGitRepository *repository;
17+
__unsafe_unretained PBGitRepository *repository;
1818
PBGitRevSpecifier *currentRev;
1919
BOOL isGraphing;
2020

Diff for: PBGitRevisionCell.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@
1616
PBGitCommit *objectValue;
1717
PBGraphCellInfo *cellInfo;
1818
NSTextFieldCell *textCell;
19-
IBOutlet PBGitHistoryController *controller;
20-
IBOutlet id<PBRefContextDelegate> contextMenuDelegate;
19+
__unsafe_unretained PBGitHistoryController *controller;
20+
__unsafe_unretained id<PBRefContextDelegate> contextMenuDelegate;
2121
}
2222

23+
@property(nonatomic, unsafe_unretained) IBOutlet PBGitHistoryController *controller;
24+
@property(nonatomic, unsafe_unretained) IBOutlet id<PBRefContextDelegate> contextMenuDelegate;
25+
26+
2327
- (int) indexAtX:(float)x;
2428
- (NSRect) rectAtIndex:(int)index;
2529
- (void) drawLabelAtIndex:(int)index inRect:(NSRect)rect;

Diff for: PBGitRevisionCell.m

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
@implementation PBGitRevisionCell
1515

16+
@synthesize controller, contextMenuDelegate;
1617

1718
- (id) initWithCoder: (id) coder
1819
{

Diff for: PBGitSidebarController.m

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ - (void)closeView
9191
[commitViewController closeView];
9292
[stashViewController closeView];
9393

94+
[repository removeObserver:self forKeyPath:@"refs"];
9495
[repository removeObserver:self forKeyPath:@"currentBranch"];
9596
[repository removeObserver:self forKeyPath:@"branches"];
9697
[repository removeObserver:self forKeyPath:@"stashController.stashes"];

Diff for: PBHistorySearchController.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ typedef enum historySearchModes {
2121

2222

2323
@interface PBHistorySearchController : NSObject {
24-
PBGitHistoryController *historyController;
24+
__unsafe_unretained PBGitHistoryController *historyController;
2525
NSArrayController *commitController;
2626

2727
PBHistorySearchMode searchMode;
@@ -38,7 +38,7 @@ typedef enum historySearchModes {
3838
NSPanel *rewindPanel;
3939
}
4040

41-
@property (strong) IBOutlet PBGitHistoryController *historyController;
41+
@property (unsafe_unretained) IBOutlet PBGitHistoryController *historyController;
4242
@property (strong) IBOutlet NSArrayController *commitController;
4343

4444
@property (strong) IBOutlet NSSearchField *searchField;

Diff for: PBQLOutlineView.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
#import "PBGitHistoryController.h"
1111

1212
@interface PBQLOutlineView : NSOutlineView {
13-
IBOutlet PBGitHistoryController* controller;
13+
__unsafe_unretained PBGitHistoryController *controller;
1414
}
1515

16+
@property(nonatomic, unsafe_unretained) IBOutlet PBGitHistoryController *controller;
17+
1618
@end

Diff for: PBQLOutlineView.m

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
@implementation PBQLOutlineView
1313

14+
@synthesize controller;
15+
1416
- initWithCoder: (NSCoder *) coder
1517
{
1618
id a = [super initWithCoder:coder];

Diff for: PBQLTextView.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313

1414

1515
@interface PBQLTextView : NSTextView {
16-
IBOutlet PBGitHistoryController *controller;
16+
__unsafe_unretained PBGitHistoryController *controller;
1717
}
1818

19+
@property(nonatomic, unsafe_unretained) IBOutlet PBGitHistoryController *controller;
20+
1921
@end

Diff for: PBQLTextView.m

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
@implementation PBQLTextView
1414

15+
@synthesize controller;
16+
1517
- (void) keyDown: (NSEvent *) event
1618
{
1719
if ([[event characters] isEqualToString:@" "]) {

Diff for: PBRefController.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
@class PBRefMenuItem;
1717

1818
@interface PBRefController : NSObject <PBRefContextDelegate> {
19-
IBOutlet PBGitHistoryController *historyController;
19+
__unsafe_unretained PBGitHistoryController *historyController;
2020
IBOutlet NSArrayController *commitController;
2121
IBOutlet PBCommitList *commitList;
2222

@@ -25,6 +25,8 @@
2525
PBGitRef *actRef;
2626
}
2727

28+
@property(nonatomic, unsafe_unretained) IBOutlet PBGitHistoryController *historyController;
29+
2830
- (void) fetchRemote:(PBRefMenuItem *)sender;
2931
- (void) pullRemote:(PBRefMenuItem *)sender;
3032
- (void) pushUpdatesToRemote:(PBRefMenuItem *)sender;

Diff for: PBRefController.m

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
@implementation PBRefController
2929

30+
@synthesize historyController;
31+
3032
-(void)dealloc
3133
{
3234
actDropInfo = Nil;

Diff for: PBStashController.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
@interface PBStashController : NSObject {
1515
@private
16-
PBGitRepository *repository;
16+
__unsafe_unretained PBGitRepository *repository;
1717
}
1818

1919
- (id) initWithRepository:(PBGitRepository *) repo;

Diff for: PBViewController.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111
#import "PBGitWindowController.h"
1212

1313
@interface PBViewController : NSViewController {
14-
PBGitRepository *repository;
15-
PBGitWindowController *superController;
14+
__unsafe_unretained PBGitRepository *repository;
15+
__unsafe_unretained PBGitWindowController *superController;
1616

1717
NSString *status;
1818
BOOL isBusy;
1919
BOOL hasViewLoaded;
2020
}
2121

22-
@property (readonly) PBGitRepository *repository;
23-
@property (readonly) PBGitWindowController *superController;
22+
@property (readonly, unsafe_unretained) PBGitRepository *repository;
23+
@property (readonly, unsafe_unretained) PBGitWindowController *superController;
2424
@property(copy) NSString *status;
2525
@property(assign) BOOL isBusy;
2626

Diff for: PBWebController.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
NSMapTable *callbacks;
2121

2222
// For the repository access
23-
IBOutlet PBGitRepository *repository;
23+
IBOutlet __unsafe_unretained PBGitRepository *repository;
2424
}
2525

2626
@property (strong) NSString *startFile;
27-
@property (strong) PBGitRepository *repository;
27+
@property (unsafe_unretained) PBGitRepository *repository;
2828

2929
- (WebScriptObject *) script;
3030
- (void) closeView;

Diff for: PBWebHistoryController.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
@class PBGitHistoryController;
1313

1414
@interface PBWebHistoryController : PBWebCommitController {
15-
IBOutlet PBGitHistoryController* historyController;
15+
__unsafe_unretained PBGitHistoryController* historyController;
1616
}
1717

18+
@property(nonatomic, unsafe_unretained) IBOutlet PBGitHistoryController *historyController;
19+
1820
@end

Diff for: PBWebHistoryController.m

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
@implementation PBWebHistoryController
1414

15+
@synthesize historyController;
16+
1517
- (void) awakeFromNib
1618
{
1719
startFile = @"history";

0 commit comments

Comments
 (0)