From aa75a39b3e3a4ae762f05b4a2e91d9790c8d5c88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lutz=20Sch=C3=B6nemann?= Date: Thu, 24 Jul 2014 17:31:22 +0200 Subject: Use UUIDs to identify wrapped objects Instead of using stringified pointers to identify objects this patch creates UUIDs (version 4) for every object that get's wrapped by QMetaObjectPublisher Especially when using QtWebChannel to publish an interface to the network it comes to the point that you don't want to publish internal memory addresses Change-Id: I7e3fec7497d63572cfba72a5dacc10542aef415c Reviewed-by: Sumedha Widyadharma Reviewed-by: Oswald Buddenhagen Reviewed-by: Milian Wolff Reviewed-by: Michael Bruning --- src/webchannel/qmetaobjectpublisher.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/webchannel/qmetaobjectpublisher.cpp b/src/webchannel/qmetaobjectpublisher.cpp index 7c6c6eb..14b94f8 100644 --- a/src/webchannel/qmetaobjectpublisher.cpp +++ b/src/webchannel/qmetaobjectpublisher.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #if HAVE_QML #include @@ -85,11 +86,6 @@ const QString KEY_ARGS = QStringLiteral("args"); const QString KEY_PROPERTY = QStringLiteral("property"); const QString KEY_VALUE = QStringLiteral("value"); -QString objectId(const QObject *object) -{ - return QString::number(quintptr(object), 16); -} - /// TODO: what is the proper value here? const int PROPERTY_UPDATE_INTERVAL = 50; } @@ -442,8 +438,7 @@ QJsonValue QMetaObjectPublisher::wrapResult(const QVariant &result) return objectInfo; } // else the object is not yet wrapped, do it now - const QString &id = objectId(object); - Q_ASSERT(!registeredObjects.contains(id)); + const QString &id = QUuid::createUuid().toString(); Q_ASSERT(!registeredObjectIds.contains(object)); objectInfo[KEY_QOBJECT] = true; -- cgit v1.2.1