summaryrefslogtreecommitdiffstats
path: root/src/declarative/util
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-04-27 05:36:11 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-04-27 05:36:11 (GMT)
commit9f941fd65083ae6d3f2f5441bf60346821932218 (patch)
tree4ccd25dd9de4835a551534de37a931e2105fa4d3 /src/declarative/util
parentf75b524b060682a896ac7a3951ac677d29e15727 (diff)
downloadQt-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')
-rw-r--r--src/declarative/util/qmlanimation.cpp2
-rw-r--r--src/declarative/util/qmlanimation_p.h3
-rw-r--r--src/declarative/util/qmlbehaviour.cpp9
-rw-r--r--src/declarative/util/qmlconnection.cpp9
-rw-r--r--src/declarative/util/qmllistmodel.cpp11
-rw-r--r--src/declarative/util/qmlscript.cpp20
-rw-r--r--src/declarative/util/qmlstateoperations.cpp7
7 files changed, 21 insertions, 40 deletions
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
index ede4008..3be714a 100644
--- a/src/declarative/util/qmlanimation.cpp
+++ b/src/declarative/util/qmlanimation.cpp
@@ -1004,7 +1004,7 @@ void QmlRunScriptActionPrivate::execute()
}
if(!scriptStr.isEmpty()) {
- QmlExpression expr(ctxt, scriptStr, q);
+ QmlExpression expr(qmlContext(q), scriptStr, q);
expr.setTrackChange(false);
expr.value();
}
diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h
index db7cb18..e07fa78 100644
--- a/src/declarative/util/qmlanimation_p.h
+++ b/src/declarative/util/qmlanimation_p.h
@@ -225,13 +225,12 @@ class QmlRunScriptActionPrivate : public QmlAbstractAnimationPrivate
Q_DECLARE_PUBLIC(QmlRunScriptAction);
public:
QmlRunScriptActionPrivate()
- : QmlAbstractAnimationPrivate(), ctxt(QmlContext::activeContext()), proxy(this), rsa(0) {}
+ : QmlAbstractAnimationPrivate(), proxy(this), rsa(0) {}
void init();
QString script;
QString file;
- QmlContext* ctxt;
void execute();
diff --git a/src/declarative/util/qmlbehaviour.cpp b/src/declarative/util/qmlbehaviour.cpp
index 3169f63..3fff06c 100644
--- a/src/declarative/util/qmlbehaviour.cpp
+++ b/src/declarative/util/qmlbehaviour.cpp
@@ -76,14 +76,13 @@ class QmlBehaviourPrivate : public QObjectPrivate
{
public:
QmlBehaviourPrivate()
- : context(0), oldContext(0), valueData(0), operations(this) {}
+ : context(0), valueData(0), operations(this) {}
QmlMetaProperty property;
QVariant currentValue;
QVariant fromValue;
QVariant toValue;
QmlContext *context;
- QmlContext *oldContext;
QmlBehaviourData *valueData;
class AnimationList : public QmlConcreteList<QmlAbstractAnimation *>
{
@@ -123,8 +122,6 @@ QmlBehaviour::QmlBehaviour(QObject *parent)
{
Q_D(QmlBehaviour);
d->valueData = new QmlBehaviourData(this);
- d->context = new QmlContext(QmlContext::activeContext(), this);
- d->context->addDefaultObject(d->valueData);
d->group = new QSequentialAnimationGroup(this);
}
@@ -234,6 +231,10 @@ void QmlBehaviour::setTarget(const QmlMetaProperty &property)
void QmlBehaviour::classBegin()
{
Q_D(QmlBehaviour);
+ if(!d->context) {
+ d->context = new QmlContext(qmlContext(this), this);
+ d->context->addDefaultObject(d->valueData);
+ }
d->context->activate();
}
diff --git a/src/declarative/util/qmlconnection.cpp b/src/declarative/util/qmlconnection.cpp
index df45a31..b2fd450 100644
--- a/src/declarative/util/qmlconnection.cpp
+++ b/src/declarative/util/qmlconnection.cpp
@@ -51,9 +51,8 @@ QT_BEGIN_NAMESPACE
class QmlConnectionPrivate : public QObjectPrivate
{
public:
- QmlConnectionPrivate() : ctxt(0), boundsignal(0), signalSender(0), componentcomplete(false) {}
+ QmlConnectionPrivate() : boundsignal(0), signalSender(0), componentcomplete(false) {}
- QmlContext *ctxt;
QmlBoundSignal *boundsignal;
QObject *signalSender;
QString script;
@@ -112,8 +111,6 @@ public:
QmlConnection::QmlConnection(QObject *parent) :
QObject(*(new QmlConnectionPrivate), parent)
{
- Q_D(QmlConnection);
- d->ctxt = QmlContext::activeContext();
}
QmlConnection::~QmlConnection()
@@ -192,9 +189,9 @@ void QmlConnection::connectIfValid()
}
if (sigparams.isEmpty())
- d->boundsignal = new QmlBoundSignal(d->ctxt, d->script, sender, sigIdx, this);
+ d->boundsignal = new QmlBoundSignal(qmlContext(this), d->script, sender, sigIdx, this);
else
- d->boundsignal = new QmlBoundSignalProxy(new QmlContext(d->ctxt,this), d->script, sender, sigIdx, this);
+ d->boundsignal = new QmlBoundSignalProxy(new QmlContext(qmlContext(this),this), d->script, sender, sigIdx, this);
}
}
diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp
index 992185a..24f2d5c 100644
--- a/src/declarative/util/qmllistmodel.cpp
+++ b/src/declarative/util/qmllistmodel.cpp
@@ -537,7 +537,6 @@ ModelNode::~ModelNode()
struct ListModelData
{
int dataOffset;
- int id;
int instrCount;
ListInstruction *instructions() const { return (ListInstruction *)((char *)this + sizeof(ListModelData)); }
};
@@ -546,7 +545,6 @@ QByteArray ListModelParser::compile(QXmlStreamReader& reader, bool *ok)
{
*ok = true;
- QByteArray id;
QByteArray data;
QList<ListInstruction> instr;
int depth=0;
@@ -649,10 +647,6 @@ QByteArray ListModelParser::compile(QXmlStreamReader& reader, bool *ok)
rv.resize(size);
ListModelData *lmd = (ListModelData *)rv.data();
- if(id.count())
- lmd->id = 0;
- else
- lmd->id = -1;
lmd->dataOffset = sizeof(ListModelData) +
instr.count() * sizeof(ListInstruction);
lmd->instrCount = instr.count();
@@ -709,11 +703,6 @@ QVariant ListModelParser::create(const QByteArray &d)
}
}
- if(lmd->id != -1) {
- QmlContext *ctxt = QmlContext::activeContext();
- ctxt->setContextProperty(QLatin1String(data + lmd->id), rv);
- }
-
return QVariant::fromValue(rv);
}
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)
diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp
index a8779f9..594e6fa 100644
--- a/src/declarative/util/qmlstateoperations.cpp
+++ b/src/declarative/util/qmlstateoperations.cpp
@@ -137,9 +137,8 @@ QmlStateOperation::ActionList QmlParentChange::actions()
class QmlRunScriptPrivate : public QObjectPrivate
{
public:
- QmlRunScriptPrivate() : ctxt(0) {}
+ QmlRunScriptPrivate() {}
- QmlContext *ctxt;
QString script;
QString name;
};
@@ -152,8 +151,6 @@ QML_DEFINE_TYPE(QmlRunScript,RunScript);
QmlRunScript::QmlRunScript(QObject *parent)
: QmlStateOperation(*(new QmlRunScriptPrivate), parent)
{
- Q_D(QmlRunScript);
- d->ctxt = QmlContext::activeContext();
}
QmlRunScript::~QmlRunScript()
@@ -192,7 +189,7 @@ void QmlRunScript::execute()
{
Q_D(QmlRunScript);
if(!d->script.isEmpty()) {
- QmlExpression expr(d->ctxt, d->script, this);
+ QmlExpression expr(qmlContext(this), d->script, this);
expr.setTrackChange(false);
expr.value();
}