diff -aur kdelibs-3.5.8/kdecore/kconfigbackend.cpp kdelibs-3.5.8.patched/kdecore/kconfigbackend.cpp --- kdelibs-3.5.8/kdecore/kconfigbackend.cpp 2007-10-08 16:01:10.000000000 +0200 +++ kdelibs-3.5.8.patched/kdecore/kconfigbackend.cpp 2007-10-18 01:52:33.000000000 +0200 @@ -980,6 +980,18 @@ bool KConfigINIBackEnd::writeConfigFile(QString filename, bool bGlobal, bool bMerge) { + return writeConfigFileInternal(filename, bGlobal, bMerge, true); +} + +bool KConfigINIBackEnd::writeConfigFileAsync(QString filename, bool bGlobal, + bool bMerge) +{ + return writeConfigFileInternal(filename, bGlobal, bMerge, false); +} + +bool KConfigINIBackEnd::writeConfigFileInternal(QString filename, bool bGlobal, + bool bMerge, bool bSync) +{ // is the config object read-only? if (pConfig->isReadOnly()) return true; // pretend we wrote it @@ -1021,6 +1033,9 @@ { pConfigFile = new KSaveFile( filename, 0600 ); + if (!bSync) + pConfigFile->setAsync(true); + if (pConfigFile->status() != 0) { delete pConfigFile; diff -aur kdelibs-3.5.8/kdecore/kconfigbackend.h kdelibs-3.5.8.patched/kdecore/kconfigbackend.h --- kdelibs-3.5.8/kdecore/kconfigbackend.h 2007-10-08 16:01:10.000000000 +0200 +++ kdelibs-3.5.8.patched/kdecore/kconfigbackend.h 2007-10-18 01:42:42.000000000 +0200 @@ -266,6 +266,22 @@ */ bool writeConfigFile(QString filename, bool bGlobal = false, bool bMerge = true); + /** + * Writes configuration file back but doesn't sync it to disk. + * + * @param filename The name of the file to write. + * @param bGlobal Specifies whether to write only entries which + * are marked as belonging to the global KDE config file. + * If this is false, it skips those entries. + * @param bMerge Specifies whether the old config file already + * on disk should be merged in with the data in memory. If true, + * data is read off the disk and merged. If false, the on-disk + * file is removed and only in-memory data is written out. + * @return Whether some entries are left to be written to other + * files. + */ + bool writeConfigFileAsync(QString filename, bool bGlobal = false, bool bMerge = true); + /** Get the entry map. * * @param map the entries will be stored in this object. @@ -286,6 +302,9 @@ protected: virtual void virtual_hook( int id, void* data ); private: + /* This does the real work */ + bool writeConfigFileInternal(QString filename, bool bGlobal, bool bMerge, bool bSync); + /* other privates */ class KConfigINIBackEndPrivate; KConfigINIBackEndPrivate *not_d; }; diff -aur kdelibs-3.5.8/kdecore/ksavefile.cpp kdelibs-3.5.8.patched/kdecore/ksavefile.cpp --- kdelibs-3.5.8/kdecore/ksavefile.cpp 2007-10-08 16:01:09.000000000 +0200 +++ kdelibs-3.5.8.patched/kdecore/ksavefile.cpp 2007-10-18 01:49:11.000000000 +0200 @@ -82,6 +82,9 @@ } } } + + // default is synchronous operation + mAsync = false; } KSaveFile::~KSaveFile() @@ -108,11 +111,17 @@ { if (mTempFile.name().isEmpty() || mTempFile.handle()==-1) return false; // Save was aborted already - if (!mTempFile.sync()) + + // only call sync if there was no async mode requested + if (!mAsync) { - abort(); - return false; + if (!mTempFile.sync()) + { + abort(); + return false; + } } + if (mTempFile.close()) { if (0==KDE_rename(QFile::encodeName(mTempFile.name()), QFile::encodeName(mFileName))) diff -aur kdelibs-3.5.8/kdecore/ksavefile.h kdelibs-3.5.8.patched/kdecore/ksavefile.h --- kdelibs-3.5.8/kdecore/ksavefile.h 2007-10-08 16:01:10.000000000 +0200 +++ kdelibs-3.5.8.patched/kdecore/ksavefile.h 2007-10-18 01:47:06.000000000 +0200 @@ -69,6 +69,15 @@ { return mTempFile.status(); } /** + * This sets all file operations to async mode, beware nothing is explicitly + * flushed to disk like normal! + * + * @param async set this to true to make file operations asynchronous + **/ + void setAsync(bool async) + { mAsync = async; } + + /** * The name of the file as passed to the constructor. * @return The name of the file, or QString::null if opening the * file has failed @@ -145,6 +154,7 @@ private: QString mFileName; KTempFile mTempFile; + bool mAsync; KSaveFilePrivate *d; };