Details
-
Bug
-
Resolution: Invalid
-
P3: Somewhat important
-
None
-
5.14.2
-
None
Description
I am using QJSEngine, here is my access method from my helper class:
QJSEngine* clsScriptHelper::pobjGetScriptEng() { if ( clsScriptHelper::mspobjJSeng == nullptr ) { clsScriptHelper::mspobjJSeng = new QJSEngine(); if ( clsScriptHelper::mspobjJSeng != nullptr ) { clsScriptHelper::mspobjJSeng->installExtensions(QJSEngine::AllExtensions); //Added the tests below to illustrate it doesn't work, both error with 2 QJSValue err; err = clsScriptHelper::mspobjJSeng->evaluate("(print(1 + 2);)"); if ( err.isError() ) { qDebug() << err.EvalError; } err = clsScriptHelper::mspobjJSeng->evaluate("(console.log(1 + 2);"); if ( err.isError() ) { qDebug() << err.EvalError; } //End of example tests proving it doesn't work! } } Q_ASSERT_X(clsScriptHelper::mspobjJSeng!=nullptr, "clsScriptHelper::pobjGetScriptEnd", "mspobjJSeng is NULL!"); return clsScriptHelper::mspobjJSeng; }
I've checked using the debugger and the call to InstallExtensions is getting called. However when I call evaluate on a script to be processed I get error number 2 returned.
According to the documentation this:
Indicates that console functions (console.log(), for example) should be installed.
Why am I getting this, doesn't QJSEngine::AllExtensions include
QJSEngine::ConsoleExtension ?
Even if I add QJSEngine::ConsoleExtension to the InstallExtensions call I still get the same error.
From: https://doc.qt.io/qt-5.9/qjsengine.html
QJSEngine::ConsoleExtension 0x2 Indicates that console functions (console.log(), for example) should be installed.