@@ -318,11 +318,21 @@ - (void)setShowDockIconValue:(BOOL)show
318
318
[alert setMessageText: @" You must now restart" ];
319
319
[alert setInformativeText: @" This change requires to restart the application" ];
320
320
[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
+ }
326
336
}
327
337
}
328
338
@@ -360,23 +370,6 @@ - (void)layoutView:(BOOL)animated
360
370
}
361
371
}
362
372
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
- // /////////////////////////////////////////////////////////////////////////////////////////////////
380
373
// /////////////////////////////////////////////////////////////////////////////////////////////////
381
374
#pragma mark -
382
375
#pragma mark Launch At Login helper Methods
0 commit comments