summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorculler <culler>2021-10-28 17:32:24 (GMT)
committerculler <culler>2021-10-28 17:32:24 (GMT)
commit427326e6504bbc34f653977e2dd4d9fc22e3c73c (patch)
tree6b122dddc44a481b46e366b01ef0e2fb574d2deb /macosx
parent4a74d1fb30690f343de79c46077a071401b1d611 (diff)
parent1b792f679cd4121f0ba1d7b919dc2b0d9b54b821 (diff)
downloadtk-427326e6504bbc34f653977e2dd4d9fc22e3c73c.zip
tk-427326e6504bbc34f653977e2dd4d9fc22e3c73c.tar.gz
tk-427326e6504bbc34f653977e2dd4d9fc22e3c73c.tar.bz2
Merge 8.6
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXDialog.c66
1 files changed, 26 insertions, 40 deletions
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c
index 08998bc..b6f4503 100644
--- a/macosx/tkMacOSXDialog.c
+++ b/macosx/tkMacOSXDialog.c
@@ -350,55 +350,41 @@ static NSInteger showOpenSavePanel(
FilePanelCallbackInfo *callbackInfo)
{
NSInteger modalReturnCode;
+ int OSVersion = [NSApp macOSVersion];
- if (parent && ![parent attachedSheet]) {
- int osVersion = [NSApp macOSVersion];
- [panel beginSheetModalForWindow:parent
- completionHandler:^(NSModalResponse returnCode) {
- [NSApp tkFilePanelDidEnd:panel
- returnCode:returnCode
- contextInfo:callbackInfo ];
- }];
-
- /*
- * The sheet has been prepared, so now we have to run it as a modal
- * window. Using [NSApp runModalForWindow:] on macOS 10.15 or later
- * generates warnings on stderr. But using [NSOpenPanel runModal] or
- * [NSSavePanel runModal] on 10.14 or earler does not cause the
- * completion handler to run when the panel is closed. Apple apparently
- * decided to go back to using runModalForWindow with the release of
- * macOS 12.0. The warnings do not appear in that OS, and using
- * runModal produces an error dialog that says "The open file operation
- * failed to connect to the open and save panel service." along with an
- * assertion error.
- */
+ /*
+ * Use a sheet if -parent is specified (unless there is already a sheet).
+ */
- if ( osVersion > 101400 && osVersion < 120000) {
- modalReturnCode = [panel runModal];
- } else {
+ if (parent && ![parent attachedSheet]) {
+ if (OSVersion < 101500) {
+ [panel beginSheetModalForWindow:parent
+ completionHandler:^(NSModalResponse returnCode) {
+ [NSApp tkFilePanelDidEnd:panel
+ returnCode:returnCode
+ contextInfo:callbackInfo ];
+ }];
modalReturnCode = [NSApp runModalForWindow:panel];
- }
- } else {
-
- /*
- * For the standalone file dialog, completion handlers do not work
- * at all on macOS 10.14 and earlier.
- */
-
- if ([NSApp macOSVersion] > 101400) {
- [panel beginWithCompletionHandler:^(NSModalResponse returnCode) {
+ } else if (OSVersion < 110000) {
+ [panel beginSheetModalForWindow:parent
+ completionHandler:^(NSModalResponse returnCode) {
[NSApp tkFilePanelDidEnd:panel
- returnCode:returnCode
- contextInfo:callbackInfo ];
- }];
+ returnCode:returnCode
+ contextInfo:callbackInfo ];
+ }];
modalReturnCode = [panel runModal];
} else {
+ [parent beginSheet: panel completionHandler:nil];
modalReturnCode = [panel runModal];
[NSApp tkFilePanelDidEnd:panel
- returnCode:modalReturnCode
- contextInfo:callbackInfo ];
- [panel close];
+ returnCode:modalReturnCode
+ contextInfo:callbackInfo ];
}
+ } else {
+ modalReturnCode = [panel runModal];
+ [NSApp tkFilePanelDidEnd:panel
+ returnCode:modalReturnCode
+ contextInfo:callbackInfo ];
}
return callbackInfo->cmdObj ? modalOther : modalReturnCode;
}