Index: kdecore/config/kconfig.cpp =================================================================== --- kdecore/config/kconfig.cpp (revision 866718) +++ kdecore/config/kconfig.cpp (revision 866909) @@ -296,11 +296,8 @@ if (d->bDirty && d->mBackend) { const QByteArray utf8Locale(locale().toUtf8()); - // Check if we can write to the local file. - if (!d->mBackend->isWritable()) { - // Create the containing dir, maybe it wasn't there - d->mBackend->createEnclosing(); - } + // Create the containing dir, maybe it wasn't there + d->mBackend->createEnclosing(); // lock the local file if (d->configState == ReadWrite && !d->lockLocal()) { @@ -409,7 +406,7 @@ fileName = appName + QLatin1String("rc"); if (type && *type) resourceType = type; // only change it if it's not empty - file = KStandardDirs::locateLocal(resourceType, fileName, componentData); + file = KStandardDirs::locateLocal(resourceType, fileName, false, componentData); } } else if (wantGlobals()) { // accessing "kdeglobals" resourceType = "config"; @@ -421,7 +418,7 @@ else { if (type && *type) resourceType = type; // only change it if it's not empty - file = KStandardDirs::locateLocal(resourceType, fileName, componentData); + file = KStandardDirs::locateLocal(resourceType, fileName, false, componentData); if (fileName == QLatin1String("kdeglobals")) openFlags |= KConfig::IncludeGlobals; Index: kdecore/config/kconfigini.cpp =================================================================== --- kdecore/config/kconfigini.cpp (revision 866718) +++ kdecore/config/kconfigini.cpp (revision 866909) @@ -485,8 +485,24 @@ bool KConfigIniBackend::isWritable() const { - if (!filePath().isEmpty()) - return KStandardDirs::checkAccess(filePath(), W_OK); + if (!filePath().isEmpty()) { + if (KStandardDirs::checkAccess(filePath(), W_OK)) { + return true; + } + // The check might have failed because any of the containing dirs + // did not exist. If the file does not exist, check if the deepest + // existing dir is writable. + if (!QFileInfo(filePath()).exists()) { + QDir dir = QFileInfo(filePath()).absolutePath(); + while (!dir.exists()) { + if (!dir.cdUp()) { + return false; + } + } + return QFileInfo(dir.absolutePath()).isWritable(); + } + } + return false; } @@ -532,7 +548,7 @@ if (filePath().isEmpty()) return KConfigBase::NoAccess; - if (KStandardDirs::checkAccess(filePath(), W_OK)) + if (isWritable()) return KConfigBase::ReadWrite; return KConfigBase::ReadOnly;