avoid QAtomicInt assignment

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-02-23 09:35:51 +02:00
parent f29abfe0fe
commit 551b9ebdfc
11 changed files with 20 additions and 22 deletions

View file

@ -95,7 +95,7 @@ inline timeval operator*(const timeval &t1, int mul)
static inline void qt_ignore_sigpipe()
{
// Set to ignore SIGPIPE once only.
static QAtomicInt atom = QAtomicInt(0);
static QAtomicInt atom(0);
if (!atom) {
// More than one thread could turn off SIGPIPE at the same time
// But that's acceptable because they all would be doing the same

View file

@ -83,7 +83,7 @@ static int *queuedConnectionTypes(const QList<QByteArray> &typeNames)
#ifndef QT_NO_THREAD
static QAtomicPointer<QMutexPool> signalSlotMutexes = QAtomicPointer<QMutexPool>(Q_NULLPTR);
#endif
static QAtomicInt objectCount = QAtomicInt(0);
static QAtomicInt objectCount(0);
/** \internal
* mutex to be locked when accessing the connectionlists or the senders list

View file

@ -51,8 +51,8 @@ QT_BEGIN_NAMESPACE
// used with dbus_server_allocate_data_slot
static dbus_int32_t server_slot = -1;
static QAtomicInt isDebugging = QAtomicInt(-1);
#define qDBusDebug if (isDebugging == 0); else qDebug
static const bool isDebugging = !qgetenv("QDBUS_DEBUG").isNull();
#define qDBusDebug if (!isDebugging); else qDebug
static const QString orgFreedesktopDBusString = QLatin1String(DBUS_SERVICE_DBUS);
@ -952,12 +952,10 @@ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p)
rootNode(QString(QLatin1Char('/')))
{
static const bool threads = dbus_threads_init_default();
if (isDebugging == -1)
isDebugging = qgetenv("QDBUS_DEBUG").toInt();
Q_UNUSED(threads)
#if QDBUS_THREAD_DEBUG
if (isDebugging > 1)
if (isDebugging)
qdbusThreadDebug = qdbusDefaultThreadDebug;
#endif

View file

@ -268,7 +268,7 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
localProgress);
qSwap(currentValue, ret);
q->updateCurrentValue(currentValue);
static QAtomicInt changedSignalIndex = QAtomicInt(0);
static QAtomicInt changedSignalIndex(0);
if (!changedSignalIndex) {
//we keep the mask so that we emit valueChanged only when needed (for performance reasons)
changedSignalIndex.testAndSetRelaxed(0, signalIndex("valueChanged(QVariant)"));

View file

@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE
\value On Display the pixmap when the widget is in an "on" state
*/
static QAtomicInt serialNumCounter = QAtomicInt(1);
static QAtomicInt serialNumCounter(1);
typedef QCache<QString, QIcon> IconCache;
Q_GLOBAL_STATIC(IconCache, qtIconCache)

View file

@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
return QImage(); \
}
QAtomicInt qimage_serial_number = QAtomicInt(1);
QAtomicInt qimage_serial_number(1);
QImageData::QImageData()
: ref(0), width(0), height(0), depth(0), nbytes(0), data(0),

View file

@ -170,7 +170,7 @@ static int defaultScreen = -1;
QPixmap member functions
*****************************************************************************/
QAtomicInt qt_pixmap_serial = QAtomicInt(0);
QAtomicInt qt_pixmap_serial(0);
QX11PixmapData::QX11PixmapData(PixelType type)
: QPixmapData(type, X11Class), hd(0),

View file

@ -82,7 +82,7 @@ Q_GLOBAL_STATIC(QHostInfoCache, globalHostInfoCache)
\sa QAbstractSocket, {http://www.rfc-editor.org/rfc/rfc3492.txt}{RFC 3492}
*/
static QAtomicInt theIdCounter = QAtomicInt(1);
static QAtomicInt theIdCounter(1);
/*!
Looks up the IP address(es) associated with host name \a name, and

View file

@ -966,7 +966,7 @@ QSocks5SocketEngine::~QSocks5SocketEngine()
delete d->bindData;
}
static QAtomicInt descriptorCounter = QAtomicInt(1);
static QAtomicInt descriptorCounter(1);
bool QSocks5SocketEngine::initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol)
{

View file

@ -66,7 +66,7 @@ private:
int threadFinishedCount;
};
static QAtomicInt counter = QAtomicInt(0);
static QAtomicInt counter(0);
class QtTestSqlThread : public QThread
{

View file

@ -213,23 +213,23 @@ void tst_QThreadPool::waitcomplete()
QCOMPARE(testFunctionCount, runs);
}
QAtomicInt ran = QAtomicInt(false); // bool
QAtomicInt ran(0); // bool
class TestTask : public QRunnable
{
public:
void run()
{
ran = true;
ran = 1;
}
};
void tst_QThreadPool::runTask()
{
QThreadPool manager;
ran = false;
ran = 0;
manager.start(new TestTask());
// Hang if task is not runned.
while (ran == false)
while (ran == 0)
QTest::qSleep(100); // no busy loop - this doesn't work with FIFO schedulers
}
@ -238,9 +238,9 @@ void tst_QThreadPool::runTask()
*/
void tst_QThreadPool::singleton()
{
ran = false;
ran = 0;
QThreadPool::globalInstance()->start(new TestTask());
while (ran == false)
while (ran == 0)
QTest::qSleep(100); // no busy loop - this doesn't work with FIFO schedulers
}
@ -771,8 +771,8 @@ void tst_QThreadPool::tryStart()
}
QMutex mutex;
QAtomicInt activeThreads = QAtomicInt(0);
QAtomicInt peakActiveThreads = QAtomicInt(0);
QAtomicInt activeThreads(0);
QAtomicInt peakActiveThreads(0);
void tst_QThreadPool::tryStartPeakThreadCount()
{
class CounterTask : public QRunnable