Skip to content

Commit 6d83491

Browse files
committed
Fix __bridge stuff with NSAlert async stuff
1 parent 5e1efbf commit 6d83491

8 files changed

+56
-79
lines changed

PBGitHistoryController.m

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,8 @@ - (void) saveFileBrowserSelection
219219
}
220220
}
221221

222-
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)ctx
222+
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(NSString *)context
223223
{
224-
NSString *context = (__bridge NSString *)ctx;
225-
226224
if ([context isEqualToString: @"commitChange"]) {
227225
[self updateKeys];
228226
[self restoreFileBrowserSelection];
@@ -264,7 +262,7 @@ - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(
264262
return;
265263
}
266264

267-
[super observeValueForKeyPath:keyPath ofObject:object change:change context:ctx];
265+
[super observeValueForKeyPath:keyPath ofObject:object change:change context:(__bridge void *)context];
268266
}
269267

270268
- (IBAction) openSelectedFile:(id)sender

PBGitIndexController.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,14 @@ - (void) showInFinderAction:(id) sender
196196
[ws selectFile: path inFileViewerRootedAtPath:nil];
197197
}
198198

199-
- (void) discardChangesForFilesAlertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
199+
- (void)discardChangesForFilesAlertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
200200
{
201+
id files = (__bridge_transfer NSString *)contextInfo;
202+
201203
[[alert window] orderOut:nil];
202204

203205
if (returnCode == NSAlertDefaultReturn) {
204-
[commitController.index discardChangesForFiles:(__bridge NSArray *)(contextInfo)];
206+
[commitController.index discardChangesForFiles:files];
205207
}
206208
}
207209

@@ -216,7 +218,7 @@ - (void) discardChangesForFiles:(NSArray *)files force:(BOOL)force
216218
[alert beginSheetModalForWindow:[[commitController view] window]
217219
modalDelegate:self
218220
didEndSelector:@selector(discardChangesForFilesAlertDidEnd:returnCode:contextInfo:)
219-
contextInfo:(__bridge void *)(files)];
221+
contextInfo:(__bridge_retained void *)files];
220222
} else {
221223
[commitController.index discardChangesForFiles:files];
222224
}

PBGitSidebarController.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ - (void)closeView
7272
[super closeView];
7373
}
7474

75-
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
75+
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(NSString *)context
7676
{
77-
if ([@"currentBranchChange" isEqualToString:(__bridge NSString *)(context)]) {
77+
if ([@"currentBranchChange" isEqualToString:context]) {
7878
[sourceView reloadData];
7979
[self selectCurrentBranch];
8080
return;
8181
}
8282

83-
if ([@"branchesModified" isEqualToString:(__bridge NSString *)(context)]) {
83+
if ([@"branchesModified" isEqualToString:context]) {
8484
NSInteger changeKind = [(NSNumber *)[change objectForKey:NSKeyValueChangeKindKey] intValue];
8585

8686
if (changeKind == NSKeyValueChangeInsertion) {
@@ -99,7 +99,7 @@ - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(
9999
return;
100100
}
101101

102-
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
102+
[super observeValueForKeyPath:keyPath ofObject:object change:change context:(__bridge void *)context];
103103
}
104104

105105
- (PBSourceViewItem *) selectedItem

PBGitWindowController.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,14 @@ - (void) updateStatus
181181
}
182182
}
183183

184-
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
184+
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(NSString *)context
185185
{
186-
if ([(__bridge NSString *)context isEqualToString:@"statusChange"]) {
186+
if ([context isEqualToString:@"statusChange"]) {
187187
[self updateStatus];
188188
return;
189189
}
190190

191-
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
191+
[super observeValueForKeyPath:keyPath ofObject:object change:change context:(__bridge void *)context];
192192
}
193193

194194
- (void)setHistorySearch:(NSString *)searchString mode:(NSInteger)mode

PBHistorySearchController.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@ - (void)awakeFromNib
132132
[commitController addObserver:self forKeyPath:@"arrangedObjects" options:0 context:kGitXSearchArrangedObjectsContext];
133133
}
134134

135-
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
135+
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(NSString *)context
136136
{
137-
if ([(__bridge NSString *)context isEqualToString:kGitXSearchArrangedObjectsContext]) {
137+
if ([context isEqualToString:kGitXSearchArrangedObjectsContext]) {
138138
// the objects in the commitlist changed so the result indexes are no longer valid
139139
[self clearSearch];
140140
return;
141141
}
142142

143-
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
143+
[super observeValueForKeyPath:keyPath ofObject:object change:change context:(__bridge void *)context];
144144
}
145145

146146

PBRefController.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,17 +226,19 @@ - (BOOL)tableView:(NSTableView *)aTableView
226226
[alert beginSheetModalForWindow:[historyController.repository.windowController window]
227227
modalDelegate:self
228228
didEndSelector:@selector(acceptDropInfoAlertDidEnd:returnCode:contextInfo:)
229-
contextInfo:(__bridge void *)(dropInfo)];
229+
contextInfo:(__bridge_retained void *)dropInfo];
230230

231231
return YES;
232232
}
233233

234234
- (void)acceptDropInfoAlertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
235235
{
236+
NSDictionary *refs = (__bridge_transfer id)contextInfo;
237+
236238
[[alert window] orderOut:nil];
237239

238240
if (returnCode == NSAlertDefaultReturn)
239-
[self dropRef:(__bridge NSDictionary *)(contextInfo)];
241+
[self dropRef:refs];
240242

241243
if ([[alert suppressionButton] state] == NSOnState)
242244
[PBGitDefaults suppressDialogWarningForDialog:kDialogAcceptDroppedRef];

PBWebChangesController.m

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
#import "PBGitIndexController.h"
1111
#import "PBGitIndex.h"
1212

13+
14+
1315
@implementation PBWebChangesController
1416

15-
- (void) awakeFromNib
16-
{
17+
- (void)awakeFromNib {
1718
selectedFile = nil;
1819
selectedFileIsCached = NO;
1920

@@ -24,26 +25,20 @@ - (void) awakeFromNib
2425
[cachedFilesController addObserver:self forKeyPath:@"selection" options:0 context:@"cachedFileSelected"];
2526
}
2627

27-
- (void)closeView
28-
{
28+
- (void)closeView {
2929
[[self script] removeWebScriptKey:@"Index"];
3030
[unstagedFilesController removeObserver:self forKeyPath:@"selection"];
3131
[cachedFilesController removeObserver:self forKeyPath:@"selection"];
3232

3333
[super closeView];
3434
}
3535

36-
- (void) didLoad
37-
{
36+
- (void)didLoad {
3837
[[self script] setValue:controller.index forKey:@"Index"];
3938
[self refresh];
4039
}
4140

42-
- (void)observeValueForKeyPath:(NSString *)keyPath
43-
ofObject:(id)object
44-
change:(NSDictionary *)change
45-
context:(void *)context
46-
{
41+
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
4742
NSArrayController *otherController;
4843
otherController = object == unstagedFilesController ? cachedFilesController : unstagedFilesController;
4944
int count = [[object selectedObjects] count];
@@ -70,13 +65,11 @@ - (void)observeValueForKeyPath:(NSString *)keyPath
7065
[self refresh];
7166
}
7267

73-
- (void) showMultiple: (NSArray *)objects
74-
{
68+
- (void)showMultiple:(NSArray *)objects {
7569
[[self script] callWebScriptMethod:@"showMultipleFilesSelection" withArguments:[NSArray arrayWithObject:objects]];
7670
}
7771

78-
- (void) refresh
79-
{
72+
- (void)refresh {
8073
if (!finishedLoading)
8174
return;
8275

@@ -86,30 +79,26 @@ - (void) refresh
8679
[NSNumber numberWithBool:selectedFileIsCached], nil]];
8780
}
8881

89-
- (void)stageHunk:(NSString *)hunk reverse:(BOOL)reverse
90-
{
82+
- (void)stageHunk:(NSString *)hunk reverse:(BOOL)reverse {
9183
[controller.index applyPatch:hunk stage:YES reverse:reverse];
9284
// FIXME: Don't need a hard refresh
9385

9486
[self refresh];
9587
}
9688

97-
- (void) discardHunk:(NSString *)hunk
98-
{
89+
- (void) discardHunk:(NSString *)hunk {
9990
[controller.index applyPatch:hunk stage:NO reverse:YES];
10091
[self refresh];
10192
}
10293

103-
- (void) discardHunkAlertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
104-
{
94+
- (void) discardHunkAlertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo {
95+
id hunk = (__bridge_transfer NSString *)contextInfo;
10596
[[alert window] orderOut:nil];
106-
10797
if (returnCode == NSAlertDefaultReturn)
108-
[self discardHunk:(__bridge NSString *)contextInfo];
98+
[self discardHunk:hunk];
10999
}
110100

111-
- (void)discardHunk:(NSString *)hunk altKey:(BOOL)altKey
112-
{
101+
- (void)discardHunk:(NSString *)hunk altKey:(BOOL)altKey {
113102
if (!altKey) {
114103
NSAlert *alert = [NSAlert alertWithMessageText:@"Discard hunk"
115104
defaultButton:nil
@@ -119,14 +108,13 @@ - (void)discardHunk:(NSString *)hunk altKey:(BOOL)altKey
119108
[alert beginSheetModalForWindow:[[controller view] window]
120109
modalDelegate:self
121110
didEndSelector:@selector(discardHunkAlertDidEnd:returnCode:contextInfo:)
122-
contextInfo:(__bridge void *)hunk];
111+
contextInfo:(__bridge_retained void *)hunk];
123112
} else {
124113
[self discardHunk:hunk];
125114
}
126115
}
127116

128-
- (void) setStateMessage:(NSString *)state
129-
{
117+
- (void) setStateMessage:(NSString *)state {
130118
id script = [view windowScriptObject];
131119
[script callWebScriptMethod:@"setState" withArguments: [NSArray arrayWithObject:state]];
132120
}

PBWebHistoryController.m

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,39 @@
1010
#import "PBGitDefaults.h"
1111
#import "PBGitSHA.h"
1212

13-
@implementation PBWebHistoryController
1413

14+
15+
@implementation PBWebHistoryController
1516
@synthesize diff;
1617

17-
- (void) awakeFromNib
18-
{
18+
- (void)awakeFromNib {
1919
startFile = @"history";
2020
repository = historyController.repository;
2121
[super awakeFromNib];
2222
[historyController addObserver:self forKeyPath:@"webCommit" options:0 context:@"ChangedCommit"];
2323
}
2424

25-
- (void)closeView
26-
{
25+
- (void)closeView {
2726
[[self script] setValue:nil forKey:@"commit"];
2827
[historyController removeObserver:self forKeyPath:@"webCommit"];
29-
3028
[super closeView];
3129
}
3230

33-
- (void) didLoad
34-
{
31+
- (void)didLoad {
3532
currentSha = nil;
3633
[self changeContentTo: historyController.webCommit];
3734
}
3835

39-
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
36+
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(NSString *)context
4037
{
41-
if ([(__bridge NSString *)context isEqualToString: @"ChangedCommit"])
42-
[self changeContentTo: historyController.webCommit];
43-
else
44-
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
38+
if ([context isEqualToString:@"ChangedCommit"]) {
39+
[self changeContentTo:historyController.webCommit];
40+
} else {
41+
[super observeValueForKeyPath:keyPath ofObject:object change:change context:(__bridge void *)context];
42+
}
4543
}
4644

47-
- (void) changeContentTo: (PBGitCommit *) content
45+
- (void)changeContentTo:(PBGitCommit *)content
4846
{
4947
if (content == nil || !finishedLoading)
5048
return;
@@ -99,28 +97,23 @@ - (void)commitDetailsLoaded:(NSNotification *)notification
9997
[[view windowScriptObject] callWebScriptMethod:@"loadCommitDetails" withArguments:[NSArray arrayWithObject:details]];
10098
}
10199

102-
- (void)selectCommit:(NSString *)sha
103-
{
100+
- (void)selectCommit:(NSString *)sha {
104101
[historyController selectCommit:[PBGitSHA shaWithString:sha]];
105102
}
106103

107-
- (void) sendKey: (NSString*) key
108-
{
104+
- (void)sendKey:(NSString *)key {
109105
id script = [view windowScriptObject];
110106
[script callWebScriptMethod:@"handleKeyFromCocoa" withArguments: [NSArray arrayWithObject:key]];
111107
}
112108

113-
- (void) copySource
114-
{
109+
- (void)copySource {
115110
NSString *source = [(DOMHTMLElement *)[[[view mainFrame] DOMDocument] documentElement] outerHTML];
116111
NSPasteboard *a =[NSPasteboard generalPasteboard];
117112
[a declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:self];
118113
[a setString:source forType: NSStringPboardType];
119114
}
120115

121-
- (NSArray *) webView:(WebView *)sender
122-
contextMenuItemsForElement:(NSDictionary *)element
123-
defaultMenuItems:(NSArray *)defaultMenuItems
116+
- (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems
124117
{
125118
DOMNode *node = [element valueForKey:@"WebElementDOMNode"];
126119

@@ -156,22 +149,16 @@ - (NSArray *) webView:(WebView *)sender
156149

157150

158151
// Open external links in the default browser
159-
- (void)webView:(WebView *)sender decidePolicyForNewWindowAction:(NSDictionary *)actionInformation
160-
request:(NSURLRequest *)request
161-
newFrameName:(NSString *)frameName
162-
decisionListener:(id < WebPolicyDecisionListener >)listener
152+
- (void)webView:(WebView *)sender decidePolicyForNewWindowAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request newFrameName:(NSString *)frameName decisionListener:(id < WebPolicyDecisionListener >)listener
163153
{
164154
[[NSWorkspace sharedWorkspace] openURL:[request URL]];
165155
}
166156

167-
- getConfig:(NSString *)config
168-
{
157+
- (id)getConfig:(NSString *)config {
169158
return [historyController valueForKeyPath:[@"repository.config." stringByAppendingString:config]];
170159
}
171160

172-
173-
- (void) preferencesChanged
174-
{
161+
- (void)preferencesChanged {
175162
[[self script] callWebScriptMethod:@"enableFeatures" withArguments:nil];
176163
}
177164

0 commit comments

Comments
 (0)