From b5298660aeff41e5cd46abc680c9d23aca25996b Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Thu, 22 Nov 2012 16:54:15 +0100 Subject: [PATCH] docs: Separate qml and c++ examples MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I1d9e2e281bff2bb77a8bdf53726d3c452e3fe911 Reviewed-by: Jędrzej Nowacki --- src/qml/doc/src/javascript/expressions.qdoc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/qml/doc/src/javascript/expressions.qdoc b/src/qml/doc/src/javascript/expressions.qdoc index 94315b2..c830425 100644 --- a/src/qml/doc/src/javascript/expressions.qdoc +++ b/src/qml/doc/src/javascript/expressions.qdoc @@ -369,10 +369,12 @@ unless the client explicitly preserves it. \section2 Example One: Automatic Release In the following example, the scarce resource will be automatically released -after the binding evaluation is complete. +after the binding evaluation is complete. Assume we have the following qml file: \snippet qml/integrating-javascript/scarceresources/exampleOne.qml 0 +And then use it from C++: + \snippet qml/integrating-javascript/scarceresources/avatarExample.cpp 1 \section2 Example Two: Automatic Release Prevented By Reference @@ -384,6 +386,8 @@ scarce resource. \snippet qml/integrating-javascript/scarceresources/exampleTwo.qml 0 +And from C++: + \snippet qml/integrating-javascript/scarceresources/avatarExample.cpp 2 \section2 Example Three: Explicit Preservation @@ -392,10 +396,13 @@ In this example, the resource must be explicitly preserved in order to prevent the declarative engine from automatically releasing the resource after evaluation of the imported script. +We create a JavaScript file: \snippet qml/integrating-javascript/scarceresources/exampleThree.js 0 +Import it in QML: \snippet qml/integrating-javascript/scarceresources/exampleThree.qml 0 +Run it in C++: \snippet qml/integrating-javascript/scarceresources/avatarExample.cpp 3 \section2 Example Four: Explicit Destruction @@ -405,10 +412,13 @@ scarce resource variant. This example shows how a client may free system resources by releasing the scarce resource held in a JavaScript object, if required, during evaluation of a JavaScript expression. +We create a JavaScript file: \snippet qml/integrating-javascript/scarceresources/exampleFour.js 0 +Import it in QML: \snippet qml/integrating-javascript/scarceresources/exampleFour.qml 0 +Run it in C++: \snippet qml/integrating-javascript/scarceresources/avatarExample.cpp 4 \section2 Example Five: Explicit Destruction and JavaScript References @@ -419,8 +429,10 @@ to one scarce resource is held, and the client calls destroy() on one of those references (to explicitly release the scarce resource), all of the references will be affected. + \snippet qml/integrating-javascript/scarceresources/exampleFive.qml 0 +Run it in C++: \snippet qml/integrating-javascript/scarceresources/avatarExample.cpp 5 */ -- 2.7.4