aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4mathobject.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2017-09-08 11:04:30 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2017-09-08 11:04:30 +0200
commitbde8c3cd9583ed9f3bdfc36a8699f56db20a6928 (patch)
tree33246b027739aafd72f9f289876f69627537f2b3 /src/qml/jsruntime/qv4mathobject.cpp
parentb63bc868875d7571bc332804f984824cff7c5b78 (diff)
parent685ad676a84bf48602a5da8f7171792686b94a73 (diff)
Merge remote-tracking branch 'origin/dev' into wip/new-backend
Conflicts: src/qml/compiler/qv4isel_moth.cpp src/qml/compiler/qv4jsir.cpp src/qml/jsruntime/qv4mathobject.cpp Change-Id: I426f1f4f0a5302b5bcff021de11766a03fec7637
Diffstat (limited to 'src/qml/jsruntime/qv4mathobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4mathobject.cpp16
1 files changed, 3 insertions, 13 deletions
diff --git a/src/qml/jsruntime/qv4mathobject.cpp b/src/qml/jsruntime/qv4mathobject.cpp
index 2c1fefe9f8..cdf5c3117c 100644
--- a/src/qml/jsruntime/qv4mathobject.cpp
+++ b/src/qml/jsruntime/qv4mathobject.cpp
@@ -42,6 +42,7 @@
#include <QtCore/qdatetime.h>
#include <QtCore/qmath.h>
+#include <QtCore/qrandom.h>
#include <QtCore/private/qnumeric_p.h>
#include <QtCore/qthreadstorage.h>
@@ -273,20 +274,9 @@ ReturnedValue MathObject::method_pow(const BuiltinFunction *, CallData *callData
RETURN_RESULT(Encode(qt_qnan()));
}
-Q_GLOBAL_STATIC(QThreadStorage<bool *>, seedCreatedStorage);
-
-ReturnedValue MathObject::method_random(const BuiltinFunction *b, CallData *)
+ReturnedValue MathObject::method_random(const BuiltinFunction *, CallData *)
{
- if (!seedCreatedStorage()->hasLocalData()) {
- int msecs = QTime(0,0,0).msecsTo(QTime::currentTime());
- Q_ASSERT(msecs >= 0);
- qsrand(uint(uint(msecs) ^ reinterpret_cast<quintptr>(b)));
- seedCreatedStorage()->setLocalData(new bool(true));
- }
- // rand()/qrand() return a value where the upperbound is RAND_MAX inclusive. So, instead of
- // dividing by RAND_MAX (which would return 0..RAND_MAX inclusive), we divide by RAND_MAX + 1.
- qint64 upperLimit = qint64(RAND_MAX) + 1;
- RETURN_RESULT(Encode(qrand() / double(upperLimit)));
+ RETURN_RESULT(Encode(QRandomGenerator::getReal()));
}
ReturnedValue MathObject::method_round(const BuiltinFunction *, CallData *callData)