diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2018-11-20 11:03:46 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2018-11-22 08:51:59 +0000 |
commit | 9926a4a49e8211a996667b467fd98b915e9f9d34 (patch) | |
tree | d514b131de6da988bc39c40753d2298b0cdccb09 /src/qml/jsruntime/qv4qobjectwrapper.cpp | |
parent | 33c13efd91954fb50019e82f3ab8e8e1d8458332 (diff) |
V4: Avoid copying WeakValues with wrapped QObjects
Such WeakValues are kept alive until the respective QObject is deleted.
Therefore they are quite expensive. In this case we don't actually need
a copy as on retrieval we only want a ReturnValue and on inserting we
just want to replace the value in the map.
Fixes: QTBUG-71817
Change-Id: I385c55140337d468289046243941077ba1ff61a3
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4qobjectwrapper.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 8cdec2f6ee..9344a231ff 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -2226,9 +2226,7 @@ void QmlSignalHandler::initProto(ExecutionEngine *engine) void MultiplyWrappedQObjectMap::insert(QObject *key, Heap::Object *value) { - QV4::WeakValue v; - v.set(value->internalClass->engine, value); - QHash<QObject*, QV4::WeakValue>::insert(key, v); + QHash<QObject*, QV4::WeakValue>::operator[](key).set(value->internalClass->engine, value); connect(key, SIGNAL(destroyed(QObject*)), this, SLOT(removeDestroyedObject(QObject*))); } |