Details
-
Bug
-
Resolution: Done
-
P2: Important
-
4.7.1
-
None
-
3b3ec6bc4114db82462eef812a47db420d4505c2
Description
Consider a Q_INVOKABLE method in an item defined in a plugin that returns a QObject pointer:
Q_INVOKABLE QObject *fetchObject(int arg);
If the function returns a non-null object then everything is happy and the QObject can be used in the normal JavaScript/QML way. However, if the function returns null (e.g. because the argument refers to a non-existent entity), then a crash will occur every time deep inside JSC. The attached example shows the problem.
This particular pattern is needed in several places in Qt/3D:
- Fetching a named material from a mesh.
- Asking for the object that is under a specific mouse position using 3D object picking.
- etc
My expectation was that returning a null from C++ should result in the JavaScript "null" or "undefined" value, not a segfault.