diff options
author | culler <culler> | 2021-10-10 16:46:26 (GMT) |
---|---|---|
committer | culler <culler> | 2021-10-10 16:46:26 (GMT) |
commit | f37694250c1164741ebb0085811291ffb0f11e51 (patch) | |
tree | b93af675626ec2f550e362e029a4491931d02cff | |
parent | d797a66a7b5dc07d1b0f3a22f5e76dab13627a22 (diff) | |
download | tk-f37694250c1164741ebb0085811291ffb0f11e51.zip tk-f37694250c1164741ebb0085811291ffb0f11e51.tar.gz tk-f37694250c1164741ebb0085811291ffb0f11e51.tar.bz2 |
Fix error generated by the open file dialog on Monterey, caused by Apple reversing course and reverting to [NSApp runModalForWindow].
-rw-r--r-- | macosx/tkMacOSXDialog.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index 4bcaedf..05bdf7f 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -352,6 +352,7 @@ static NSInteger showOpenSavePanel( NSInteger modalReturnCode; if (parent && ![parent attachedSheet]) { + int osVersion = [NSApp macOSVersion]; [panel beginSheetModalForWindow:parent completionHandler:^(NSModalResponse returnCode) { [NSApp tkFilePanelDidEnd:panel @@ -364,10 +365,15 @@ static NSInteger showOpenSavePanel( * 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. + * 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. */ - if ([NSApp macOSVersion] > 101400) { + if ( osVersion >= 101400 && osVersion < 120000) { modalReturnCode = [panel runModal]; } else { modalReturnCode = [NSApp runModalForWindow:panel]; |