QSystemSemaphore: Clear error after successful operation
Change-Id: I5c1021b2329439e3aefaa1c0d9c0b8a298d285de Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
6aa496c366
commit
ed9e954f4b
@ -229,8 +229,7 @@ void QSystemSemaphore::setKey(const QString &key, int initialValue, AccessMode m
|
||||
{
|
||||
if (key == d->key && mode == Open)
|
||||
return;
|
||||
d->error = NoError;
|
||||
d->errorString = QString();
|
||||
d->clearError();
|
||||
#if !defined(Q_OS_WIN)
|
||||
// optimization to not destroy/create the file & semaphore
|
||||
if (key == d->key && mode == Create && d->createdSemaphore && d->createdFile) {
|
||||
|
@ -75,6 +75,11 @@ public:
|
||||
return QSharedMemoryPrivate::makePlatformSafeKey(key, QLatin1String("qipc_systemsem_"));
|
||||
}
|
||||
|
||||
inline void setError(QSystemSemaphore::SystemSemaphoreError e, const QString &message)
|
||||
{ error = e; errorString = message; }
|
||||
inline void clearError()
|
||||
{ setError(QSystemSemaphore::NoError, QString()); }
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
Qt::HANDLE handle(QSystemSemaphore::AccessMode mode = QSystemSemaphore::Open);
|
||||
void setErrorString(const QString &function);
|
||||
|
@ -229,6 +229,7 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
|
||||
return false;
|
||||
}
|
||||
|
||||
clearError();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -136,6 +136,7 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
|
||||
}
|
||||
}
|
||||
|
||||
clearError();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -145,12 +145,19 @@ void tst_QSystemSemaphore::complexacquire()
|
||||
{
|
||||
QSystemSemaphore sem("QSystemSemaphore_complexacquire", 2, QSystemSemaphore::Create);
|
||||
QVERIFY(sem.acquire());
|
||||
QCOMPARE(sem.error(), QSystemSemaphore::NoError);
|
||||
QVERIFY(sem.release());
|
||||
QCOMPARE(sem.error(), QSystemSemaphore::NoError);
|
||||
QVERIFY(sem.acquire());
|
||||
QCOMPARE(sem.error(), QSystemSemaphore::NoError);
|
||||
QVERIFY(sem.release());
|
||||
QCOMPARE(sem.error(), QSystemSemaphore::NoError);
|
||||
QVERIFY(sem.acquire());
|
||||
QCOMPARE(sem.error(), QSystemSemaphore::NoError);
|
||||
QVERIFY(sem.acquire());
|
||||
QCOMPARE(sem.error(), QSystemSemaphore::NoError);
|
||||
QVERIFY(sem.release());
|
||||
QCOMPARE(sem.error(), QSystemSemaphore::NoError);
|
||||
QVERIFY(sem.release());
|
||||
QCOMPARE(sem.error(), QSystemSemaphore::NoError);
|
||||
QCOMPARE(sem.errorString(), QString());
|
||||
|
Loading…
x
Reference in New Issue
Block a user