Details
-
Bug
-
Resolution: Duplicate
-
P2: Important
-
None
-
5.6.2, 5.8.0, 5.9.1
Description
Calling functions Qt.createComponent or Qt.createQmlObject leads to a crash (assert triggers in debug) when the call is made from an anonymous function created inside an object that was destroyed.
The reason is that inside builtin method method_createComponent or method_createQmlObject there is assumption that calling QML context is exists, which is not always true. Actually in the described use case the context is absent, and corresponding pointer is null:
// from qqmlbuiltinfunctions.cpp: QQmlContextData *context = scope.engine->callingQmlContext(); Q_ASSERT(context); // <<== this line triggers assert
See attached test case: click on the green rectangle, and the application will crash in 1 second.
Inside Qt Declarative submodule there are places where the context pointer is checked for null, for example see qv4runtime.cpp, qv4include.cpp
Also beside the described case there are places where the context is used without such checks, it should be investigated if those classes could be compromised too, see qqmlxmlhttprequest.cpp, qquickloader.cpp
Attachments
Issue Links
- is duplicated by
-
QTBUG-61781 Crash when accessing a QML singleton from anonymous function
- Closed