mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-22 07:54:18 +01:00
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.
This commit is contained in:
parent
73c0af1977
commit
5f75bde396
@ -278,7 +278,7 @@ void WorkerPool<HandlerType>::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);
|
||||
|
Loading…
Reference in New Issue
Block a user