diff options
Diffstat (limited to 'src/declarative/qml/qmlengine.cpp')
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index d88d11f..6eb0005 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -72,6 +72,7 @@ #include "private/qmlmetaproperty_p.h" #include <private/qmlbindablevalue_p.h> #include <private/qmlvme_p.h> +#include <private/qmlenginedebug_p.h> Q_DECLARE_METATYPE(QmlMetaProperty) Q_DECLARE_METATYPE(QList<QObject *>); @@ -132,8 +133,9 @@ QStack<QmlEngine *> *QmlEngineStack::engines() QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) -: rootContext(0), currentBindContext(0), currentExpression(0), q(e), - rootComponent(0), networkAccessManager(0), typeManager(e), uniqueId(1) +: rootContext(0), currentBindContext(0), currentExpression(0), q(e), + isDebugging(false), rootComponent(0), networkAccessManager(0), typeManager(e), + uniqueId(1) { QScriptValue qtObject = scriptEngine.newQMetaObject(StaticQtMetaObject::get()); scriptEngine.globalObject().setProperty(QLatin1String("Qt"), qtObject); @@ -179,12 +181,14 @@ void QmlEnginePrivate::clear(SimpleList<QmlParserStatus> &pss) pss.clear(); } +Q_GLOBAL_STATIC(QmlEngineDebugServer, qmlEngineDebugServer); + void QmlEnginePrivate::init() { scriptEngine.installTranslatorFunctions(); contextClass = new QmlContextScriptClass(q); objectClass = new QmlObjectScriptClass(q); - rootContext = new QmlContext(q); + rootContext = new QmlContext(q,true); #ifdef QT_SCRIPTTOOLS_LIB if (qmlDebugger()){ debugger = new QScriptEngineDebugger(q); @@ -198,6 +202,13 @@ void QmlEnginePrivate::init() scriptEngine.newFunction(QmlEngine::createQmlObject, 1)); scriptEngine.globalObject().setProperty(QLatin1String("createComponent"), scriptEngine.newFunction(QmlEngine::createComponent, 1)); + + if (QCoreApplication::instance()->thread() == q->thread() && + QmlEngineDebugServer::isDebuggingEnabled()) { + qmlEngineDebugServer(); + isDebugging = true; + QmlEngineDebugServer::addEngine(q); + } } QmlContext *QmlEnginePrivate::setCurrentBindContext(QmlContext *c) @@ -423,6 +434,9 @@ QmlEngine::QmlEngine(QObject *parent) */ QmlEngine::~QmlEngine() { + Q_D(QmlEngine); + if (d->isDebugging) + QmlEngineDebugServer::remEngine(this); } /*! |