diff options
Diffstat (limited to 'src/corelib/io/qsettings_mac.cpp')
-rw-r--r-- | src/corelib/io/qsettings_mac.cpp | 55 |
1 files changed, 8 insertions, 47 deletions
diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp index d73cc4d298..bc397055ff 100644 --- a/src/corelib/io/qsettings_mac.cpp +++ b/src/corelib/io/qsettings_mac.cpp @@ -181,7 +181,7 @@ static QCFType<CFPropertyListRef> macValue(const QVariant &value) QDateTime dt = value.toDateTime(); if (dt.timeSpec() == Qt::LocalTime) { QDateTime reference; - reference.setTime_t((uint)kCFAbsoluteTimeIntervalSince1970); + reference.setSecsSinceEpoch(qint64(kCFAbsoluteTimeIntervalSince1970)); result = CFDateCreate(kCFAllocatorDefault, CFAbsoluteTime(reference.secsTo(dt))); } else { goto string_case; @@ -293,7 +293,7 @@ static QVariant qtValue(CFPropertyListRef cfvalue) return map; } else if (typeId == CFDateGetTypeID()) { QDateTime dt; - dt.setTime_t((uint)kCFAbsoluteTimeIntervalSince1970); + dt.setSecsSinceEpoch(qint64(kCFAbsoluteTimeIntervalSince1970)); return dt.addSecs((int)CFDateGetAbsoluteTime(static_cast<CFDateRef>(cfvalue))); } return QVariant(); @@ -541,31 +541,7 @@ void QMacSettingsPrivate::sync() domains[i].userName, hostNames[j]); // only report failures for the primary file (the one we write to) if (!ok && i == 0 && hostNames[j] == hostName && status == QSettings::NoError) { -#if 1 - if (QSysInfo::macVersion() < QSysInfo::MV_10_7) { - // work around what seems to be a bug in CFPreferences: - // don't report an error if there are no preferences for the application - QCFType<CFArrayRef> appIds = CFPreferencesCopyApplicationList(domains[i].userName, - hostNames[j]); - - // iterate through all the applications and see if we're there - CFIndex size = CFArrayGetCount(appIds); - for (CFIndex k = 0; k < size; ++k) { - const void *cfvalue = CFArrayGetValueAtIndex(appIds, k); - if (CFGetTypeID(cfvalue) == CFStringGetTypeID()) { - if (CFStringCompare(static_cast<CFStringRef>(cfvalue), - domains[i].applicationOrSuiteId, - kCFCompareCaseInsensitive) == kCFCompareEqualTo) { - setStatus(QSettings::AccessError); - break; - } - } - } - } else -#endif - { - setStatus(QSettings::AccessError); - } + setStatus(QSettings::AccessError); } } } @@ -637,24 +613,11 @@ QSettingsPrivate *QSettingsPrivate::create(QSettings::Format format, } } -static QCFType<CFURLRef> urlFromFileName(const QString &fileName) -{ - return CFURLCreateWithFileSystemPath(kCFAllocatorDefault, QCFString(fileName), - kCFURLPOSIXPathStyle, false); -} - -bool QConfFileSettingsPrivate::readPlistFile(const QString &fileName, ParsedSettingsMap *map) const +bool QConfFileSettingsPrivate::readPlistFile(const QByteArray &data, 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; @@ -675,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()); @@ -699,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 |