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