From 18afbbbbcf8d27f35d4530e00cd798c4fc7daf92 Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <barracuda@macos-powerpc.org>
Date: Wed, 11 Jun 2025 00:32:10 +0800
Subject: [PATCH 1/2] Fix broken code

---
 src/app/config-ui/config-ui.pro              |  3 ++-
 src/lib/corelib/api/project.cpp              | 15 +++++++++++++--
 src/lib/corelib/jsextensions/propertylist.mm |  4 ++--
 tests/auto/blackbox/tst_blackbox.cpp         |  7 -------
 4 files changed, 17 insertions(+), 12 deletions(-)

diff --git src/app/config-ui/config-ui.pro src/app/config-ui/config-ui.pro
index 0c406694d..aba823500 100644
--- src/app/config-ui/config-ui.pro
+++ src/app/config-ui/config-ui.pro
@@ -22,6 +22,7 @@ SOURCES += \
 OTHER_FILES += \
     Info.plist
 
-mac: QMAKE_LFLAGS += -sectcreate __TEXT __info_plist $$shell_quote($$PWD/Info.plist)
+# This does not seem to be needed, but it breaks the build.
+# mac: QMAKE_LFLAGS += -sectcreate __TEXT __info_plist $$shell_quote($$PWD/Info.plist)
 
 FORMS += mainwindow.ui
diff --git src/lib/corelib/api/project.cpp src/lib/corelib/api/project.cpp
index 040bc1b05..f6211dc10 100644
--- src/lib/corelib/api/project.cpp
+++ src/lib/corelib/api/project.cpp
@@ -826,7 +826,10 @@ QString bundleExecutablePath(const QString &qbundlePath, const QString &defaultV
 {
 #ifdef Q_OS_MAC
     QString qexecutablePath = defaultValue;
-    CFStringRef bundlePath = qbundlePath.toCFString();
+    CFStringRef bundlePath = CFStringCreateWithCharacters(
+        kCFAllocatorDefault,
+        reinterpret_cast<const UniChar *>(qbundlePath.unicode()),
+        qbundlePath.length());
     CFURLRef bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, bundlePath,
                                                        kCFURLPOSIXPathStyle, true);
     CFRelease(bundlePath);
@@ -839,7 +842,15 @@ QString bundleExecutablePath(const QString &qbundlePath, const QString &defaultV
                 CFStringRef executablePath = CFURLCopyFileSystemPath(absoluteExecutableURL,
                                                                      kCFURLPOSIXPathStyle);
                 if (executablePath) {
-                    qexecutablePath = QString::fromCFString(executablePath);
+                    const UniChar *chars = CFStringGetCharactersPtr(executablePath);
+                    if (chars) {
+                        qexecutablePath = QString::fromUtf16(reinterpret_cast<const ushort *>(chars), CFStringGetLength(executablePath));
+                    } else {
+                        CFIndex length = CFStringGetLength(executablePath);
+                        QVector<UniChar> buffer(length);
+                        CFStringGetCharacters(executablePath, CFRangeMake(0, length), buffer.data());
+                        qexecutablePath = QString::fromUtf16(reinterpret_cast<const ushort *>(buffer.constData()), length);
+                    }
                     CFRelease(executablePath);
                 }
                 CFRelease(absoluteExecutableURL);
diff --git src/lib/corelib/jsextensions/propertylist.mm src/lib/corelib/jsextensions/propertylist.mm
index 6dd7acabb..b99fd8ade 100644
--- src/lib/corelib/jsextensions/propertylist.mm
+++ src/lib/corelib/jsextensions/propertylist.mm
@@ -174,9 +174,9 @@ NSData *PropertyListPrivate::writeToData(QScriptContext *context, const QString
             } else {
                 errorString = @"Property list object cannot be converted to JSON data";
             }
-        }
+        } else
 #endif
-        else {
+        {
             errorString = @"JSON serialization of property lists is not "
                           @"supported on this version of OS X";
         }
diff --git tests/auto/blackbox/tst_blackbox.cpp tests/auto/blackbox/tst_blackbox.cpp
index 19f52cb8d..576ac9cca 100644
--- tests/auto/blackbox/tst_blackbox.cpp
+++ tests/auto/blackbox/tst_blackbox.cpp
@@ -2443,10 +2443,6 @@ void TestBlackbox::testAssetCatalog()
 {
     if (!HostOsInfo::isOsxHost())
         SKIP_TEST("only applies on OS X");
-#ifdef Q_OS_MAC
-    if (QSysInfo::macVersion() < Q_MV_OSX(10, 9))
-        SKIP_TEST("This test needs at least OS X 10.9.");
-#endif
 
     QDir::setCurrent(testDataDir + QLatin1String("/ib/assetcatalog"));
 
@@ -2481,9 +2477,6 @@ void TestBlackbox::testAssetCatalog()
 
     // make sure the nibs/storyboards are in there
     QVERIFY(regularFileExists(productBuildDir("assetcatalogempty") + "/assetcatalogempty.app/Contents/Resources/MainMenu.nib"));
-#ifdef Q_OS_MAC
-    if (QSysInfo::macVersion() >= Q_MV_OSX(10, 10))
-#endif
         QVERIFY(directoryExists(productBuildDir("assetcatalogempty") + "/assetcatalogempty.app/Contents/Resources/Storyboard.storyboardc"));
 }
 
-- 
2.48.0

