QJNIHelpers: unbreak runnables counter

Adding 0 each time will obviously not produce a new identifier each
time...

Also use static initialization for QBasicAtomicInt.

A default-constructed static QBasicAtomicInt at function scope
will be dynamically initialized. It will still be zero-initialized,
but at least GCC adds guard variables for such objects.

When using aggregate initialization, the guard disappears.

Amends 265db5ad9bda9c984393c1e95fd27dcc4633ed1c.

Change-Id: Ia71290cf26c486dcbcc74381f12cd0c4712d6019
Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
Marc Mutz 2017-02-16 15:03:01 +01:00
parent bee82432eb
commit f05d2764b0

View File

@ -79,8 +79,8 @@ Q_GLOBAL_STATIC(PendingPermissionRequestsHash, g_pendingPermissionRequests);
static QBasicMutex g_pendingPermissionRequestsMutex;
static int nextRequestCode()
{
static QBasicAtomicInt counter;
return counter.fetchAndAddRelaxed(0);
static QBasicAtomicInt counter = Q_BASIC_ATOMIC_INITIALIZER(0);
return counter.fetchAndAddRelaxed(1);
}
// function called from Java from Android UI thread