equal
deleted
inserted
replaced
114 \endcode |
114 \endcode |
115 |
115 |
116 All properties added explicitly by QDeclarativeContext::setContextProperty() take |
116 All properties added explicitly by QDeclarativeContext::setContextProperty() take |
117 precedence over the context object's properties. |
117 precedence over the context object's properties. |
118 |
118 |
119 Contexts form a hierarchy. The root of this heirarchy is the QDeclarativeEngine's |
119 Contexts form a hierarchy. The root of this hierarchy is the QDeclarativeEngine's |
120 \l {QDeclarativeEngine::rootContext()}{root context}. A component instance can |
120 \l {QDeclarativeEngine::rootContext()}{root context}. A component instance can |
121 access the data in its own context, as well as all its ancestor contexts. Data |
121 access the data in its own context, as well as all its ancestor contexts. Data |
122 can be made available to all instances by modifying the |
122 can be made available to all instances by modifying the |
123 \l {QDeclarativeEngine::rootContext()}{root context}. |
123 \l {QDeclarativeEngine::rootContext()}{root context}. |
124 |
124 |
143 |
143 |
144 \note Setting the context object or adding new context properties after an object |
144 \note Setting the context object or adding new context properties after an object |
145 has been created in that context is an expensive operation (essentially forcing all bindings |
145 has been created in that context is an expensive operation (essentially forcing all bindings |
146 to reevaluate). Thus whenever possible you should complete "setup" of the context |
146 to reevaluate). Thus whenever possible you should complete "setup" of the context |
147 before using it to create any objects. |
147 before using it to create any objects. |
|
148 |
|
149 \sa {Using QML in C++ Applications} |
148 */ |
150 */ |
149 |
151 |
150 /*! \internal */ |
152 /*! \internal */ |
151 QDeclarativeContext::QDeclarativeContext(QDeclarativeEngine *e, bool) |
153 QDeclarativeContext::QDeclarativeContext(QDeclarativeEngine *e, bool) |
152 : QObject(*(new QDeclarativeContextPrivate)) |
154 : QObject(*(new QDeclarativeContextPrivate)) |
658 QHash<QString, QScriptValue>::Iterator iter = enginePriv->m_sharedScriptImports.find(url); |
660 QHash<QString, QScriptValue>::Iterator iter = enginePriv->m_sharedScriptImports.find(url); |
659 if (iter == enginePriv->m_sharedScriptImports.end()) { |
661 if (iter == enginePriv->m_sharedScriptImports.end()) { |
660 QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine); |
662 QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine); |
661 |
663 |
662 scriptContext->pushScope(enginePriv->contextClass->newUrlContext(url)); |
664 scriptContext->pushScope(enginePriv->contextClass->newUrlContext(url)); |
663 scriptContext->pushScope(enginePriv->globalClass->globalObject()); |
665 scriptContext->pushScope(enginePriv->globalClass->staticGlobalObject()); |
664 |
666 |
665 QScriptValue scope = scriptEngine->newObject(); |
667 QScriptValue scope = QScriptDeclarativeClass::newStaticScopeObject(scriptEngine); |
666 scriptContext->setActivationObject(scope); |
|
667 scriptContext->pushScope(scope); |
668 scriptContext->pushScope(scope); |
668 |
669 |
669 scriptEngine->evaluate(code, url, 1); |
670 scriptEngine->evaluate(code, url, 1); |
670 |
671 |
671 if (scriptEngine->hasUncaughtException()) { |
672 if (scriptEngine->hasUncaughtException()) { |
684 } else { |
685 } else { |
685 |
686 |
686 QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine); |
687 QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine); |
687 |
688 |
688 scriptContext->pushScope(enginePriv->contextClass->newUrlContext(this, 0, url)); |
689 scriptContext->pushScope(enginePriv->contextClass->newUrlContext(this, 0, url)); |
689 scriptContext->pushScope(enginePriv->globalClass->globalObject()); |
690 scriptContext->pushScope(enginePriv->globalClass->staticGlobalObject()); |
690 |
691 |
691 QScriptValue scope = scriptEngine->newObject(); |
692 QScriptValue scope = QScriptDeclarativeClass::newStaticScopeObject(scriptEngine); |
692 scriptContext->setActivationObject(scope); |
|
693 scriptContext->pushScope(scope); |
693 scriptContext->pushScope(scope); |
694 |
694 |
695 scriptEngine->evaluate(code, url, 1); |
695 scriptEngine->evaluate(code, url, 1); |
696 |
696 |
697 if (scriptEngine->hasUncaughtException()) { |
697 if (scriptEngine->hasUncaughtException()) { |