diff --git a/kdecore/config/kconfigini.cpp b/kdecore/config/kconfigini.cpp index 5f7ba7c..718ad29 100644 --- a/kdecore/config/kconfigini.cpp +++ b/kdecore/config/kconfigini.cpp @@ -500,14 +500,18 @@ bool KConfigIniBackend::isWritable() const // 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(); + QFileInfo file(filePath()); + if (!file.exists()) { + QFileInfo dir(file.absolutePath()); while (!dir.exists()) { - if (!dir.cdUp()) { + QString parent = dir.absolutePath(); + if (parent == dir.filePath()) { + // no parent return false; } + dir.setFile(parent); } - return QFileInfo(dir.absolutePath()).isWritable(); + return dir.isDir() && dir.isWritable(); } }