QSystemSemaphore: Fix broken translated messages
Add Q_DECLARE_TR_FUNCTIONS() and use tr(). Pick-to: 6.1 Change-Id: I31a27afa06ee2a592a7e588283e5ff08b5d14f3b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
This commit is contained in:
parent
3be3848338
commit
1128e0bea1
@ -40,6 +40,7 @@
|
||||
#ifndef QSYSTEMSEMAPHORE_H
|
||||
#define QSYSTEMSEMAPHORE_H
|
||||
|
||||
#include <QtCore/qcoreapplication.h>
|
||||
#include <QtCore/qstring.h>
|
||||
#include <QtCore/qscopedpointer.h>
|
||||
|
||||
@ -52,7 +53,7 @@ class QSystemSemaphorePrivate;
|
||||
|
||||
class Q_CORE_EXPORT QSystemSemaphore
|
||||
{
|
||||
|
||||
Q_DECLARE_TR_FUNCTIONS(QSystemSemaphore)
|
||||
public:
|
||||
enum AccessMode
|
||||
{
|
||||
|
@ -55,6 +55,7 @@
|
||||
|
||||
#ifndef QT_NO_SYSTEMSEMAPHORE
|
||||
|
||||
#include "qcoreapplication.h"
|
||||
#include "qsharedmemory_p.h"
|
||||
#include <sys/types.h>
|
||||
#ifdef QT_POSIX_IPC
|
||||
|
@ -70,7 +70,7 @@ bool QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode)
|
||||
return true; // we already have a semaphore
|
||||
|
||||
if (fileName.isEmpty()) {
|
||||
errorString = QCoreApplication::translate("%1: key is empty", "QSystemSemaphore").arg(QLatin1String("QSystemSemaphore::handle"));
|
||||
errorString = QSystemSemaphore::tr("%1: key is empty").arg(QLatin1String("QSystemSemaphore::handle"));
|
||||
error = QSystemSemaphore::KeyError;
|
||||
return false;
|
||||
}
|
||||
|
@ -72,13 +72,8 @@ QT_BEGIN_NAMESPACE
|
||||
key_t QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode)
|
||||
{
|
||||
if (key.isEmpty()){
|
||||
errorString =
|
||||
#if QT_CONFIG(translation)
|
||||
QCoreApplication::tr("%1: key is empty", "QSystemSemaphore")
|
||||
#else
|
||||
QLatin1String("%1: key is empty")
|
||||
#endif
|
||||
.arg(QLatin1String("QSystemSemaphore::handle:"));
|
||||
errorString = QSystemSemaphore::tr("%1: key is empty")
|
||||
.arg(QLatin1String("QSystemSemaphore::handle:"));
|
||||
error = QSystemSemaphore::KeyError;
|
||||
return -1;
|
||||
}
|
||||
@ -90,13 +85,8 @@ key_t QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode)
|
||||
// Create the file needed for ftok
|
||||
int built = QSharedMemoryPrivate::createUnixKeyFile(fileName);
|
||||
if (-1 == built) {
|
||||
errorString =
|
||||
#if QT_CONFIG(translation)
|
||||
QCoreApplication::tr("%1: unable to make key", "QSystemSemaphore")
|
||||
#else
|
||||
QLatin1String("%1: unable to make key")
|
||||
#endif
|
||||
.arg(QLatin1String("QSystemSemaphore::handle:"));
|
||||
errorString = QSystemSemaphore::tr("%1: unable to make key")
|
||||
.arg(QLatin1String("QSystemSemaphore::handle:"));
|
||||
error = QSystemSemaphore::KeyError;
|
||||
return -1;
|
||||
}
|
||||
@ -107,13 +97,8 @@ key_t QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode)
|
||||
unix_key = ftok(QFile::encodeName(fileName).constData(), 'Q');
|
||||
#endif
|
||||
if (-1 == unix_key) {
|
||||
errorString =
|
||||
#if QT_CONFIG(translation)
|
||||
QCoreApplication::tr("%1: ftok failed", "QSystemSemaphore")
|
||||
#else
|
||||
QLatin1String("%1: ftok failed")
|
||||
#endif
|
||||
.arg(QLatin1String("QSystemSemaphore::handle:"));
|
||||
errorString = QSystemSemaphore::tr("%1: ftok failed")
|
||||
.arg(QLatin1String("QSystemSemaphore::handle:"));
|
||||
error = QSystemSemaphore::KeyError;
|
||||
return -1;
|
||||
}
|
||||
|
@ -73,24 +73,24 @@ void QSystemSemaphorePrivate::setErrorString(const QString &function)
|
||||
switch (errno) {
|
||||
case EPERM:
|
||||
case EACCES:
|
||||
errorString = QCoreApplication::translate("QSystemSemaphore", "%1: permission denied").arg(function);
|
||||
errorString = QSystemSemaphore::tr("%1: permission denied").arg(function);
|
||||
error = QSystemSemaphore::PermissionDenied;
|
||||
break;
|
||||
case EEXIST:
|
||||
errorString = QCoreApplication::translate("QSystemSemaphore", "%1: already exists").arg(function);
|
||||
errorString = QSystemSemaphore::tr("%1: already exists").arg(function);
|
||||
error = QSystemSemaphore::AlreadyExists;
|
||||
break;
|
||||
case ENOENT:
|
||||
errorString = QCoreApplication::translate("QSystemSemaphore", "%1: does not exist").arg(function);
|
||||
errorString = QSystemSemaphore::tr("%1: does not exist").arg(function);
|
||||
error = QSystemSemaphore::NotFound;
|
||||
break;
|
||||
case ERANGE:
|
||||
case ENOSPC:
|
||||
errorString = QCoreApplication::translate("QSystemSemaphore", "%1: out of resources").arg(function);
|
||||
errorString = QSystemSemaphore::tr("%1: out of resources").arg(function);
|
||||
error = QSystemSemaphore::OutOfResources;
|
||||
break;
|
||||
default:
|
||||
errorString = QCoreApplication::translate("QSystemSemaphore", "%1: unknown error %2").arg(function).arg(errno);
|
||||
errorString = QSystemSemaphore::tr("%1: unknown error %2").arg(function).arg(errno);
|
||||
error = QSystemSemaphore::UnknownError;
|
||||
#if defined QSYSTEMSEMAPHORE_DEBUG
|
||||
qDebug() << errorString << "key" << key << "errno" << errno << EINVAL;
|
||||
|
Loading…
Reference in New Issue
Block a user