mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 02:42:55 +00:00
various cleanups
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
parent
e2965b4413
commit
be83f7d709
5 changed files with 18 additions and 26 deletions
|
@ -63,14 +63,11 @@ QString QSharedMemoryPrivate::makePlatformSafeKey(const QString &key,
|
|||
if (key.isEmpty())
|
||||
return QString();
|
||||
|
||||
QString result = prefix;
|
||||
|
||||
QString part1 = key;
|
||||
part1.replace(QRegExp(QLatin1String("[^A-Za-z]")), QString());
|
||||
result.append(part1);
|
||||
|
||||
QByteArray hex = QCryptographicHash::hash(key.toUtf8(), QCryptographicHash::Sha1).toHex();
|
||||
result.append(QLatin1String(hex.constData()));
|
||||
QString result = (part1 + QString::fromLatin1(hex.constData()));
|
||||
#if defined(QT_POSIX_IPC)
|
||||
return QLatin1Char('/') + result;
|
||||
#else
|
||||
|
@ -238,8 +235,7 @@ bool QSharedMemoryPrivate::initKey()
|
|||
systemSemaphore.setKey(QString(), 1);
|
||||
systemSemaphore.setKey(key, 1);
|
||||
if (systemSemaphore.error() != QSystemSemaphore::NoError) {
|
||||
QString function = QLatin1String("QSharedMemoryPrivate::initKey");
|
||||
errorString = QSharedMemory::tr("%1: unable to set key on lock").arg(function);
|
||||
errorString = QSharedMemory::tr("%1: unable to set key on lock").arg(QLatin1String("QSharedMemoryPrivate::initKey"));
|
||||
switch(systemSemaphore.error()) {
|
||||
case QSystemSemaphore::PermissionDenied:
|
||||
error = QSharedMemory::PermissionDenied;
|
||||
|
@ -496,8 +492,7 @@ bool QSharedMemory::lock()
|
|||
d->lockedByMe = true;
|
||||
return true;
|
||||
}
|
||||
const QString function = QLatin1String("QSharedMemory::lock");
|
||||
d->errorString = QSharedMemory::tr("%1: unable to lock").arg(function);
|
||||
d->errorString = QSharedMemory::tr("%1: unable to lock").arg(QLatin1String("QSharedMemory::lock"));
|
||||
d->error = QSharedMemory::LockError;
|
||||
return false;
|
||||
}
|
||||
|
@ -518,8 +513,7 @@ bool QSharedMemory::unlock()
|
|||
d->lockedByMe = false;
|
||||
if (d->systemSemaphore.release())
|
||||
return true;
|
||||
const QString function = QLatin1String("QSharedMemory::unlock");
|
||||
d->errorString = QSharedMemory::tr("%1: unable to unlock").arg(function);
|
||||
d->errorString = QSharedMemory::tr("%1: unable to unlock").arg(QLatin1String("QSharedMemory::unlock"));
|
||||
d->error = QSharedMemory::LockError;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -59,14 +59,12 @@ class Q_CORE_EXPORT QSharedMemory : public QObject
|
|||
Q_DECLARE_PRIVATE(QSharedMemory)
|
||||
|
||||
public:
|
||||
enum AccessMode
|
||||
{
|
||||
enum AccessMode {
|
||||
ReadOnly,
|
||||
ReadWrite
|
||||
};
|
||||
|
||||
enum SharedMemoryError
|
||||
{
|
||||
enum SharedMemoryError {
|
||||
NoError,
|
||||
PermissionDenied,
|
||||
InvalidSize,
|
||||
|
|
|
@ -175,7 +175,7 @@ static void construct(QVariant::Private *x, const void *copy)
|
|||
case QVariant::Double:
|
||||
x->data.d = copy ? *static_cast<const double*>(copy) : 0.0;
|
||||
break;
|
||||
case QMetaType::Float:
|
||||
case QVariant::Float:
|
||||
x->data.f = copy ? *static_cast<const float*>(copy) : 0.0f;
|
||||
break;
|
||||
case QMetaType::QObjectStar:
|
||||
|
@ -286,7 +286,7 @@ static void clear(QVariant::Private *d)
|
|||
case QVariant::LongLong:
|
||||
case QVariant::ULongLong:
|
||||
case QVariant::Double:
|
||||
case QMetaType::Float:
|
||||
case QVariant::Float:
|
||||
case QMetaType::QObjectStar:
|
||||
break;
|
||||
case QVariant::Invalid:
|
||||
|
@ -454,7 +454,7 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b)
|
|||
return a->data.b == b->data.b;
|
||||
case QVariant::Double:
|
||||
return a->data.d == b->data.d;
|
||||
case QMetaType::Float:
|
||||
case QVariant::Float:
|
||||
return a->data.f == b->data.f;
|
||||
case QMetaType::QObjectStar:
|
||||
return a->data.o == b->data.o;
|
||||
|
@ -525,7 +525,7 @@ static qlonglong qMetaTypeNumber(const QVariant::Private *d)
|
|||
return qlonglong(*static_cast<short *>(d->data.shared->ptr));
|
||||
case QMetaType::Long:
|
||||
return qlonglong(*static_cast<long *>(d->data.shared->ptr));
|
||||
case QMetaType::Float:
|
||||
case QVariant::Float:
|
||||
return qRound64(d->data.f);
|
||||
case QVariant::Double:
|
||||
return qRound64(d->data.d);
|
||||
|
@ -619,7 +619,7 @@ static qulonglong qConvertToUnsignedNumber(const QVariant::Private *d, bool *ok)
|
|||
case QMetaType::Char:
|
||||
case QMetaType::Short:
|
||||
case QMetaType::Long:
|
||||
case QMetaType::Float:
|
||||
case QVariant::Float:
|
||||
case QMetaType::LongLong:
|
||||
return qulonglong(qMetaTypeNumber(d));
|
||||
case QVariant::ULongLong:
|
||||
|
@ -689,7 +689,7 @@ static bool convert(const QVariant::Private *d, QVariant::Type t, void *result,
|
|||
case QMetaType::ULong:
|
||||
*str = QString::number(qMetaTypeUNumber(d));
|
||||
break;
|
||||
case QMetaType::Float:
|
||||
case QVariant::Float:
|
||||
*str = QString::number(d->data.f, 'g', FLT_DIG);
|
||||
break;
|
||||
case QVariant::Double:
|
||||
|
@ -871,7 +871,7 @@ static bool convert(const QVariant::Private *d, QVariant::Type t, void *result,
|
|||
case QVariant::Double:
|
||||
*ba = QByteArray::number(d->data.d, 'g', DBL_DIG);
|
||||
break;
|
||||
case QMetaType::Float:
|
||||
case QVariant::Float:
|
||||
*ba = QByteArray::number(d->data.f, 'g', FLT_DIG);
|
||||
break;
|
||||
case QMetaType::Char:
|
||||
|
@ -945,7 +945,7 @@ static bool convert(const QVariant::Private *d, QVariant::Type t, void *result,
|
|||
case QMetaType::Char:
|
||||
case QMetaType::Short:
|
||||
case QMetaType::Long:
|
||||
case QMetaType::Float:
|
||||
case QVariant::Float:
|
||||
*b = qMetaTypeNumber(d) != Q_INT64_C(0);
|
||||
break;
|
||||
case QVariant::UInt:
|
||||
|
@ -1010,7 +1010,7 @@ static bool convert(const QVariant::Private *d, QVariant::Type t, void *result,
|
|||
}
|
||||
break;
|
||||
}
|
||||
case QMetaType::Float: {
|
||||
case QVariant::Float: {
|
||||
float *f = static_cast<float *>(result);
|
||||
switch (d->type) {
|
||||
case QVariant::String:
|
||||
|
|
|
@ -96,7 +96,7 @@ QMutexPool::QMutexPool(QMutex::RecursionMode recursionMode, int size)
|
|||
: mutexes(size), recursionMode(recursionMode)
|
||||
{
|
||||
for (int index = 0; index < mutexes.count(); ++index) {
|
||||
mutexes[index] = 0;
|
||||
mutexes[index] = Q_NULLPTR;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ QMutexPool::~QMutexPool()
|
|||
{
|
||||
for (int index = 0; index < mutexes.count(); ++index) {
|
||||
delete mutexes[index];
|
||||
mutexes[index] = 0;
|
||||
mutexes[index] = Q_NULLPTR;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -216,7 +216,7 @@ bool QSemaphore::tryAcquire(int n, int timeout)
|
|||
{
|
||||
Q_ASSERT_X(n >= 0, "QSemaphore::tryAcquire", "parameter 'n' must be non-negative");
|
||||
QMutexLocker locker(&d->mutex);
|
||||
if (timeout < 0) {
|
||||
if (timeout <= 0) {
|
||||
while (n > d->avail)
|
||||
d->cond.wait(locker.mutex());
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue