summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2024-02-12 16:50:20 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2024-02-13 21:53:33 +0100
commit6657acf8f57529bfe601d18db5d594773f51fe91 (patch)
treed60b20e4cef02e50bf122c3a1c3b282cb93d086f
parenta3eba2378b4acfc46e5e6f8f511cdb0370c81d89 (diff)
Disable NSUserDefaults initialization workaround on iOS
Core Foundation would fail to pick up defaults from command line arguments, as the logic to read the command line arguments was in the Foundation class NSUserDefaults. As a workaround, we initialized NSUserDefaults as early as we could, so that we could use Core Foundation elsewhere in Qt. As NSUserDefaults is considered a potential privacy risk, and needs explicit declaration of use for iOS in the privacy manifest, we disable the workaround for iOS. This should be okey, as the original issue does not seem to manifest on iOS 17, and was only a problem in practice when using command line arguments to debug things. The issue is also seemingly gone from macOS 14.3, but we keep the workaround in for now, just in case. Task-number: QTBUG-114319 Pick-to: 6.7 Change-Id: I2c698353673f797756a877a49cfbd8a37367c31e Reviewed-by: Doris Verria <doris.verria@qt.io>
-rw-r--r--src/corelib/kernel/qcore_mac.mm2
-rw-r--r--src/corelib/text/qlocale_mac.mm2
2 files changed, 4 insertions, 0 deletions
diff --git a/src/corelib/kernel/qcore_mac.mm b/src/corelib/kernel/qcore_mac.mm
index 8844a173c7..8ec0464399 100644
--- a/src/corelib/kernel/qcore_mac.mm
+++ b/src/corelib/kernel/qcore_mac.mm
@@ -52,6 +52,7 @@ QT_BEGIN_NAMESPACE
// --------------------------------------------------------------------------
+#if defined(Q_OS_MACOS)
static void initializeStandardUserDefaults()
{
// The standard user defaults are initialized from an ordered list of domains,
@@ -64,6 +65,7 @@ static void initializeStandardUserDefaults()
Q_UNUSED(NSUserDefaults.standardUserDefaults);
}
Q_CONSTRUCTOR_FUNCTION(initializeStandardUserDefaults);
+#endif
// --------------------------------------------------------------------------
diff --git a/src/corelib/text/qlocale_mac.mm b/src/corelib/text/qlocale_mac.mm
index 1236cd9e18..65891d6a3b 100644
--- a/src/corelib/text/qlocale_mac.mm
+++ b/src/corelib/text/qlocale_mac.mm
@@ -32,9 +32,11 @@ static void printLocalizationInformation()
if (!lcLocale().isDebugEnabled())
return;
+#if defined(Q_OS_MACOS)
// Trigger initialization of standard user defaults, so that Foundation picks
// up -AppleLanguages and -AppleLocale passed on the command line.
Q_UNUSED(NSUserDefaults.standardUserDefaults);
+#endif
auto singleLineDescription = [](NSArray *array) {
NSString *str = [array description];