From 351d3e50f993014ca6b17817c87d12153ca2f617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 2 Jan 2023 13:58:36 +0100 Subject: [PATCH] macOS: Stop using the deprecated [NSWorkspace openFile:] API We can use openURL instead, which also opens local files in the associated application. Pick-to: 6.5 Change-Id: Ieddc6fb68d6b9e64195ed261953b9fffb6b0b73e Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoaservices.mm | 8 +------- src/printsupport/dialogs/qprintdialog_mac.mm | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoaservices.mm b/src/plugins/platforms/cocoa/qcocoaservices.mm index 29f8ed96e6..68daa660ef 100644 --- a/src/plugins/platforms/cocoa/qcocoaservices.mm +++ b/src/plugins/platforms/cocoa/qcocoaservices.mm @@ -12,18 +12,12 @@ QT_BEGIN_NAMESPACE bool QCocoaServices::openUrl(const QUrl &url) { - const QString scheme = url.scheme(); - if (scheme.isEmpty()) - return openDocument(url); return [[NSWorkspace sharedWorkspace] openURL:url.toNSURL()]; } bool QCocoaServices::openDocument(const QUrl &url) { - if (!url.isValid()) - return false; - - return [[NSWorkspace sharedWorkspace] openFile:url.toLocalFile().toNSString()]; + return openUrl(url); } QT_END_NAMESPACE diff --git a/src/printsupport/dialogs/qprintdialog_mac.mm b/src/printsupport/dialogs/qprintdialog_mac.mm index 6671afae52..b1b56dbf54 100644 --- a/src/printsupport/dialogs/qprintdialog_mac.mm +++ b/src/printsupport/dialogs/qprintdialog_mac.mm @@ -118,7 +118,7 @@ QT_USE_NAMESPACE // happen synchronously after the dialog is accepted, so we can defer // the opening of the file to the next runloop pass. dispatch_async(dispatch_get_main_queue(), ^{ - [NSWorkspace.sharedWorkspace openFile:fileName.toNSString()]; + [NSWorkspace.sharedWorkspace openURL:[NSURL fileURLWithPath:fileName.toNSString()]]; }); } else if (dest == kPMDestinationProcessPDF) { qWarning("Printing workflows are not supported");