summaryrefslogtreecommitdiffstats
path: root/src/libs/kdtools
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@digia.com>2014-11-11 11:29:32 +0100
committerKarsten Heimrich <karsten.heimrich@theqtcompany.com>2014-11-11 12:22:16 +0100
commit3030607e6445ba98597c3118b0afc29715ff9305 (patch)
treec5c7acab86ab83c8e29734dac7c4afabdd3fe804 /src/libs/kdtools
parent7f036a60976ec6ccae70a95f43ca2ca838b384f8 (diff)
Don't use QObject::tr().
Change-Id: I2931d72e2e7add6fb5179b831ad91670fc6d1604 Reviewed-by: Niels Weber <niels.weber@digia.com>
Diffstat (limited to 'src/libs/kdtools')
-rw-r--r--src/libs/kdtools/kdlockfile_unix.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/libs/kdtools/kdlockfile_unix.cpp b/src/libs/kdtools/kdlockfile_unix.cpp
index e6b3dbe9d..eac314bbe 100644
--- a/src/libs/kdtools/kdlockfile_unix.cpp
+++ b/src/libs/kdtools/kdlockfile_unix.cpp
@@ -50,7 +50,8 @@ bool KDLockFile::Private::lock()
errno = 0;
handle = open(filename.toLatin1().constData(), O_CREAT | O_RDWR | O_NONBLOCK, 0600);
if (handle == -1) {
- errorString = QObject::tr("Could not create lock file %1: %2").arg(filename, QLatin1String(strerror(errno)));
+ errorString = QCoreApplication::translate("KDLockFile", "Could not create lock file '%1': "
+ "%2").arg(filename, QString::fromLocal8Bit(strerror(errno)));
return false;
}
const QString pid = QString::number(qApp->applicationPid());
@@ -60,15 +61,18 @@ bool KDLockFile::Private::lock()
while (written < data.size()) {
const qint64 n = write(handle, data.constData() + written, data.size() - written);
if (n < 0) {
- errorString = QObject::tr("Could not write PID to lock file %1: %2").arg( filename, QLatin1String( strerror( errno ) ) );
+ errorString = QCoreApplication::translate("KDLockFile", "Could not write PID to lock "
+ "file '%1': %2").arg(filename, QString::fromLocal8Bit(strerror(errno)));
return false;
}
written += n;
}
errno = 0;
locked = flock(handle, LOCK_NB | LOCK_EX) != -1;
- if (!locked)
- errorString = QObject::tr("Could not lock lock file %1: %2").arg(filename, QLatin1String(strerror(errno)));
+ if (!locked) {
+ errorString = QCoreApplication::translate("KDLockFile", "Could not obtain the lock for "
+ "file '%1': %2").arg(filename, QString::fromLocal8Bit(strerror(errno)));
+ }
return locked;
}
@@ -77,11 +81,14 @@ bool KDLockFile::Private::unlock()
errorString.clear();
if (!locked)
return true;
+
errno = 0;
locked = flock(handle, LOCK_UN | LOCK_NB) == -1;
- if (locked)
- errorString = QObject::tr("Could not unlock lock file %1: %2").arg(filename, QLatin1String(strerror(errno)));
- else
+ if (locked) {
+ errorString = QCoreApplication::translate("KDLockFile", "Could not release the lock for "
+ "file '%1': %2").arg(filename, QString::fromLocal8Bit(strerror(errno)));
+ } else {
unlink(filename.toLatin1());
+ }
return !locked;
}