KConfigIniBackend::isWritable bug
Nicolas Alvarez
nicolas.alvarez at gmail.com
Wed Jun 8 02:39:15 BST 2011
Hi,
I'm trying to get kdelibs unit tests to run in a clean and headless
environment (for automated testing). I'm starting an X server, dbus, and
kdeinit by hand.
Currently kded (started by kdeinit) is failing to start up if I'm running it
for the first time and there is currently no ~/.kde directory.
Specifically, it's showing a kdialog popup with 'Configuration file
"/var/lib/buildbot/.kde/share/config/kdedrc" not writable.'. (I don't even
see the popup because it's on the invisible Xvfb server).
After some code-reading and debugging, I found the cause. kded checks if
~/.kde/share/config/kdedrc is writable via KConfigIniBackend::isWritable().
This function first checks if the file itself is writable using access()
(well, KStandardDirs::checkAccess). Then there is this code:
// 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();
}
This code will never succeed for more than one level of directories:
QDir::cdUp() requires an existing and readable parent directory! So it would
only work in this case if ~/.kde/share already exists.
What's the cleanest way to rewrite it? dir=dir.filePath("..")?
--
Nicolas
More information about the kde-core-devel
mailing list