Skip to content

Commit 52a3474

Browse files
author
Anthony Somerset
committed
Move to beginSheetModalForWindow:completionHandler: to close another deprecation issue
1 parent 400891d commit 52a3474

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

Diff for: MVPreferencesController.m

+15-22
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,21 @@ - (void)setShowDockIconValue:(BOOL)show
318318
[alert setMessageText:@"You must now restart"];
319319
[alert setInformativeText:@"This change requires to restart the application"];
320320
[alert setAlertStyle:NSWarningAlertStyle];
321-
[alert beginSheetModalForWindow:self.window
322-
modalDelegate:self
323-
didEndSelector:@selector(restartDialogDidEnd:returnCode:contextInfo:)
324-
contextInfo:nil];
325-
}
321+
322+
[alert beginSheetModalForWindow: self.window completionHandler: ^(NSInteger returnCode){
323+
if (returnCode==NSAlertFirstButtonReturn) {
324+
[NSTask launchedTaskWithLaunchPath:@"/bin/sh"
325+
arguments:[NSArray arrayWithObjects:@"-c",
326+
[NSString stringWithFormat:
327+
@"sleep 1 ; /usr/bin/open '%@'",
328+
[[NSBundle mainBundle] bundlePath]],
329+
nil]];
330+
[NSApp terminate:self];
331+
}
332+
}
333+
];
334+
335+
}
326336
}
327337
}
328338

@@ -360,23 +370,6 @@ - (void)layoutView:(BOOL)animated
360370
}
361371
}
362372

363-
///////////////////////////////////////////////////////////////////////////////////////////////////
364-
- (void)restartDialogDidEnd:(NSAlert *)alert
365-
returnCode:(NSInteger)returnCode
366-
contextInfo:(void *)contextInfo
367-
{
368-
// Not quite sure why we can't directly execute outselves, but
369-
// we seem to require the open command to make it work
370-
[NSTask launchedTaskWithLaunchPath:@"/bin/sh"
371-
arguments:[NSArray arrayWithObjects:@"-c",
372-
[NSString stringWithFormat:
373-
@"sleep 1 ; /usr/bin/open '%@'",
374-
[[NSBundle mainBundle] bundlePath]],
375-
nil]];
376-
[NSApp terminate:self];
377-
}
378-
379-
///////////////////////////////////////////////////////////////////////////////////////////////////
380373
///////////////////////////////////////////////////////////////////////////////////////////////////
381374
#pragma mark -
382375
#pragma mark Launch At Login helper Methods

0 commit comments

Comments
 (0)