Let OakHTMLOutputView handle the “Stop Task?” warning sheet

This also allows for the sheet to automatically close, should the command exit before the user selects an action.
This commit is contained in:
Allan Odgaard
2016-08-25 14:05:16 +02:00
parent 2c41cf8fa0
commit c99e65b17c
6 changed files with 36 additions and 30 deletions

View File

@@ -101,16 +101,13 @@ OAK_DEBUG_VAR(HTMLOutputWindow);
if(!self.running)
return YES;
NSAlert* alert = [NSAlert alertWithMessageText:@"Stop task before closing?" defaultButton:@"Stop Task" alternateButton:@"Cancel" otherButton:nil informativeTextWithFormat:@"The job that the task is performing will not be completed."];
OakShowAlertForWindow(alert, self.window, ^(NSInteger returnCode){
D(DBF_HTMLOutputWindow, bug("close %s\n", BSTR(returnCode == NSAlertDefaultReturn)););
if(returnCode == NSAlertDefaultReturn) /* "Stop" */
[_htmlOutputView stopLoadingWithUserInteraction:YES completionHandler:^(BOOL didStop){
if(didStop)
{
[self.window orderOut:self];
[self.htmlOutputView stopLoading];
[self.window close];
}
});
}];
return NO;
}