From 4d74cbb945d53991ae844922b532987b513e14e6 Mon Sep 17 00:00:00 2001 From: Tim Jenssen Date: Thu, 15 Nov 2018 19:21:12 +0100 Subject: Fix reference on temperary value Old code at Context::lookupReference took via Context::ptr() a temporary QSharedPointer as an argument into a reference member which is deleted just after ReferenceContext is constructed - changing that to a general member copies this temporary QSharedPointer and fixes the problem which was there since always and that this was not crashing before was just luck. class ReferenceContext { public: ReferenceContext(const ContextPtr &context); private: const ContextPtr &m_context; }; QWeakPointer _ptr; ContextPtr Context::ptr() const { return _ptr.toStrongRef(); } const Value *Context::lookupReference(const Value *value) const { ReferenceContext refContext(ptr()); return refContext.lookupReference(value); } Task-number: QTCREATORBUG-21510 Change-Id: Ic49a0597763fb8be65feca6f24fec105d531d6ab Reviewed-by: Alessandro Portale --- src/libs/qmljs/qmljscontext.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/qmljs/qmljscontext.h b/src/libs/qmljs/qmljscontext.h index fd7f0569eb..cafee3e970 100644 --- a/src/libs/qmljs/qmljscontext.h +++ b/src/libs/qmljs/qmljscontext.h @@ -91,7 +91,7 @@ public: operator const ContextPtr &() const; private: - const ContextPtr &m_context; + const ContextPtr m_context; QList m_references; }; -- cgit v1.2.3