diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-04-29 23:13:10 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-04-29 23:40:33 (GMT) |
commit | 5fc59b64642b8af7b449770bae471a2a72bfa490 (patch) | |
tree | fcb409172e81947f972ebc7174bf43edcf7bc950 /src | |
parent | e5f5f009bb1ee7ba039c712013700ac0363fa323 (diff) | |
download | Qt-5fc59b64642b8af7b449770bae471a2a72bfa490.zip Qt-5fc59b64642b8af7b449770bae471a2a72bfa490.tar.gz Qt-5fc59b64642b8af7b449770bae471a2a72bfa490.tar.bz2 |
Fix translation context when qsTr is used in PropertyChanges.
This should also lead to better error meesages coming from PropertyChanges.
Task-number: QTBUG-10300
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/util/qdeclarativepropertychanges.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/declarative/util/qdeclarativepropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp index 4b2d5a0..c7e3bc5 100644 --- a/src/declarative/util/qdeclarativepropertychanges.cpp +++ b/src/declarative/util/qdeclarativepropertychanges.cpp @@ -51,6 +51,7 @@ #include <qdeclarativecontext.h> #include <qdeclarativeguard_p.h> #include <qdeclarativeproperty_p.h> +#include <qdeclarativecontext_p.h> #include <QtCore/qdebug.h> @@ -302,12 +303,18 @@ void QDeclarativePropertyChangesPrivate::decode() QDeclarativeProperty prop = property(name); //### better way to check for signal property? if (prop.type() & QDeclarativeProperty::SignalProperty) { QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(q), data.toString(), object); + QDeclarativeData *ddata = QDeclarativeData::get(q); + if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) + expression->setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); QDeclarativeReplaceSignalHandler *handler = new QDeclarativeReplaceSignalHandler; handler->property = prop; handler->expression = expression; signalReplacements << handler; } else if (isScript) { QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(q), data.toString(), object); + QDeclarativeData *ddata = QDeclarativeData::get(q); + if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) + expression->setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); expressions << qMakePair(name, expression); } else { properties << qMakePair(name, data); @@ -437,9 +444,11 @@ QDeclarativePropertyChanges::ActionList QDeclarativePropertyChanges::actions() if (d->isExplicit) { a.toValue = d->expressions.at(ii).second->evaluate(); } else { + QDeclarativeExpression *e = d->expressions.at(ii).second; QDeclarativeBinding *newBinding = - new QDeclarativeBinding(d->expressions.at(ii).second->expression(), object(), qmlContext(this)); + new QDeclarativeBinding(e->expression(), object(), qmlContext(this)); newBinding->setTarget(prop); + newBinding->setSourceLocation(e->sourceFile(), e->lineNumber()); a.toBinding = newBinding; a.deletableToBinding = true; } |