diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-04-27 05:36:11 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-04-27 05:36:11 (GMT) |
commit | 9f941fd65083ae6d3f2f5441bf60346821932218 (patch) | |
tree | 4ccd25dd9de4835a551534de37a931e2105fa4d3 /src/declarative/util/qmlscript.cpp | |
parent | f75b524b060682a896ac7a3951ac677d29e15727 (diff) | |
download | Qt-9f941fd65083ae6d3f2f5441bf60346821932218.zip Qt-9f941fd65083ae6d3f2f5441bf60346821932218.tar.gz Qt-9f941fd65083ae6d3f2f5441bf60346821932218.tar.bz2 |
Add a declarative data ptr to QObjectPrivate
This data ptr does not increase the size of the QObject, as we take advantage of space only used during destruction. Currently this data is only used to store an object's QmlContext, but it will be used for more later.
Diffstat (limited to 'src/declarative/util/qmlscript.cpp')
-rw-r--r-- | src/declarative/util/qmlscript.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/declarative/util/qmlscript.cpp b/src/declarative/util/qmlscript.cpp index 859e21e..73c8c07 100644 --- a/src/declarative/util/qmlscript.cpp +++ b/src/declarative/util/qmlscript.cpp @@ -65,7 +65,7 @@ class QmlScriptPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QmlScript); public: - QmlScriptPrivate() : reply(0), ctxt(0) {} + QmlScriptPrivate() : reply(0) {} void addScriptToEngine(const QString &, const QString &fileName=QString()); @@ -73,7 +73,6 @@ public: QString source; QNetworkReply *reply; QUrl url; - QmlContext *ctxt; }; /*! @@ -106,8 +105,6 @@ public: QML_DEFINE_TYPE(QmlScript,Script); QmlScript::QmlScript(QObject *parent) : QObject(*(new QmlScriptPrivate), parent) { - Q_D(QmlScript); - d->ctxt = QmlContext::activeContext(); } /*! @@ -154,10 +151,10 @@ void QmlScript::setSource(const QString &source) if (d->source == source) return; d->source = source; - d->url = d->ctxt->resolvedUrl(source); + d->url = qmlContext(this)->resolvedUrl(source); QNetworkRequest req(d->url); req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache); - d->reply = d->ctxt->engine()->networkAccessManager()->get(req); + d->reply = qmlEngine(this)->networkAccessManager()->get(req); QObject::connect(d->reply, SIGNAL(finished()), this, SLOT(replyFinished())); } @@ -176,7 +173,8 @@ void QmlScript::replyFinished() void QmlScriptPrivate::addScriptToEngine(const QString &script, const QString &fileName) { Q_Q(QmlScript); - QmlEngine *engine = ctxt->engine(); + QmlEngine *engine = qmlEngine(q); + QmlContext *context = qmlContext(q); QScriptEngine *scriptEngine = engine->scriptEngine(); QScriptContext *currentContext = engine->scriptEngine()->currentContext(); @@ -186,11 +184,11 @@ void QmlScriptPrivate::addScriptToEngine(const QString &script, const QString &f for (int i = 0; i < oldScopeChain.size(); ++i) { currentContext->popScope(); } - for (int i = ctxt->d_func()->scopeChain.size() - 1; i > -1; --i) { - currentContext->pushScope(ctxt->d_func()->scopeChain.at(i)); + for (int i = context->d_func()->scopeChain.size() - 1; i > -1; --i) { + currentContext->pushScope(context->d_func()->scopeChain.at(i)); } - currentContext->setActivationObject(ctxt->d_func()->scopeChain.at(0)); + currentContext->setActivationObject(context->d_func()->scopeChain.at(0)); QScriptValue val = scriptEngine->evaluate(script, fileName); if (scriptEngine->hasUncaughtException()) { @@ -209,7 +207,7 @@ void QmlScriptPrivate::addScriptToEngine(const QString &script, const QString &f currentContext->setActivationObject(oldact); - for (int i = 0; i < ctxt->d_func()->scopeChain.size(); ++i) + for (int i = 0; i < context->d_func()->scopeChain.size(); ++i) currentContext->popScope(); for (int i = oldScopeChain.size() - 1; i > -1; --i) |