Skip to content

Commit 7e21c52

Browse files
committed
Merge pull request #164 from ksuther/master
Fixed lots of retain cycles which caused memory leaks
2 parents 83307f6 + 94e722b commit 7e21c52

36 files changed

+101
-57
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

Controller/PBSubmoduleController.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ - (void) reload {
5050
}
5151
}
5252

53-
submodules = loadedSubmodules;
53+
dispatch_async(dispatch_get_main_queue(), ^{
54+
[self willChangeValueForKey:@"submodules"];
55+
submodules = loadedSubmodules;
56+
[self didChangeValueForKey:@"submodules"];
57+
});
5458
});
5559
}
5660

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

GitXTextFieldCell.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212

1313
@interface GitXTextFieldCell : NSTextFieldCell {
14-
IBOutlet id<PBRefContextDelegate> contextMenuDelegate;
14+
__unsafe_unretained id<PBRefContextDelegate> contextMenuDelegate;
1515
}
1616

17+
@property(nonatomic, unsafe_unretained) IBOutlet id<PBRefContextDelegate> contextMenuDelegate;
18+
1719
@end

GitXTextFieldCell.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
@implementation GitXTextFieldCell
1515

16+
@synthesize contextMenuDelegate;
17+
1618
- (NSColor *)highlightColorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
1719
{
1820
// disables the cell's selection highlight

MGScopeBar/MGScopeBar.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
@interface MGScopeBar : NSView {
1313
@private
14-
IBOutlet id <MGScopeBarDelegate, NSObject> delegate; // weak ref.
14+
__unsafe_unretained id <MGScopeBarDelegate, NSObject> delegate; // weak ref.
1515
NSMutableArray *_separatorPositions; // x-coords of separators, indexed by their group-number.
1616
NSMutableArray *_groups; // groups of items.
1717
NSView *_accessoryView; // weak ref since it's a subview.
@@ -24,7 +24,7 @@
2424
BOOL _smartResizeEnabled; // whether to do our clever collapsing/expanding of buttons when resizing (Smart Resizing).
2525
}
2626

27-
@property(strong,nonatomic) id delegate; // should implement the MGScopeBarDelegate protocol.
27+
@property(unsafe_unretained,nonatomic) IBOutlet id delegate; // should implement the MGScopeBarDelegate protocol.
2828

2929
- (void)reloadData; // causes the scope-bar to reload all groups/items from its delegate.
3030
- (void)sizeToFit; // only resizes vertically to optimum height; does not affect width.

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

0 commit comments

Comments
 (0)