From e407bab246063a872a388f4b1ca86a186933d89b Mon Sep 17 00:00:00 2001 From: Peter Zhigalov Date: Tue, 27 Aug 2024 14:16:21 +0700 Subject: [PATCH] Revert "Apple: Fix a few deprecation warnings after bumping deployment targets" This reverts commit 2a2a30155719d9175f92467a42e0deac5aad3767. --- src/corelib/CMakeLists.txt | 6 ------ src/corelib/global/qsysinfo.cpp | 3 ++- src/corelib/io/qfilesystemengine_unix.cpp | 21 ++++++++++++------- src/corelib/kernel/qcore_mac.mm | 2 +- src/gui/platform/darwin/qutimimeconverter.mm | 3 +-- src/plugins/platforms/cocoa/qcocoadrag.mm | 4 ++-- .../platforms/cocoa/qcocoaintegration.mm | 5 ++--- src/plugins/platforms/cocoa/qcocoascreen.mm | 2 +- src/plugins/platforms/cocoa/qnsview.mm | 3 +-- .../platforms/cocoa/qnsview_dragging.mm | 4 ++-- src/tools/bootstrap/CMakeLists.txt | 6 ------ 11 files changed, 25 insertions(+), 34 deletions(-) diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index 076eabcbe78..49a6f30c8a6 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -694,12 +694,6 @@ qt_internal_extend_target(Core CONDITION UNIX kernel/qtimerinfo_unix.cpp kernel/qtimerinfo_unix_p.h thread/qthread_unix.cpp ) -if(APPLE) - set_source_files_properties(io/qfilesystemengine_unix.cpp PROPERTIES LANGUAGE OBJCXX) - qt_internal_extend_target(Core CONDITION - PUBLIC_LIBRARIES ${FWUniformTypeIdentifiers} - ) -endif() qt_internal_extend_target(Core CONDITION UNIX AND NOT WASM SOURCES diff --git a/src/corelib/global/qsysinfo.cpp b/src/corelib/global/qsysinfo.cpp index d4079e0d8df..e431d9d6c3b 100644 --- a/src/corelib/global/qsysinfo.cpp +++ b/src/corelib/global/qsysinfo.cpp @@ -1013,7 +1013,8 @@ QByteArray QSysInfo::machineUniqueId() { #if defined(Q_OS_DARWIN) && __has_include() char uuid[UuidStringLen + 1]; - io_service_t service = IOServiceGetMatchingService(kIOMainPortDefault, IOServiceMatching("IOPlatformExpertDevice")); + static const mach_port_t defaultPort = 0; // Effectively kIOMasterPortDefault/kIOMainPortDefault + io_service_t service = IOServiceGetMatchingService(defaultPort, IOServiceMatching("IOPlatformExpertDevice")); QCFString stringRef = (CFStringRef)IORegistryEntryCreateCFProperty(service, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0); CFStringGetCString(stringRef, uuid, sizeof(uuid), kCFStringEncodingMacRoman); return QByteArray(uuid); diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 14beb89b26a..5008420e0f2 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -39,11 +39,6 @@ #if defined(Q_OS_DARWIN) # include # include -# include -# include -# include -# include -# include #endif #ifdef Q_OS_MACOS @@ -54,6 +49,15 @@ #include #endif +#if defined(Q_OS_DARWIN) +# include +# include +// We cannot include (it's an Objective-C header), but +// we need these declarations: +Q_FORWARD_DECLARE_OBJC_CLASS(NSString); +extern "C" NSString *NSTemporaryDirectory(); +#endif + #if defined(Q_OS_LINUX) # include # include @@ -123,9 +127,10 @@ static bool isPackage(const QFileSystemMetaData &data, const QFileSystemEntry &e QString suffix = info.suffix(); if (suffix.length() > 0) { - // First step: is it a bundle? - const auto *utType = [UTType typeWithFilenameExtension:suffix.toNSString()]; - if ([utType conformsToType:UTTypeBundle]) + // First step: is the extension known ? + QCFType extensionRef = suffix.toCFString(); + QCFType uniformTypeIdentifier = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, extensionRef, NULL); + if (UTTypeConformsTo(uniformTypeIdentifier, kUTTypeBundle)) return true; // Second step: check if an application knows the package type diff --git a/src/corelib/kernel/qcore_mac.mm b/src/corelib/kernel/qcore_mac.mm index 00b0d078d7d..dea46efdf5b 100644 --- a/src/corelib/kernel/qcore_mac.mm +++ b/src/corelib/kernel/qcore_mac.mm @@ -346,7 +346,7 @@ bool qt_mac_runningUnderRosetta() return config; #endif - QIOType nvram = IORegistryEntryFromPath(kIOMainPortDefault, "IODeviceTree:/options"); + QIOType nvram = IORegistryEntryFromPath(kIOMasterPortDefault, "IODeviceTree:/options"); if (!nvram) { qWarning("Failed to locate NVRAM entry in IO registry"); return {}; diff --git a/src/gui/platform/darwin/qutimimeconverter.mm b/src/gui/platform/darwin/qutimimeconverter.mm index 294a617f3b0..b01a4c26cb0 100644 --- a/src/gui/platform/darwin/qutimimeconverter.mm +++ b/src/gui/platform/darwin/qutimimeconverter.mm @@ -3,7 +3,6 @@ #include #include -#include #include #include @@ -785,7 +784,7 @@ QVariant convertToMime(const QString &mime, const QList &data, QCFType data = CFDataCreateMutable(0, 0); QCFType imageDestination = CGImageDestinationCreateWithData(data, - (CFStringRef)UTTypeTIFF.identifier, 1, 0); + kUTTypeTIFF, 1, 0); if (!imageDestination) return QList(); diff --git a/src/plugins/platforms/cocoa/qcocoadrag.mm b/src/plugins/platforms/cocoa/qcocoadrag.mm index 3a9f5a87941..2a89b8eec3f 100644 --- a/src/plugins/platforms/cocoa/qcocoadrag.mm +++ b/src/plugins/platforms/cocoa/qcocoadrag.mm @@ -2,7 +2,6 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include -#include #include "qcocoadrag.h" #include "qmacclipboard.h" @@ -156,7 +155,8 @@ for (NSPasteboardItem *item in dragBoard.pasteboardItems) { bool isUrl = false; for (NSPasteboardType type in item.types) { - if ([type isEqualToString:UTTypeFileURL.identifier]) { + using NSStringRef = NSString *; + if ([type isEqualToString:NSStringRef(kUTTypeFileURL)]) { isUrl = true; break; } diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index ad767a0694a..c576e581ece 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -40,7 +40,6 @@ #include #include -#include #include @@ -447,8 +446,8 @@ QSurfaceFormat format() const override return; static bool hasDefaultApplicationIcon = [](){ - NSImage *genericApplicationIcon = [NSWorkspace.sharedWorkspace - iconForContentType:UTTypeApplicationBundle]; + NSImage *genericApplicationIcon = [[NSWorkspace sharedWorkspace] + iconForFileType:NSFileTypeForHFSTypeCode(kGenericApplicationIcon)]; NSImage *applicationIcon = [NSImage imageNamed:NSImageNameApplicationIcon]; NSRect rect = NSMakeRect(0, 0, 32, 32); diff --git a/src/plugins/platforms/cocoa/qcocoascreen.mm b/src/plugins/platforms/cocoa/qcocoascreen.mm index 17af0efaea1..94daadb8570 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.mm +++ b/src/plugins/platforms/cocoa/qcocoascreen.mm @@ -200,7 +200,7 @@ static QString displayName(CGDirectDisplayID displayID) { QIOType iterator; - if (IOServiceGetMatchingServices(kIOMainPortDefault, + if (IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceMatching("IODisplayConnect"), &iterator)) return QString(); diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 7289c66ea65..ed9bd21b749 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -5,7 +5,6 @@ #include #include -#include #include "qnsview.h" #include "qcocoawindow.h" @@ -417,7 +416,7 @@ @implementation QNSView (QtExtras) - (QCocoaWindow*)platformWindow { - return m_platformWindow.data();; + return m_platformWindow.data(); } @end diff --git a/src/plugins/platforms/cocoa/qnsview_dragging.mm b/src/plugins/platforms/cocoa/qnsview_dragging.mm index 4f7d35a0d64..f5bb25c300c 100644 --- a/src/plugins/platforms/cocoa/qnsview_dragging.mm +++ b/src/plugins/platforms/cocoa/qnsview_dragging.mm @@ -16,8 +16,8 @@ -(void)registerDragTypes NSPasteboardTypeRTF, NSPasteboardTypeTabularText, NSPasteboardTypeFont, NSPasteboardTypeRuler, NSFileContentsPboardType, NSPasteboardTypeRTFD , NSPasteboardTypeHTML, - NSPasteboardTypeURL, NSPasteboardTypePDF, UTTypeVCard.identifier, - (NSString *)kPasteboardTypeFileURLPromise, + NSPasteboardTypeURL, NSPasteboardTypePDF, (NSString *)kUTTypeVCard, + (NSString *)kPasteboardTypeFileURLPromise, (NSString *)kUTTypeInkText, NSPasteboardTypeMultipleTextSelection, mimeTypeGeneric]]; // Add custom types supported by the application diff --git a/src/tools/bootstrap/CMakeLists.txt b/src/tools/bootstrap/CMakeLists.txt index a1f8480a1d8..f10bad5a6a3 100644 --- a/src/tools/bootstrap/CMakeLists.txt +++ b/src/tools/bootstrap/CMakeLists.txt @@ -107,12 +107,6 @@ qt_internal_extend_target(Bootstrap CONDITION UNIX ../../corelib/io/qfsfileengine_unix.cpp ../../corelib/kernel/qcore_unix.cpp ) -if(APPLE) - set_source_files_properties(../../corelib/io/qfilesystemengine_unix.cpp PROPERTIES LANGUAGE OBJCXX) - qt_internal_extend_target(Bootstrap CONDITION - PUBLIC_LIBRARIES ${FWUniformTypeIdentifiers} - ) -endif() qt_internal_extend_target(Bootstrap CONDITION WIN32 SOURCES