mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 21:56:43 +08:00
Move function-scope static QThreadStorage objects to namespace scope
to ensure destruction after all function-scope statics and avoid warning "thread exited after QThreadStorage destroyed".
This commit is contained in:
@@ -50,6 +50,9 @@ namespace BlackMisc
|
||||
//! \threadsafe
|
||||
inline std::mt19937 &defaultRandomGenerator()
|
||||
{
|
||||
//! \fixme Move rng to namespace scope to ensure destruction after function-local statics
|
||||
//! and avoid warning "thread exited after QThreadStorage destroyed".
|
||||
//! This will require careful thought about linkage.
|
||||
static QThreadStorage<std::mt19937> rng;
|
||||
if (rng.hasLocalData()) { rng.setLocalData(std::mt19937(static_cast<std::mt19937::result_type>(QRandomGenerator::global()->generate()))); }
|
||||
return rng.localData();
|
||||
|
||||
Reference in New Issue
Block a user