Fix broken QJSEngine snippet in documentation.
authorMitch Curtis <mitch.curtis@digia.com>
Mon, 8 Sep 2014 09:11:50 +0000 (11:11 +0200)
committerMitch Curtis <mitch.curtis@digia.com>
Thu, 11 Sep 2014 07:26:28 +0000 (09:26 +0200)
toBoolean() isn't even a function in that class, and declaring the
button on the stack causes crashes upon closing the application.

Change-Id: I063cac2bb144cfb9786f20bbc122d5af92a4c2c0
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
src/qml/doc/snippets/code/src_script_qjsengine.cpp

index b836fab..7428ced 100644 (file)
@@ -79,12 +79,12 @@ if (result.isError())
 
 
 //! [5]
-QPushButton button;
-QJSValue scriptButton = myEngine.newQObject(&button);
+QPushButton *button = new QPushButton;
+QJSValue scriptButton = myEngine.newQObject(button);
 myEngine.globalObject().setProperty("button", scriptButton);
 
 myEngine.evaluate("button.checkable = true");
 
-qDebug() << scriptButton.property("checkable").toBoolean();
+qDebug() << scriptButton.property("checkable").toBool();
 scriptButton.property("show").call(); // call the show() slot
 //! [5]