Issue #77 Reduce dependency on Qt

This commit is contained in:
Mat Sutcliffe
2020-08-24 00:37:11 +01:00
parent 0c78c187f8
commit 6703922de5
4 changed files with 6 additions and 13 deletions

View File

@@ -11,8 +11,6 @@
#ifndef BLACKMISC_ALGORITHM_H
#define BLACKMISC_ALGORITHM_H
#include <QThreadStorage>
#include <QRandomGenerator>
#include <QtGlobal>
#include <algorithm>
#include <iterator>
@@ -45,16 +43,12 @@ namespace BlackMisc
namespace Private
{
//! \private A high quality deterministic pseudo-random number generator.
//! \private A high quality pseudo-random number generator.
//! \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();
thread_local std::mt19937 rng(std::random_device{}());
return rng;
}
}

View File

@@ -12,9 +12,11 @@
#define BLACKMISC_INHERITANCE_TRAITS_H
#include "blackmisc/typetraits.h" // for void_t
#include <QMetaType>
#include <type_traits>
template <typename T>
struct QMetaTypeId;
namespace BlackMisc
{
class CPropertyIndex;

View File

@@ -12,8 +12,6 @@
#define BLACKMISC_PREDICATES_H
#include "blackmisc/algorithm.h"
#include <QObject>
#include <functional>
#include <algorithm>

View File

@@ -16,7 +16,6 @@
#include <QPointer>
#include <QObject>
#include <QtGlobal>
#include <QTimer>
#include <atomic>
#include <functional>