Details
-
Suggestion
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
Description
When calling the constructor of a C++ class from within JS, it would be nice if the constructor could throw JS exceptions. Because the invoking engine instance is not known at creation time of the object, ugly workarounds like storing the engine in a global variable are needed.
Suggestion 1:
- a factory function parameter in QJSEngine::newQMetaObject() which takes QJSEngine as parameter and which would create the C++ object instead. Just like C++ singletons are created by QQmlEngine.
- The factory function should take QJSValueList as parameter in order to call an appropriate constructor
Suggestion 2:
- make QJSEngine* a required first parameter for invokable constructors