[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kdeui/icons
From: Rivo Laks <rivolaks () hot ! ee>
Date: 2007-07-20 10:48:13
Message-ID: 1184928493.135971.16545.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 690208 by rivol:
Use KLockFile on Windows (it doesn't have flock())
M +21 -0 kpixmapcache.cpp
--- trunk/KDE/kdelibs/kdeui/icons/kpixmapcache.cpp #690207:690208
@@ -27,10 +27,12 @@
#include <QtCore/QFileInfo>
#include <QtCore/QDateTime>
#include <QtGui/QPixmapCache>
+#include <QtCore/QtGlobal>
#include <kglobal.h>
#include <kstandarddirs.h>
#include <kdebug.h>
+#include <klockfile.h>
#include <sys/file.h>
@@ -49,6 +51,7 @@
: mFile(filename)
{
mValid = false;
+#ifndef Q_OS_WIN
if (!mFile.open(QIODevice::ReadOnly)) {
kError() << k_funcinfo << "Failed to open file '" << filename << "'" << endl;
} else if (::flock(mFile.handle(), exclusive ? LOCK_EX : LOCK_SH)) {
@@ -57,12 +60,27 @@
} else {
mValid = true;
}
+#else
+ mLockFile = new KLockFile(filename);
+ if (mLockFile->lock() != KLockFile::LockOK) {
+ kError() << k_funcinfo << "Failed to lock file '" << filename << "'" << endl;
+ } else {
+ mValid = true;
+ }
+#endif
}
~LockFile()
{
+#ifndef Q_OS_WIN
if (mValid) {
::flock(mFile.handle(), LOCK_UN);
}
+#else
+ if (mValid) {
+ mLockFile->unlock();
+ }
+ delete mLockFile;
+#endif
}
bool isValid() const { return mValid; }
@@ -70,6 +88,9 @@
private:
QFile mFile;
bool mValid;
+#ifdef Q_OS_WIN
+ KLockFile* mLockFile;
+#endif
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic