summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qsettings_mac.cpp
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@qt.io>2016-06-29 16:20:31 -0700
committerJake Petroules <jake.petroules@qt.io>2016-08-30 01:52:53 +0000
commitbc1b45ff9f952edd0676e5d9509f9adef746c977 (patch)
tree4d263b4590c3008a66efdc6f6d349488519544cc /src/corelib/io/qsettings_mac.cpp
parent4c1c68b2ba2f01639fc03ca947fdd37479537ad2 (diff)
QSettings: Remove calls to deprecated API on macOS
CFURLCreateDataAndPropertiesFromResource and CFURLWriteDataAndPropertiestoResource have been deprecated since 10.9. We replace them with simple QFile access. Code cleaning and included. Change-Id: I19c7ceac41c8c511962f1128bd8e210e3adb434c Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com> Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Diffstat (limited to 'src/corelib/io/qsettings_mac.cpp')
-rw-r--r--src/corelib/io/qsettings_mac.cpp25
1 files changed, 5 insertions, 20 deletions
diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp
index 7f857a77a4..bc397055ff 100644
--- a/src/corelib/io/qsettings_mac.cpp
+++ b/src/corelib/io/qsettings_mac.cpp
@@ -613,24 +613,11 @@ QSettingsPrivate *QSettingsPrivate::create(QSettings::Format format,
}
}
-static QCFType<CFURLRef> urlFromFileName(const QString &fileName)
+bool QConfFileSettingsPrivate::readPlistFile(const QByteArray &data, ParsedSettingsMap *map) const
{
- return CFURLCreateWithFileSystemPath(kCFAllocatorDefault, QCFString(fileName),
- kCFURLPOSIXPathStyle, false);
-}
-
-bool QConfFileSettingsPrivate::readPlistFile(const QString &fileName, ParsedSettingsMap *map) const
-{
- QCFType<CFDataRef> resource;
- SInt32 code;
- if (!CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, urlFromFileName(fileName),
- &resource, 0, 0, &code))
- return false;
-
- QCFString errorStr;
+ QCFType<CFDataRef> cfData = data.toRawCFData();
QCFType<CFPropertyListRef> propertyList =
- CFPropertyListCreateFromXMLData(kCFAllocatorDefault, resource, kCFPropertyListImmutable,
- &errorStr);
+ CFPropertyListCreateWithData(kCFAllocatorDefault, cfData, kCFPropertyListImmutable, Q_NULLPTR, Q_NULLPTR);
if (!propertyList)
return true;
@@ -651,8 +638,7 @@ bool QConfFileSettingsPrivate::readPlistFile(const QString &fileName, ParsedSett
return true;
}
-bool QConfFileSettingsPrivate::writePlistFile(const QString &fileName,
- const ParsedSettingsMap &map) const
+bool QConfFileSettingsPrivate::writePlistFile(QIODevice &file, const ParsedSettingsMap &map) const
{
QVarLengthArray<QCFType<CFStringRef> > cfkeys(map.size());
QVarLengthArray<QCFType<CFPropertyListRef> > cfvalues(map.size());
@@ -675,8 +661,7 @@ bool QConfFileSettingsPrivate::writePlistFile(const QString &fileName,
QCFType<CFDataRef> xmlData = CFPropertyListCreateData(
kCFAllocatorDefault, propertyList, kCFPropertyListXMLFormat_v1_0, 0, 0);
- SInt32 code;
- return CFURLWriteDataAndPropertiesToResource(urlFromFileName(fileName), xmlData, 0, &code);
+ return file.write(QByteArray::fromRawCFData(xmlData)) == CFDataGetLength(xmlData);
}
QT_END_NAMESPACE