summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qrandom.h9
-rw-r--r--src/corelib/plugin/quuid.cpp2
-rw-r--r--src/corelib/tools/qhash.cpp2
3 files changed, 7 insertions, 6 deletions
diff --git a/src/corelib/global/qrandom.h b/src/corelib/global/qrandom.h
index 2259f2657a..049495d4e8 100644
--- a/src/corelib/global/qrandom.h
+++ b/src/corelib/global/qrandom.h
@@ -51,9 +51,12 @@ class QRandomGenerator
template <typename UInt> using IfValidUInt =
typename std::enable_if<std::is_unsigned<UInt>::value && sizeof(UInt) >= sizeof(uint), bool>::type;
public:
+ static QRandomGenerator system() { return {}; }
+ static QRandomGenerator global() { return {}; }
QRandomGenerator() = default;
// ### REMOVE BEFORE 5.10
+ QRandomGenerator *operator->() { return this; }
static quint32 get32() { return generate(); }
static quint64 get64() { return generate64(); }
static qreal getReal() { return generateDouble(); }
@@ -135,13 +138,14 @@ public:
static Q_DECL_CONSTEXPR result_type max() { return (std::numeric_limits<result_type>::max)(); }
private:
- Q_DISABLE_COPY(QRandomGenerator)
static Q_CORE_EXPORT void fillRange_helper(void *buffer, void *bufferEnd);
};
class QRandomGenerator64
{
public:
+ static QRandomGenerator64 system() { return {}; }
+ static QRandomGenerator64 global() { return {}; }
QRandomGenerator64() = default;
static quint64 generate() { return QRandomGenerator::generate64(); }
@@ -152,9 +156,6 @@ public:
double entropy() const Q_DECL_NOTHROW { return 0.0; }
static Q_DECL_CONSTEXPR result_type min() { return (std::numeric_limits<result_type>::min)(); }
static Q_DECL_CONSTEXPR result_type max() { return (std::numeric_limits<result_type>::max)(); }
-
-private:
- Q_DISABLE_COPY(QRandomGenerator64)
};
diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp
index 11ef247531..3a1c0495fe 100644
--- a/src/corelib/plugin/quuid.cpp
+++ b/src/corelib/plugin/quuid.cpp
@@ -945,7 +945,7 @@ QUuid QUuid::createUuid()
QUuid result(Qt::Uninitialized);
uint *data = &(result.data1);
enum { AmountToRead = 4 };
- QRandomGenerator::fillRange(data, AmountToRead);
+ QRandomGenerator::system()->fillRange(data, AmountToRead);
result.data4[0] = (result.data4[0] & 0x3F) | 0x80; // UV_DCE
result.data3 = (result.data3 & 0x0FFF) | 0x4000; // UV_Random
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
index 485c6591c2..ded9ad354e 100644
--- a/src/corelib/tools/qhash.cpp
+++ b/src/corelib/tools/qhash.cpp
@@ -296,7 +296,7 @@ static uint qt_create_qhash_seed()
return seed;
}
- seed = QRandomGenerator::generate();
+ seed = QRandomGenerator::system()->generate();
#endif // QT_BOOTSTRAPPED
return seed;