Details
-
Bug
-
Resolution: Done
-
P2: Important
-
None
-
5.0.1
-
None
-
Ubuntu 12.04
Description
After registering a singleton QJSValue for use in QML scripts, the application crashes when accessing its values.
See attached file for a minimal program reproducing the crash (relevant material in main.cpp and main.qml, the rest is the stock qtquick2 application viewer).
Relevant portions of both files:
Unable to find source-code formatter for language: main.cpp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
static QJSValue qjsvalue_provider(QQmlEngine *engine, QJSEngine *scriptEngine) { Q_UNUSED(engine) QJSValue example = scriptEngine->newObject(); example.setProperty("Normal", 0); example.setProperty("Special", 1); example.setProperty("Custom", 2); return example; } int main(int argc, char *argv[]) { /*...*/ qmlRegisterSingletonType("Content", 1, 0, "ProgramsId", qjsvalue_provider); /*...*/ }
Unable to find source-code formatter for language: main.qml. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
import QtQuick 2.0 import Content 1.0 Rectangle { width: 360 height: 360 property int test: ProgramsId.Normal }
Setting a QML breakpoint just before the binding that accesses the QJSValue, trying to print "ProgramsId.Normal" results in "SyntaxError: Unexpected token ILLEGAL".