Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 239269
Collapse All | Expand All

(-)kdecore/config/kconfig.cpp (-7 / +4 lines)
Lines 296-306 Link Here
296
    if (d->bDirty && d->mBackend) {
296
    if (d->bDirty && d->mBackend) {
297
        const QByteArray utf8Locale(locale().toUtf8());
297
        const QByteArray utf8Locale(locale().toUtf8());
298
298
299
        // Check if we can write to the local file.
299
        // Create the containing dir, maybe it wasn't there
300
        if (!d->mBackend->isWritable()) {
300
        d->mBackend->createEnclosing();
301
            // Create the containing dir, maybe it wasn't there
302
            d->mBackend->createEnclosing();
303
        }
304
301
305
        // lock the local file
302
        // lock the local file
306
        if (d->configState == ReadWrite && !d->lockLocal()) {
303
        if (d->configState == ReadWrite && !d->lockLocal()) {
Lines 409-415 Link Here
409
                fileName = appName + QLatin1String("rc");
406
                fileName = appName + QLatin1String("rc");
410
                if (type && *type)
407
                if (type && *type)
411
                    resourceType = type; // only change it if it's not empty
408
                    resourceType = type; // only change it if it's not empty
412
                file = KStandardDirs::locateLocal(resourceType, fileName, componentData);
409
                file = KStandardDirs::locateLocal(resourceType, fileName, false, componentData);
413
            }
410
            }
414
        } else if (wantGlobals()) { // accessing "kdeglobals"
411
        } else if (wantGlobals()) { // accessing "kdeglobals"
415
            resourceType = "config";
412
            resourceType = "config";
Lines 421-427 Link Here
421
    else {
418
    else {
422
        if (type && *type)
419
        if (type && *type)
423
            resourceType = type; // only change it if it's not empty
420
            resourceType = type; // only change it if it's not empty
424
        file = KStandardDirs::locateLocal(resourceType, fileName, componentData);
421
        file = KStandardDirs::locateLocal(resourceType, fileName, false, componentData);
425
422
426
        if (fileName == QLatin1String("kdeglobals"))
423
        if (fileName == QLatin1String("kdeglobals"))
427
            openFlags |= KConfig::IncludeGlobals;
424
            openFlags |= KConfig::IncludeGlobals;
(-)kdecore/config/kconfigini.cpp (-3 / +19 lines)
Lines 485-492 Link Here
485
485
486
bool KConfigIniBackend::isWritable() const
486
bool KConfigIniBackend::isWritable() const
487
{
487
{
488
    if (!filePath().isEmpty())
488
    if (!filePath().isEmpty()) {
489
        return KStandardDirs::checkAccess(filePath(), W_OK);
489
        if (KStandardDirs::checkAccess(filePath(), W_OK)) {
490
            return true;
491
        }
492
        // The check might have failed because any of the containing dirs
493
        // did not exist. If the file does not exist, check if the deepest
494
        // existing dir is writable.
495
        if (!QFileInfo(filePath()).exists()) {
496
            QDir dir = QFileInfo(filePath()).absolutePath();
497
            while (!dir.exists()) {
498
                if (!dir.cdUp()) {
499
                    return false;
500
                }
501
            }
502
            return QFileInfo(dir.absolutePath()).isWritable();
503
        }
504
    }
505
490
    return false;
506
    return false;
491
}
507
}
492
508
Lines 532-538 Link Here
532
    if (filePath().isEmpty())
548
    if (filePath().isEmpty())
533
        return KConfigBase::NoAccess;
549
        return KConfigBase::NoAccess;
534
550
535
    if (KStandardDirs::checkAccess(filePath(), W_OK))
551
    if (isWritable())
536
        return KConfigBase::ReadWrite;
552
        return KConfigBase::ReadWrite;
537
553
538
    return KConfigBase::ReadOnly;
554
    return KConfigBase::ReadOnly;

Return to bug 239269