From 87a81ed1a755316853e64520dd7db199f0dc158d Mon Sep 17 00:00:00 2001 From: miruka Date: Wed, 4 Dec 2019 06:22:04 -0400 Subject: [PATCH] Use real UUIDs for pendingCoroutines --- src/qml/Python.qml | 4 ++-- src/utils.cpp | 7 ++++++- src/utils.h | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/qml/Python.qml b/src/qml/Python.qml index 525e613e..aa9a87dd 100644 --- a/src/qml/Python.qml +++ b/src/qml/Python.qml @@ -15,7 +15,7 @@ Python { } function callCoro(name, args=[], onSuccess=null, onError=null) { - let uuid = Math.random() + "." + name + let uuid = name + "." + CppUtils.uuid() pendingCoroutines[uuid] = {onSuccess, onError} call("APP.call_backend_coro", [name, uuid, args]) @@ -25,7 +25,7 @@ Python { accountId, name, args=[], onSuccess=null, onError=null ) { callCoro("wait_until_client_exists", [accountId], () => { - let uuid = Math.random() + "." + name + let uuid = accountId + "." + name + "." + CppUtils.uuid() pendingCoroutines[uuid] = {onSuccess, onError} call("APP.call_client_coro", [accountId, name, uuid, args]) diff --git a/src/utils.cpp b/src/utils.cpp index b98a314e..44de256d 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "utils.h" @@ -14,3 +14,8 @@ QString Utils::formattedBytes(qint64 bytes, int precision) { bytes, precision, QLocale::DataSizeTraditionalFormat ); }; + + +QString Utils::uuid() { + return QUuid::createUuid().toString(QUuid::WithoutBraces); +} diff --git a/src/utils.h b/src/utils.h index 4fd2cb17..c49ee652 100644 --- a/src/utils.h +++ b/src/utils.h @@ -14,6 +14,7 @@ public: public slots: QString formattedBytes(qint64 bytes, int precision = 2); + QString uuid(); private: QLocale m_locale;