aboutsummaryrefslogtreecommitdiffstats
path: root/src/webchannel/qmetaobjectpublisher_p.h
diff options
context:
space:
mode:
authorArno Rehn <a.rehn@menlosystems.com>2020-08-10 21:52:14 +0200
committerArno Rehn <a.rehn@menlosystems.com>2020-08-17 10:37:25 +0200
commit0451ef836415c93a6beb68a315a25c6ab27f44fa (patch)
tree9d92d880616a24af4b5ca381a317750cfd8ca954 /src/webchannel/qmetaobjectpublisher_p.h
parenta1d717d881f6f1e72cf2643826b6025c1d16d7f6 (diff)
Fix infinite recursion when wrapping a self-contained object twice
The previous unit test for self-contained objects only wrapped the test object once. After wrapping, a different code path is taken which still exhibited infinite recursion. This patch addresses both the unit test and the infinite recursion. To fix the problem, a boolean in the ObjectInfo struct is toggled to indicate whether the object in question is currently being wrapped. If that is the case, the recursing code path is skipped. [ChangeLog][General] Fixed infinite recursion when dealing with self contained objects. Fixes: QTBUG-84007 Pick-to: 5.15 Change-Id: Ie0898fb5f28cec91587897835ff937672d60f2a1 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'src/webchannel/qmetaobjectpublisher_p.h')
-rw-r--r--src/webchannel/qmetaobjectpublisher_p.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/webchannel/qmetaobjectpublisher_p.h b/src/webchannel/qmetaobjectpublisher_p.h
index d7e2a5b..5e57e8c 100644
--- a/src/webchannel/qmetaobjectpublisher_p.h
+++ b/src/webchannel/qmetaobjectpublisher_p.h
@@ -295,13 +295,15 @@ private:
QHash<const QObject *, QString> registeredObjectIds;
// Groups individually wrapped objects with their class information and the transports that have access to it.
+ // Also tags objects that are in the process of being wrapped to prevent infinite recursion.
struct ObjectInfo
{
ObjectInfo(QObject *o = nullptr)
- : object(o)
+ : object(o), isBeingWrapped(false)
{}
QObject *object;
QList<QWebChannelAbstractTransport *> transports;
+ bool isBeingWrapped;
};
// Map of objects wrapped from invocation returns