From 5f75bde396fe28d8e0dd5b17b2baf2de185ec3db Mon Sep 17 00:00:00 2001 From: Jim Broadus Date: Wed, 21 Apr 2021 14:35:12 -0700 Subject: [PATCH] libclementine-common: Use positive numbers for worker ids. QRandomGenerator::generate() returns an unbounded int32, while the legacy qrand method always returned a positive number. When generating a tag reader ID with QRandomGenerator, cast the random value to an unsigned so that it is formatted as a positive number in the name. Note that most usages of QRandomGenrator in the codebase use bounded() instead of generate(), and should work as expected. --- ext/libclementine-common/core/workerpool.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/libclementine-common/core/workerpool.h b/ext/libclementine-common/core/workerpool.h index b9c0ca32e..6beecb831 100644 --- a/ext/libclementine-common/core/workerpool.h +++ b/ext/libclementine-common/core/workerpool.h @@ -278,7 +278,7 @@ void WorkerPool::StartOneWorker(Worker* worker) { const int unique_number = qrand() ^ ((int)(quint64(this) & 0xFFFFFFFF)); #else // The global generator is securely seeded. - const int unique_number = QRandomGenerator::global()->generate(); + const unsigned int unique_number = QRandomGenerator::global()->generate(); #endif const QString name = QString("%1_%2").arg(local_server_name_).arg(unique_number);