summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qsettings.cpp
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@nokia.com>2011-05-04 10:41:39 (GMT)
committerJørgen Lind <jorgen.lind@nokia.com>2011-05-04 10:41:39 (GMT)
commit8a706b5133b1ba1d5eb5fdca97e002597d6ff829 (patch)
tree5cf57028938262d25ea1894784dd97289184241c /src/corelib/io/qsettings.cpp
parent9625c564877414695a9706acf34bc8719018ef06 (diff)
parent60e65cc23bf1df213320604062ef98e40c46d3df (diff)
downloadQt-8a706b5133b1ba1d5eb5fdca97e002597d6ff829.zip
Qt-8a706b5133b1ba1d5eb5fdca97e002597d6ff829.tar.gz
Qt-8a706b5133b1ba1d5eb5fdca97e002597d6ff829.tar.bz2
Merge remote-tracking branch 'origin/4.8' into lighthouse-master
Diffstat (limited to 'src/corelib/io/qsettings.cpp')
-rw-r--r--src/corelib/io/qsettings.cpp29
1 files changed, 5 insertions, 24 deletions
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index b084ca5..f43fb31 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -981,23 +981,6 @@ QStringList QSettingsPrivate::splitArgs(const QString &s, int idx)
// ************************************************************************
// QConfFileSettingsPrivate
-/*
- If we don't have the permission to read the file, returns false.
- If the file doesn't exist, returns true.
-*/
-static bool checkAccess(const QString &name)
-{
- QFileInfo fileInfo(name);
-
- if (fileInfo.exists()) {
- QFile file(name);
- // if the file exists but we can't open it, report an error
- return file.open(QFile::ReadOnly);
- } else {
- return true;
- }
-}
-
void QConfFileSettingsPrivate::initFormat()
{
extension = (format == QSettings::NativeFormat) ? QLatin1String(".conf") : QLatin1String(".ini");
@@ -1026,18 +1009,13 @@ void QConfFileSettingsPrivate::initFormat()
void QConfFileSettingsPrivate::initAccess()
{
- bool readAccess = false;
if (confFiles[spec]) {
- readAccess = checkAccess(confFiles[spec]->name);
if (format > QSettings::IniFormat) {
if (!readFunc)
- readAccess = false;
+ setStatus(QSettings::AccessError);
}
}
- if (!readAccess)
- setStatus(QSettings::AccessError);
-
sync(); // loads the files the first time
}
@@ -1432,7 +1410,7 @@ void QConfFileSettingsPrivate::syncConfFile(int confFileNo)
We can often optimize the read-only case, if the file on disk
hasn't changed.
*/
- if (readOnly) {
+ if (readOnly && confFile->size > 0) {
QFileInfo fileInfo(confFile->name);
if (confFile->size == fileInfo.size() && confFile->timeStamp == fileInfo.lastModified())
return;
@@ -1455,6 +1433,9 @@ void QConfFileSettingsPrivate::syncConfFile(int confFileNo)
if (!file.isOpen())
file.open(QFile::ReadOnly);
+ if (!createFile && !file.isOpen())
+ setStatus(QSettings::AccessError);
+
#ifdef Q_OS_WIN
HANDLE readSemaphore = 0;
HANDLE writeSemaphore = 0;