diff options
5 files changed, 36 insertions, 3 deletions
diff --git a/examples/declarative/fonts/fonts.qml b/examples/declarative/fonts/fonts.qml index 97dd645..ae31b03 100644 --- a/examples/declarative/fonts/fonts.qml +++ b/examples/declarative/fonts/fonts.qml @@ -7,7 +7,7 @@ Rectangle { color: "steelblue" FontLoader { id: fixedFont; name: "Courier" } - FontLoader { id: localFont; source: "fonts/tarzenau-ocr-a.ttf" } + FontLoader { id: localFont; source: "fonts/tarzeau_ocr_a.ttf" } FontLoader { id: webFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" } Column { @@ -19,7 +19,7 @@ Rectangle { color: "lightsteelblue" width: parent.width elide: Text.ElideRight - font.family: "Times"; font.pointSize: 42 + font.family: "Times"; font.pointSize: 42 } Text { text: myText diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index b65212b..3a35dd5 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -677,7 +677,7 @@ void QDeclarativeTextPrivate::updateSize() QTextOption option((Qt::Alignment)int(hAlign | vAlign)); option.setWrapMode(QTextOption::WrapMode(wrapMode)); doc->setDefaultTextOption(option); - if (wrapMode != QDeclarativeText::NoWrap && !q->heightValid() && q->widthValid()) + if (wrapMode != QDeclarativeText::NoWrap && q->widthValid()) doc->setTextWidth(q->width()); else doc->setTextWidth(doc->idealWidth()); // ### Text does not align if width is not set (QTextDoc bug) diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 33ddb46..fac38d7 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -44,6 +44,7 @@ #include "private/qdeclarativebehavior_p.h" #include "private/qdeclarativestateoperations_p.h" +#include "private/qdeclarativecontext_p.h" #include <qdeclarativepropertyvaluesource.h> #include <qdeclarative.h> @@ -767,6 +768,7 @@ void QDeclarativeScriptAction::setStateChangeScriptName(const QString &name) void QDeclarativeScriptActionPrivate::execute() { + Q_Q(QDeclarativeScriptAction); if (hasRunScriptScript && reversing) return; @@ -775,7 +777,12 @@ void QDeclarativeScriptActionPrivate::execute() const QString &str = scriptStr.script(); if (!str.isEmpty()) { QDeclarativeExpression expr(scriptStr.context(), str, scriptStr.scopeObject()); + QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(q); + if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) + expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); expr.value(); + if (expr.hasError()) + qWarning() << expr.error(); } } diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index 410a269..0521d27 100644 --- a/src/declarative/util/qdeclarativestateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -49,6 +49,7 @@ #include <qdeclarativeitem_p.h> #include <qdeclarativeguard_p.h> #include <qdeclarativenullablevalue_p_p.h> +#include "private/qdeclarativecontext_p.h" #include <QtCore/qdebug.h> #include <QtGui/qgraphicsitem.h> @@ -571,7 +572,12 @@ void QDeclarativeStateChangeScript::execute() const QString &script = d->script.script(); if (!script.isEmpty()) { QDeclarativeExpression expr(d->script.context(), script, d->script.scopeObject()); + QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(this); + if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) + expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); expr.value(); + if (expr.hasError()) + qWarning() << expr.error(); } } diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp index 2d10756..6637415 100644 --- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp +++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp @@ -286,8 +286,28 @@ void tst_qdeclarativetext::wrap() QVERIFY(textObject != 0); QCOMPARE(textObject->width(), 30.); QVERIFY(textObject->height() > textHeight); + + qreal oldHeight = textObject->height(); + textObject->setWidth(100); + QVERIFY(textObject->height() < oldHeight); } + // richtext again with a fixed height + for (int i = 0; i < richText.size(); i++) + { + QString componentStr = "import Qt 4.7\nText { wrapMode: Text.WordWrap; width: 30; height: 50; text: \"" + richText.at(i) + "\" }"; + QDeclarativeComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->width(), 30.); + QVERIFY(textObject->implicitHeight() > textHeight); + + qreal oldHeight = textObject->implicitHeight(); + textObject->setWidth(100); + QVERIFY(textObject->implicitHeight() < oldHeight); + } } void tst_qdeclarativetext::elide() |