From 7aedb72dea904981969c0a4a9e5a6b721381c5a9 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 19 Apr 2010 14:08:20 +1000 Subject: Emit runtime warnings through QDeclarativeEngine QTBUG-9726 --- .../graphicsitems/qdeclarativeanimatedimage.cpp | 5 +- src/declarative/graphicsitems/qdeclarativeitem.cpp | 4 +- .../graphicsitems/qdeclarativeloader.cpp | 4 +- .../graphicsitems/qdeclarativescalegrid.cpp | 2 +- .../graphicsitems/qdeclarativetextedit.cpp | 4 +- .../graphicsitems/qdeclarativetextinput.cpp | 11 +- .../graphicsitems/qdeclarativevisualitemmodel.cpp | 2 +- src/declarative/qml/qdeclarativebinding.cpp | 3 +- src/declarative/qml/qdeclarativeboundsignal.cpp | 2 +- .../qml/qdeclarativecompiledbindings.cpp | 2 +- src/declarative/qml/qdeclarativecompiler.cpp | 9 +- src/declarative/qml/qdeclarativecomponent.cpp | 12 +-- src/declarative/qml/qdeclarativecomponent.h | 3 +- .../qml/qdeclarativecompositetypemanager.cpp | 1 - src/declarative/qml/qdeclarativecontext.cpp | 6 +- src/declarative/qml/qdeclarativedirparser.cpp | 9 +- src/declarative/qml/qdeclarativeengine.cpp | 103 ++++++++++++++++-- src/declarative/qml/qdeclarativeengine.h | 7 +- src/declarative/qml/qdeclarativeengine_p.h | 8 ++ src/declarative/qml/qdeclarativeenginedebug.cpp | 2 - src/declarative/qml/qdeclarativeerror.cpp | 12 ++- src/declarative/qml/qdeclarativeexpression.cpp | 5 +- src/declarative/qml/qdeclarativeinfo.cpp | 119 ++++++++++++++------- src/declarative/qml/qdeclarativeinfo.h | 17 +++ src/declarative/qml/qdeclarativemetatype.cpp | 8 +- .../qml/qdeclarativeproxymetaobject.cpp | 14 --- src/declarative/qml/qdeclarativexmlhttprequest.cpp | 2 +- src/declarative/util/qdeclarativeanimation.cpp | 8 +- src/declarative/util/qdeclarativefontloader.cpp | 7 +- src/declarative/util/qdeclarativelistmodel.cpp | 5 +- .../util/qdeclarativelistmodelworkeragent.cpp | 5 +- src/declarative/util/qdeclarativestategroup.cpp | 3 +- .../util/qdeclarativestateoperations.cpp | 2 +- .../tst_qdeclarativeanchors.cpp | 30 +++--- .../tst_qdeclarativeanimatedimage.cpp | 2 +- .../tst_qdeclarativeanimations.cpp | 14 +-- .../tst_qdeclarativebehaviors.cpp | 6 +- .../tst_qdeclarativeborderimage.cpp | 8 +- .../tst_qdeclarativeecmascript.cpp | 2 +- .../tst_qdeclarativeflipable.cpp | 4 +- .../tst_qdeclarativefontloader.cpp | 4 +- .../qdeclarativeimage/tst_qdeclarativeimage.cpp | 6 +- .../tst_qdeclarativeimageprovider.cpp | 6 +- .../qdeclarativeinfo/tst_qdeclarativeinfo.cpp | 16 +-- .../qdeclarativeitem/tst_qdeclarativeitem.cpp | 7 +- .../tst_qdeclarativelanguage.cpp | 3 +- .../tst_qdeclarativelistmodel.cpp | 56 +++++----- .../qdeclarativeloader/tst_qdeclarativeloader.cpp | 6 +- .../tst_qdeclarativeproperty.cpp | 8 +- .../qdeclarativestates/tst_qdeclarativestates.cpp | 12 +-- .../qdeclarativetext/tst_qdeclarativetext.cpp | 4 +- .../tst_qdeclarativetextedit.cpp | 2 +- 52 files changed, 374 insertions(+), 228 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp index 6ab126d..c81c2d2 100644 --- a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp @@ -44,6 +44,7 @@ #ifndef QT_NO_MOVIE +#include #include #include @@ -213,7 +214,7 @@ void QDeclarativeAnimatedImage::setSource(const QUrl &url) //### should be unified with movieRequestFinished d->_movie = new QMovie(lf); if (!d->_movie->isValid()){ - qWarning() << "Error Reading Animated Image File" << d->url; + qmlInfo(this) << "Error Reading Animated Image File " << d->url.toString(); delete d->_movie; d->_movie = 0; return; @@ -270,7 +271,7 @@ void QDeclarativeAnimatedImage::movieRequestFinished() d->_movie = new QMovie(d->reply); if (!d->_movie->isValid()){ - qWarning() << "Error Reading Animated Image File " << d->url; + qmlInfo(this) << "Error Reading Animated Image File " << d->url; delete d->_movie; d->_movie = 0; return; diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 843dfdc..37c7923 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -2242,7 +2242,7 @@ QScriptValue QDeclarativeItem::mapFromItem(const QScriptValue &item, qreal x, qr QScriptValue sv = QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(this))->newObject(); QDeclarativeItem *itemObj = qobject_cast(item.toQObject()); if (!itemObj && !item.isNull()) { - qWarning().nospace() << "mapFromItem() given argument " << item.toString() << " which is neither null nor an Item"; + qmlInfo(this) << "mapFromItem() given argument \"" << item.toString() << "\" which is neither null nor an Item"; return 0; } @@ -2268,7 +2268,7 @@ QScriptValue QDeclarativeItem::mapToItem(const QScriptValue &item, qreal x, qrea QScriptValue sv = QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(this))->newObject(); QDeclarativeItem *itemObj = qobject_cast(item.toQObject()); if (!itemObj && !item.isNull()) { - qWarning().nospace() << "mapToItem() given argument " << item.toString() << " which is neither null nor an Item"; + qmlInfo(this) << "mapToItem() given argument \"" << item.toString() << "\" which is neither null nor an Item"; return 0; } diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp index 8cf8235..3f257b5 100644 --- a/src/declarative/graphicsitems/qdeclarativeloader.cpp +++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp @@ -277,7 +277,7 @@ void QDeclarativeLoaderPrivate::_q_sourceLoaded() if (component) { if (!component->errors().isEmpty()) { - qWarning() << component->errors(); + QDeclarativeEnginePrivate::warning(qmlEngine(q), component->errors()); emit q->sourceChanged(); emit q->statusChanged(); emit q->progressChanged(); @@ -312,7 +312,7 @@ void QDeclarativeLoaderPrivate::_q_sourceLoaded() } } else { if (!component->errors().isEmpty()) - qWarning() << component->errors(); + QDeclarativeEnginePrivate::warning(qmlEngine(q), component->errors()); delete obj; delete ctxt; source = QUrl(); diff --git a/src/declarative/graphicsitems/qdeclarativescalegrid.cpp b/src/declarative/graphicsitems/qdeclarativescalegrid.cpp index e68f645..fe89190 100644 --- a/src/declarative/graphicsitems/qdeclarativescalegrid.cpp +++ b/src/declarative/graphicsitems/qdeclarativescalegrid.cpp @@ -175,7 +175,7 @@ QDeclarativeBorderImage::TileMode QDeclarativeGridScaledImage::stringToRule(cons if (s == QLatin1String("Round")) return QDeclarativeBorderImage::Round; - qWarning() << "Unknown tile rule specified. Using Stretch"; + qWarning("QDeclarativeGridScaledImage: Invalid tile rule specified. Using Stretch."); return QDeclarativeBorderImage::Stretch; } diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 1fec484..77fb459 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -614,7 +614,7 @@ void QDeclarativeTextEdit::loadCursorDelegate() d->cursor->setHeight(QFontMetrics(d->font).height()); moveCursorDelegate(); }else{ - qWarning() << QLatin1String("Error loading cursor delegate for TextEdit:") + objectName(); + qmlInfo(this) << "Error loading cursor delegate."; } } @@ -1076,8 +1076,6 @@ void QDeclarativeTextEditPrivate::updateSelection() q->selectionEndChanged(); startChange = (lastSelectionStart != control->textCursor().selectionStart()); endChange = (lastSelectionEnd != control->textCursor().selectionEnd()); - if(startChange || endChange) - qWarning() << "QDeclarativeTextEditPrivate::updateSelection() has failed you."; } void QDeclarativeTextEdit::updateSelectionMarkers() diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index e00d333..2161e23 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -779,9 +779,8 @@ void QDeclarativeTextInputPrivate::startCreatingCursor() }else if(cursorComponent->isLoading()){ q->connect(cursorComponent, SIGNAL(statusChanged(int)), q, SLOT(createCursor())); - }else{//isError - qmlInfo(q) << QDeclarativeTextInput::tr("Could not load cursor delegate"); - qWarning() << cursorComponent->errors(); + }else {//isError + qmlInfo(q, cursorComponent->errors()) << QDeclarativeTextInput::tr("Could not load cursor delegate"); } } @@ -789,8 +788,7 @@ void QDeclarativeTextInput::createCursor() { Q_D(QDeclarativeTextInput); if(d->cursorComponent->isError()){ - qmlInfo(this) << tr("Could not load cursor delegate"); - qWarning() << d->cursorComponent->errors(); + qmlInfo(this, d->cursorComponent->errors()) << tr("Could not load cursor delegate"); return; } @@ -801,8 +799,7 @@ void QDeclarativeTextInput::createCursor() delete d->cursorItem; d->cursorItem = qobject_cast(d->cursorComponent->create()); if(!d->cursorItem){ - qmlInfo(this) << tr("Could not instantiate cursor delegate"); - //The failed instantiation should print its own error messages + qmlInfo(this, d->cursorComponent->errors()) << tr("Could not instantiate cursor delegate"); return; } diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index 751284d..207232d 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -1011,7 +1011,7 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray } else { delete data; delete ctxt; - qWarning() << d->m_delegate->errors(); + qmlInfo(this, d->m_delegate->errors()) << "Error creating delgate"; } } QDeclarativeItem *item = qobject_cast(nobj); diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp index 25492ac..d759427 100644 --- a/src/declarative/qml/qdeclarativebinding.cpp +++ b/src/declarative/qml/qdeclarativebinding.cpp @@ -210,8 +210,7 @@ void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags) } if (data->error.isValid()) { - if (!data->addError(ep)) - qWarning().nospace() << qPrintable(this->error().toString()); + if (!data->addError(ep)) ep->warning(this->error()); } else { data->removeError(); } diff --git a/src/declarative/qml/qdeclarativeboundsignal.cpp b/src/declarative/qml/qdeclarativeboundsignal.cpp index 8c7a977..00a93cc 100644 --- a/src/declarative/qml/qdeclarativeboundsignal.cpp +++ b/src/declarative/qml/qdeclarativeboundsignal.cpp @@ -179,7 +179,7 @@ int QDeclarativeBoundSignal::qt_metacall(QMetaObject::Call c, int id, void **a) if (m_expression && m_expression->engine()) { QDeclarativeExpressionPrivate::get(m_expression)->value(m_params); if (m_expression && m_expression->hasError()) - qWarning().nospace() << qPrintable(m_expression->error().toString()); + QDeclarativeEnginePrivate::warning(m_expression->engine(), m_expression->error()); } if (m_params) m_params->clearValues(); return -1; diff --git a/src/declarative/qml/qdeclarativecompiledbindings.cpp b/src/declarative/qml/qdeclarativecompiledbindings.cpp index 6fdf706..4a47fc6 100644 --- a/src/declarative/qml/qdeclarativecompiledbindings.cpp +++ b/src/declarative/qml/qdeclarativecompiledbindings.cpp @@ -938,7 +938,7 @@ static void throwException(int id, QDeclarativeDelayedError *error, error->error.setColumn(-1); } if (!context->engine || !error->addError(QDeclarativeEnginePrivate::get(context->engine))) - qWarning() << error->error; + QDeclarativeEnginePrivate::warning(context->engine, error->error); } static void dumpInstruction(const Instr *instr) diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index 065009a..cced7b1 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -1218,7 +1218,14 @@ bool QDeclarativeCompiler::buildComponent(QDeclarativeParser::Object *obj, bool QDeclarativeCompiler::buildScript(QDeclarativeParser::Object *obj, QDeclarativeParser::Object *script) { - qWarning().nospace() << qPrintable(output->url.toString()) << ":" << obj->location.start.line << ":" << obj->location.start.column << ": Script blocks have been deprecated. Support will be removed entirely shortly."; + { + QDeclarativeError warning; + warning.setUrl(output->url); + warning.setLine(obj->location.start.line); + warning.setColumn(obj->location.start.column); + warning.setDescription(tr("Script blocks have been deprecated. Support will be removed entirely shortly.")); + qWarning() << warning.toString(); + } Object::ScriptBlock scriptBlock; diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index 3e4651c..c86f089 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -530,10 +530,8 @@ QScriptValue QDeclarativeComponent::createObject() { Q_D(QDeclarativeComponent); QDeclarativeContext* ctxt = creationContext(); - if(!ctxt){ - qWarning() << QLatin1String("createObject can only be used in QML"); + if(!ctxt) return QScriptValue(); - } QObject* ret = create(ctxt); if (!ret) return QScriptValue(); @@ -613,17 +611,17 @@ QDeclarativeComponentPrivate::beginCreate(QDeclarativeContextData *context, cons { Q_Q(QDeclarativeComponent); if (!context) { - qWarning("QDeclarativeComponent::beginCreate(): Cannot create a component in a null context"); + qWarning("QDeclarativeComponent: Cannot create a component in a null context"); return 0; } if (!context->isValid()) { - qWarning("QDeclarativeComponent::beginCreate(): Cannot create a component in an invalid context"); + qWarning("QDeclarativeComponent: Cannot create a component in an invalid context"); return 0; } if (context->engine != engine) { - qWarning("QDeclarativeComponent::beginCreate(): Must create component in context from the same QDeclarativeEngine"); + qWarning("QDeclarativeComponent: Must create component in context from the same QDeclarativeEngine"); return 0; } @@ -766,7 +764,7 @@ void QDeclarativeComponentPrivate::complete(QDeclarativeEnginePrivate *enginePri enginePriv->inProgressCreations--; if (0 == enginePriv->inProgressCreations) { while (enginePriv->erroredBindings) { - qWarning().nospace() << qPrintable(enginePriv->erroredBindings->error.toString()); + enginePriv->warning(enginePriv->erroredBindings->error); enginePriv->erroredBindings->removeError(); } } diff --git a/src/declarative/qml/qdeclarativecomponent.h b/src/declarative/qml/qdeclarativecomponent.h index 6ee5070..526a319 100644 --- a/src/declarative/qml/qdeclarativecomponent.h +++ b/src/declarative/qml/qdeclarativecomponent.h @@ -99,8 +99,6 @@ public: virtual QObject *beginCreate(QDeclarativeContext *); virtual void completeCreate(); - Q_INVOKABLE QScriptValue createObject(); - void loadUrl(const QUrl &url); void setData(const QByteArray &, const QUrl &baseUrl); @@ -114,6 +112,7 @@ Q_SIGNALS: protected: QDeclarativeComponent(QDeclarativeComponentPrivate &dd, QObject* parent); + Q_INVOKABLE QScriptValue createObject(); private: QDeclarativeComponent(QDeclarativeEngine *, QDeclarativeCompiledData *, int, int, QObject *parent); diff --git a/src/declarative/qml/qdeclarativecompositetypemanager.cpp b/src/declarative/qml/qdeclarativecompositetypemanager.cpp index 133b71f..adeb7a5 100644 --- a/src/declarative/qml/qdeclarativecompositetypemanager.cpp +++ b/src/declarative/qml/qdeclarativecompositetypemanager.cpp @@ -341,7 +341,6 @@ static QString toLocalFileOrQrc(const QUrl& url) if (url.scheme() == QLatin1String("qrc")) { if (url.authority().isEmpty()) return QLatin1Char(':') + url.path(); - qWarning() << "Invalid url:" << url.toString() << "authority" << url.authority() << "not known."; return QString(); } return url.toLocalFile(); diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp index 5288923..31430c7 100644 --- a/src/declarative/qml/qdeclarativecontext.cpp +++ b/src/declarative/qml/qdeclarativecontext.cpp @@ -660,7 +660,7 @@ void QDeclarativeContextData::addImportedScript(const QDeclarativeParser::Object if (scriptEngine->hasUncaughtException()) { QDeclarativeError error; QDeclarativeExpressionPrivate::exceptionToError(scriptEngine, error); - qWarning().nospace() << qPrintable(error.toString()); + enginePriv->warning(error); } scriptEngine->popContext(); @@ -686,7 +686,7 @@ void QDeclarativeContextData::addImportedScript(const QDeclarativeParser::Object if (scriptEngine->hasUncaughtException()) { QDeclarativeError error; QDeclarativeExpressionPrivate::exceptionToError(scriptEngine, error); - qWarning().nospace() << qPrintable(error.toString()); + enginePriv->warning(error); } scriptEngine->popContext(); @@ -720,7 +720,7 @@ void QDeclarativeContextData::addScript(const QDeclarativeParser::Object::Script if (scriptEngine->hasUncaughtException()) { QDeclarativeError error; QDeclarativeExpressionPrivate::exceptionToError(scriptEngine, error); - qWarning().nospace() << qPrintable(error.toString()); + enginePriv->warning(error); } } diff --git a/src/declarative/qml/qdeclarativedirparser.cpp b/src/declarative/qml/qdeclarativedirparser.cpp index 1e3b37b..3e05853 100644 --- a/src/declarative/qml/qdeclarativedirparser.cpp +++ b/src/declarative/qml/qdeclarativedirparser.cpp @@ -170,10 +170,9 @@ bool QDeclarativeDirParser::parse() const int dotIndex = version.indexOf(QLatin1Char('.')); if (dotIndex == -1) { - qWarning() << "expected '.'"; // ### use reportError + reportError(lineNumber, -1, QLatin1String("expected '.'")); } else if (version.indexOf(QLatin1Char('.'), dotIndex + 1) != -1) { - qWarning() << "unexpected '.'"; // ### use reportError - + reportError(lineNumber, -1, QLatin1String("unexpected '.'")); } else { bool validVersionNumber = false; const int majorVersion = version.left(dotIndex).toInt(&validVersionNumber); @@ -189,8 +188,8 @@ bool QDeclarativeDirParser::parse() } } } else { - // ### use reportError - qWarning() << "a component declaration requires 3 arguments, but" << (sectionCount + 1) << "were provided"; + reportError(lineNumber, -1, + QString::fromUtf8("a component declaration requires 3 arguments, but %1 were provided").arg(sectionCount + 1)); } } diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 4dbd199..9cd6b3c 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -153,10 +153,10 @@ void QDeclarativeEnginePrivate::defineModule() QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e) : captureProperties(false), rootContext(0), currentExpression(0), isDebugging(false), - contextClass(0), sharedContext(0), sharedScope(0), objectClass(0), valueTypeClass(0), - globalClass(0), cleanup(0), erroredBindings(0), inProgressCreations(0), - scriptEngine(this), workerScriptEngine(0), componentAttached(0), inBeginCreate(false), - networkAccessManager(0), networkAccessManagerFactory(0), + outputWarningsToStdErr(true), contextClass(0), sharedContext(0), sharedScope(0), + objectClass(0), valueTypeClass(0), globalClass(0), cleanup(0), erroredBindings(0), + inProgressCreations(0), scriptEngine(this), workerScriptEngine(0), componentAttached(0), + inBeginCreate(false), networkAccessManager(0), networkAccessManagerFactory(0), typeManager(e), uniqueId(1) { if (!qt_QmlQtModule_registered) { @@ -216,8 +216,6 @@ QDeclarativeScriptEngine::QDeclarativeScriptEngine(QDeclarativeEnginePrivate *pr offlineStoragePath = QDesktopServices::storageLocation(QDesktopServices::DataLocation).replace(QLatin1Char('/'), QDir::separator()) + QDir::separator() + QLatin1String("QML") + QDir::separator() + QLatin1String("OfflineStorage"); -#else - qWarning("offlineStoragePath is not set by default with QT_NO_DESKTOPSERVICES"); #endif qt_add_qmlxmlhttprequest(this); @@ -650,6 +648,34 @@ void QDeclarativeEngine::setBaseUrl(const QUrl &url) { Q_D(QDeclarativeEngine); d->baseUrl = url; +} + +/*! + Returns true if warning messages will be output to stderr in addition + to being emitted by the warnings() signal, otherwise false. + + The default value is true. +*/ +bool QDeclarativeEngine::outputWarningsToStandardError() const +{ + Q_D(const QDeclarativeEngine); + return d->outputWarningsToStdErr; +} + +/*! + Set whether warning messages will be output to stderr to \a enabled. + + If \a enabled is true, any warning messages generated by QML will be + output to stderr and emitted by the warnings() signal. If \a enabled + is false, on the warnings() signal will be emitted. This allows + applications to handle warning output themselves. + + The default value is true. +*/ +void QDeclarativeEngine::setOutputWarningsToStandardError(bool enabled) +{ + Q_D(QDeclarativeEngine); + d->outputWarningsToStdErr = enabled; } /*! @@ -777,9 +803,8 @@ void qmlExecuteDeferred(QObject *object) QDeclarativeComponentPrivate::complete(ep, &state); - if (!state.errors.isEmpty()) - qWarning() << state.errors; - + if (!state.errors.isEmpty()) + ep->warning(state.errors); } } @@ -1295,6 +1320,65 @@ void QDeclarativeEnginePrivate::sendQuit() emit q->quit(); } +static void dumpwarning(const QDeclarativeError &error) +{ + qWarning().nospace() << qPrintable(error.toString()); +} + +static void dumpwarning(const QList &errors) +{ + for (int ii = 0; ii < errors.count(); ++ii) + dumpwarning(errors.at(ii)); +} + +void QDeclarativeEnginePrivate::warning(const QDeclarativeError &error) +{ + Q_Q(QDeclarativeEngine); + q->warnings(QList() << error); + if (outputWarningsToStdErr) + dumpwarning(error); +} + +void QDeclarativeEnginePrivate::warning(const QList &errors) +{ + Q_Q(QDeclarativeEngine); + q->warnings(errors); + if (outputWarningsToStdErr) + dumpwarning(errors); +} + +void QDeclarativeEnginePrivate::warning(QDeclarativeEngine *engine, const QDeclarativeError &error) +{ + if (engine) + QDeclarativeEnginePrivate::get(engine)->warning(error); + else + dumpwarning(error); +} + +void QDeclarativeEnginePrivate::warning(QDeclarativeEngine *engine, const QList &error) +{ + if (engine) + QDeclarativeEnginePrivate::get(engine)->warning(error); + else + dumpwarning(error); +} + +void QDeclarativeEnginePrivate::warning(QDeclarativeEnginePrivate *engine, const QDeclarativeError &error) +{ + if (engine) + engine->warning(error); + else + dumpwarning(error); +} + +void QDeclarativeEnginePrivate::warning(QDeclarativeEnginePrivate *engine, const QList &error) +{ + if (engine) + engine->warning(error); + else + dumpwarning(error); +} + QScriptValue QDeclarativeEnginePrivate::quit(QScriptContext * /*ctxt*/, QScriptEngine *e) { QDeclarativeEnginePrivate *qe = get (e); @@ -1415,7 +1499,6 @@ static QString toLocalFileOrQrc(const QUrl& url) if (url.scheme() == QLatin1String("qrc")) { if (url.authority().isEmpty()) return QLatin1Char(':') + url.path(); - qWarning() << "Invalid url:" << url.toString() << "authority" << url.authority() << "not known."; return QString(); } return url.toLocalFile(); diff --git a/src/declarative/qml/qdeclarativeengine.h b/src/declarative/qml/qdeclarativeengine.h index 7b058ea..e161cd9 100644 --- a/src/declarative/qml/qdeclarativeengine.h +++ b/src/declarative/qml/qdeclarativeengine.h @@ -46,6 +46,7 @@ #include #include #include +#include QT_BEGIN_HEADER @@ -102,6 +103,9 @@ public: QUrl baseUrl() const; void setBaseUrl(const QUrl &); + bool outputWarningsToStandardError() const; + void setOutputWarningsToStandardError(bool); + static QDeclarativeContext *contextForObject(const QObject *); static void setContextForObject(QObject *, QDeclarativeContext *); @@ -110,7 +114,8 @@ public: static ObjectOwnership objectOwnership(QObject *); Q_SIGNALS: - void quit (); + void quit(); + void warnings(const QList &warnings); private: Q_DECLARE_PRIVATE(QDeclarativeEngine) diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h index 43d329c..f6b9bcb 100644 --- a/src/declarative/qml/qdeclarativeengine_p.h +++ b/src/declarative/qml/qdeclarativeengine_p.h @@ -162,6 +162,8 @@ public: QDeclarativeExpression *currentExpression; bool isDebugging; + bool outputWarningsToStdErr; + struct ImportedNamespace; QDeclarativeContextScriptClass *contextClass; QDeclarativeContextData *sharedContext; @@ -312,6 +314,12 @@ public: QVariant scriptValueToVariant(const QScriptValue &, int hint = QVariant::Invalid); void sendQuit(); + void warning(const QDeclarativeError &); + void warning(const QList &); + static void warning(QDeclarativeEngine *, const QDeclarativeError &); + static void warning(QDeclarativeEngine *, const QList &); + static void warning(QDeclarativeEnginePrivate *, const QDeclarativeError &); + static void warning(QDeclarativeEnginePrivate *, const QList &); static QScriptValue qmlScriptObject(QObject*, QDeclarativeEngine*); diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp index 578733c..264fd8d 100644 --- a/src/declarative/qml/qdeclarativeenginedebug.cpp +++ b/src/declarative/qml/qdeclarativeenginedebug.cpp @@ -308,8 +308,6 @@ void QDeclarativeEngineDebugServer::messageReceived(const QByteArray &message) QByteArray type; ds >> type; - //qDebug() << "QDeclarativeEngineDebugServer::messageReceived()" << type; - if (type == "LIST_ENGINES") { int queryId; ds >> queryId; diff --git a/src/declarative/qml/qdeclarativeerror.cpp b/src/declarative/qml/qdeclarativeerror.cpp index 17e91e3..8717f56 100644 --- a/src/declarative/qml/qdeclarativeerror.cpp +++ b/src/declarative/qml/qdeclarativeerror.cpp @@ -216,9 +216,15 @@ void QDeclarativeError::setColumn(int column) QString QDeclarativeError::toString() const { QString rv; - rv = url().toString() + QLatin1Char(':') + QString::number(line()); - if(column() != -1) - rv += QLatin1Char(':') + QString::number(column()); + if (url().isEmpty()) { + rv = QLatin1String(""); + } else if (line() != -1) { + rv = url().toString() + QLatin1Char(':') + QString::number(line()); + if(column() != -1) + rv += QLatin1Char(':') + QString::number(column()); + } else { + rv = url().toString(); + } rv += QLatin1String(": ") + description(); diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp index 05240a2..8b5a62f 100644 --- a/src/declarative/qml/qdeclarativeexpression.cpp +++ b/src/declarative/qml/qdeclarativeexpression.cpp @@ -695,14 +695,13 @@ void QDeclarativeExpressionPrivate::updateGuards(const QPODVectorexpression() - << "depends on non-NOTIFYable properties:"; + << "depends on non-NOTIFYable properties:"; } const QMetaObject *metaObj = property.object->metaObject(); QMetaProperty metaProp = metaObj->property(property.coreIndex); - qWarning().nospace() << " " << metaObj->className() - << "::" << metaProp.name(); + qWarning().nospace() << " " << metaObj->className() << "::" << metaProp.name(); } } } diff --git a/src/declarative/qml/qdeclarativeinfo.cpp b/src/declarative/qml/qdeclarativeinfo.cpp index 0a4352f..f6560a6 100644 --- a/src/declarative/qml/qdeclarativeinfo.cpp +++ b/src/declarative/qml/qdeclarativeinfo.cpp @@ -45,6 +45,7 @@ #include "qdeclarativecontext.h" #include "private/qdeclarativecontext_p.h" #include "private/qdeclarativemetatype_p.h" +#include "private/qdeclarativeengine_p.h" #include @@ -77,52 +78,94 @@ QT_BEGIN_NAMESPACE \endcode */ +struct QDeclarativeInfoPrivate +{ + const QObject *object; + QString *buffer; + QList errors; +}; + QDeclarativeInfo::QDeclarativeInfo(const QObject *object) -: QDebug(QtWarningMsg) +: QDebug((*(QString **)&d) = new QString) { - QString pos = QLatin1String("QML"); - if (object) { - pos += QLatin1Char(' '); - - QString typeName; - QDeclarativeType *type = QDeclarativeMetaType::qmlType(object->metaObject()); - if (type) { - typeName = QLatin1String(type->qmlTypeName()); - int lastSlash = typeName.lastIndexOf(QLatin1Char('/')); - if (lastSlash != -1) - typeName = typeName.mid(lastSlash+1); - } else { - typeName = QString::fromUtf8(object->metaObject()->className()); - int marker = typeName.indexOf(QLatin1String("_QMLTYPE_")); - if (marker != -1) - typeName = typeName.left(marker); - } + QDeclarativeInfoPrivate *p = new QDeclarativeInfoPrivate; + p->buffer = (QString *)d; + d = p; - pos += typeName; - } - QDeclarativeData *ddata = object?QDeclarativeData::get(object):0; - pos += QLatin1String(" ("); - if (ddata) { - if (ddata->outerContext && !ddata->outerContext->url.isEmpty()) { - pos += ddata->outerContext->url.toString(); - pos += QLatin1Char(':'); - pos += QString::number(ddata->lineNumber); - pos += QLatin1Char(':'); - pos += QString::number(ddata->columnNumber); - } else { - pos += QCoreApplication::translate("QDeclarativeInfo","unknown location"); - } - } else { - pos += QCoreApplication::translate("QDeclarativeInfo","unknown location"); - } - pos += QLatin1Char(')'); - *this << pos; + d->object = object; nospace(); } -QDeclarativeInfo::~QDeclarativeInfo() +QDeclarativeInfo::QDeclarativeInfo(const QObject *object, const QList &errors) +: QDebug((*(QString **)&d) = new QString) { + QDeclarativeInfoPrivate *p = new QDeclarativeInfoPrivate; + p->buffer = (QString *)d; + d = p; + + d->object = object; + d->errors = errors; + nospace(); } +QDeclarativeInfo::QDeclarativeInfo(const QObject *object, const QDeclarativeError &error) +: QDebug((*(QString **)&d) = new QString) +{ + QDeclarativeInfoPrivate *p = new QDeclarativeInfoPrivate; + p->buffer = (QString *)d; + d = p; + + d->object = object; + d->errors << error; + nospace(); +} + +QDeclarativeInfo::~QDeclarativeInfo() +{ + QList errors = d->errors; + + QDeclarativeEngine *engine = 0; + + if (!d->buffer->isEmpty()) { + QDeclarativeError error; + + QObject *object = const_cast(d->object); + + if (object) { + engine = qmlEngine(d->object); + QString typeName; + QDeclarativeType *type = QDeclarativeMetaType::qmlType(object->metaObject()); + if (type) { + typeName = QLatin1String(type->qmlTypeName()); + int lastSlash = typeName.lastIndexOf(QLatin1Char('/')); + if (lastSlash != -1) + typeName = typeName.mid(lastSlash+1); + } else { + typeName = QString::fromUtf8(object->metaObject()->className()); + int marker = typeName.indexOf(QLatin1String("_QMLTYPE_")); + if (marker != -1) + typeName = typeName.left(marker); + } + + d->buffer->prepend(QLatin1String("QML ") + typeName + QLatin1String(": ")); + + QDeclarativeData *ddata = QDeclarativeData::get(object, false); + if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) { + error.setUrl(ddata->outerContext->url); + error.setLine(ddata->lineNumber); + error.setColumn(ddata->columnNumber); + } + } + + error.setDescription(*d->buffer); + + errors.prepend(error); + } + + QDeclarativeEnginePrivate::warning(engine, errors); + + delete d->buffer; + delete d; +} QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeinfo.h b/src/declarative/qml/qdeclarativeinfo.h index 8f69f73..36de7b1 100644 --- a/src/declarative/qml/qdeclarativeinfo.h +++ b/src/declarative/qml/qdeclarativeinfo.h @@ -43,6 +43,7 @@ #define QDECLARATIVEINFO_H #include +#include QT_BEGIN_HEADER @@ -50,10 +51,13 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) +class QDeclarativeInfoPrivate; class Q_DECLARATIVE_EXPORT QDeclarativeInfo : public QDebug { public: QDeclarativeInfo(const QObject *); + QDeclarativeInfo(const QObject *, const QDeclarativeError &); + QDeclarativeInfo(const QObject *, const QList &); ~QDeclarativeInfo(); inline QDeclarativeInfo &operator<<(QChar t) { QDebug::operator<<(t); return *this; } @@ -78,6 +82,9 @@ public: inline QDeclarativeInfo &operator<<(const void * t) { QDebug::operator<<(t); return *this; } inline QDeclarativeInfo &operator<<(QTextStreamFunction f) { QDebug::operator<<(f); return *this; } inline QDeclarativeInfo &operator<<(QTextStreamManipulator m) { QDebug::operator<<(m); return *this; } + +private: + QDeclarativeInfoPrivate *d; }; Q_DECLARATIVE_EXPORT inline QDeclarativeInfo qmlInfo(const QObject *me) @@ -85,6 +92,16 @@ Q_DECLARATIVE_EXPORT inline QDeclarativeInfo qmlInfo(const QObject *me) return QDeclarativeInfo(me); } +Q_DECLARATIVE_EXPORT inline QDeclarativeInfo qmlInfo(const QObject *me, const QDeclarativeError &error) +{ + return QDeclarativeInfo(me, error); +} + +Q_DECLARATIVE_EXPORT inline QDeclarativeInfo qmlInfo(const QObject *me, const QList &errors) +{ + return QDeclarativeInfo(me, errors); +} + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp index 7b71608..d41bd43 100644 --- a/src/declarative/qml/qdeclarativemetatype.cpp +++ b/src/declarative/qml/qdeclarativemetatype.cpp @@ -403,10 +403,8 @@ int QDeclarativeType::index() const int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterInterface &interface) { - if (interface.version > 0) { - qWarning("Cannot mix incompatible QML versions."); - return -1; - } + if (interface.version > 0) + qFatal("qmlRegisterType(): Cannot mix incompatible QML versions."); QWriteLocker lock(metaTypeDataLock()); QDeclarativeMetaTypeData *data = metaTypeData(); @@ -437,7 +435,7 @@ int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterType &t if (type.elementName) { for (int ii = 0; type.elementName[ii]; ++ii) { if (!isalnum(type.elementName[ii])) { - qWarning("QDeclarativeMetaType: Invalid QML element name %s", type.elementName); + qWarning("qmlRegisterType(): Invalid QML element name \"%s\"", type.elementName); return -1; } } diff --git a/src/declarative/qml/qdeclarativeproxymetaobject.cpp b/src/declarative/qml/qdeclarativeproxymetaobject.cpp index fe0dce7..c2dce0a 100644 --- a/src/declarative/qml/qdeclarativeproxymetaobject.cpp +++ b/src/declarative/qml/qdeclarativeproxymetaobject.cpp @@ -41,17 +41,11 @@ #include "private/qdeclarativeproxymetaobject_p.h" -#include - QT_BEGIN_NAMESPACE QDeclarativeProxyMetaObject::QDeclarativeProxyMetaObject(QObject *obj, QList *mList) : metaObjects(mList), proxies(0), parent(0), object(obj) { -#ifdef QDECLARATIVEPROXYMETAOBJECT_DEBUG - qWarning() << "QDeclarativeProxyMetaObject" << obj->metaObject()->className(); -#endif - *static_cast(this) = *metaObjects->first().metaObject; QObjectPrivate *op = QObjectPrivate::get(obj); @@ -59,14 +53,6 @@ QDeclarativeProxyMetaObject::QDeclarativeProxyMetaObject(QObject *obj, QList(op->metaObject); op->metaObject = this; - -#ifdef QDECLARATIVEPROXYMETAOBJECT_DEBUG - const QMetaObject *mo = obj->metaObject(); - while(mo) { - qWarning() << " " << mo->className(); - mo = mo->superClass(); - } -#endif } QDeclarativeProxyMetaObject::~QDeclarativeProxyMetaObject() diff --git a/src/declarative/qml/qdeclarativexmlhttprequest.cpp b/src/declarative/qml/qdeclarativexmlhttprequest.cpp index be2a1a7..b7e1832 100644 --- a/src/declarative/qml/qdeclarativexmlhttprequest.cpp +++ b/src/declarative/qml/qdeclarativexmlhttprequest.cpp @@ -1305,7 +1305,7 @@ void QDeclarativeXMLHttpRequest::printError(const QScriptValue& sv) { QDeclarativeError error; QDeclarativeExpressionPrivate::exceptionToError(sv.engine(), error); - qWarning().nospace() << qPrintable(error.toString()); + QDeclarativeEnginePrivate::warning(QDeclarativeEnginePrivate::get(sv.engine()), error); } void QDeclarativeXMLHttpRequest::destroyNetwork() diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index fd85d91..5f81b26 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -185,7 +185,7 @@ void QDeclarativeAbstractAnimation::setRunning(bool r) return; if (d->group || d->disableUserControl) { - qWarning("QDeclarativeAbstractAnimation: setRunning() cannot be used on non-root animation nodes"); + qmlInfo(this) << "setRunning() cannot be used on non-root animation nodes."; return; } @@ -245,7 +245,7 @@ void QDeclarativeAbstractAnimation::setPaused(bool p) return; if (d->group || d->disableUserControl) { - qWarning("QDeclarativeAbstractAnimation: setPaused() cannot be used on non-root animation nodes"); + qmlInfo(this) << "setPaused() cannot be used on non-root animation nodes."; return; } @@ -781,8 +781,8 @@ void QDeclarativeScriptActionPrivate::execute() if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); expr.value(); - if (expr.hasError()) - qWarning() << expr.error(); + if (expr.hasError()) + qmlInfo(q) << expr.error(); } } diff --git a/src/declarative/util/qdeclarativefontloader.cpp b/src/declarative/util/qdeclarativefontloader.cpp index 41740a8..4115193 100644 --- a/src/declarative/util/qdeclarativefontloader.cpp +++ b/src/declarative/util/qdeclarativefontloader.cpp @@ -53,6 +53,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -136,7 +137,7 @@ void QDeclarativeFontLoader::setSource(const QUrl &url) d->status = QDeclarativeFontLoader::Ready; } else { d->status = QDeclarativeFontLoader::Error; - qWarning() << "Cannot load font:" << url; + qmlInfo(this) << "Cannot load font: \"" << url.toString() << "\""; } emit statusChanged(); } else @@ -231,7 +232,7 @@ void QDeclarativeFontLoader::replyFinished() d->addFontToDatabase(ba); } else { d->status = Error; - qWarning() << "Cannot load font:" << d->reply->url(); + qmlInfo(this) << "Cannot load font: \"" << d->reply->url().toString() << "\""; emit statusChanged(); } d->reply->deleteLater(); @@ -250,7 +251,7 @@ void QDeclarativeFontLoaderPrivate::addFontToDatabase(const QByteArray &ba) status = QDeclarativeFontLoader::Ready; } else { status = QDeclarativeFontLoader::Error; - qWarning() << "Cannot load font:" << url; + qmlInfo(q) << "Cannot load font: \"" << url.toString() << "\""; } emit q->statusChanged(); } diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 2616ccf..6e980d0 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -1187,10 +1187,9 @@ QScriptValue NestedListModel::get(int index) const if (!node) return 0; QDeclarativeEngine *eng = qmlEngine(m_listModel); - if (!eng) { - qWarning("Cannot call QDeclarativeListModel::get() without a QDeclarativeEngine"); + if (!eng) return 0; - } + return QDeclarativeEnginePrivate::qmlScriptObject(node->object(this), eng); } diff --git a/src/declarative/util/qdeclarativelistmodelworkeragent.cpp b/src/declarative/util/qdeclarativelistmodelworkeragent.cpp index d91b107..534c923 100644 --- a/src/declarative/util/qdeclarativelistmodelworkeragent.cpp +++ b/src/declarative/util/qdeclarativelistmodelworkeragent.cpp @@ -202,10 +202,9 @@ bool QDeclarativeListModelWorkerAgent::event(QEvent *e) FlatListModel *orig = m_orig->m_flat; FlatListModel *copy = s->list->m_flat; - if (!orig || !copy) { - qWarning("QML ListModel worker: sync() failed"); + if (!orig || !copy) return QObject::event(e); - } + orig->m_roles = copy->m_roles; orig->m_strings = copy->m_strings; orig->m_values = copy->m_values; diff --git a/src/declarative/util/qdeclarativestategroup.cpp b/src/declarative/util/qdeclarativestategroup.cpp index ff78c60..81f4230 100644 --- a/src/declarative/util/qdeclarativestategroup.cpp +++ b/src/declarative/util/qdeclarativestategroup.cpp @@ -50,6 +50,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -381,7 +382,7 @@ void QDeclarativeStateGroupPrivate::setCurrentStateInternal(const QString &state } if (applyingState) { - qWarning() << "Can't apply a state change as part of a state definition."; + qmlInfo(q) << "Can't apply a state change as part of a state definition."; return; } diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index 3854b10..eb6ac7b 100644 --- a/src/declarative/util/qdeclarativestateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -577,7 +577,7 @@ void QDeclarativeStateChangeScript::execute() expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); expr.value(); if (expr.hasError()) - qWarning() << expr.error(); + qmlInfo(this, expr.error()); } } diff --git a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp index 01b5bc5..06a8f64 100644 --- a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp +++ b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp @@ -262,7 +262,7 @@ void tst_qdeclarativeanchors::loops() { QUrl source(QUrl::fromLocalFile(SRCDIR "/data/loop1.qml")); - QString expect = "QML Text (" + source.toString() + ":6:5" + ") Possible anchor loop detected on horizontal anchor."; + QString expect = source.toString() + ":6:5: QML Text: Possible anchor loop detected on horizontal anchor."; QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); @@ -277,7 +277,7 @@ void tst_qdeclarativeanchors::loops() { QUrl source(QUrl::fromLocalFile(SRCDIR "/data/loop2.qml")); - QString expect = "QML Image (" + source.toString() + ":8:3" + ") Possible anchor loop detected on horizontal anchor."; + QString expect = source.toString() + ":8:3: QML Image: Possible anchor loop detected on horizontal anchor."; QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); QDeclarativeView *view = new QDeclarativeView; @@ -312,55 +312,55 @@ void tst_qdeclarativeanchors::illegalSets_data() QTest::newRow("H - too many anchors") << "Rectangle { id: rect; Rectangle { anchors.left: rect.left; anchors.right: rect.right; anchors.horizontalCenter: rect.horizontalCenter } }" - << "QML Rectangle (file::2:23) Cannot specify left, right, and hcenter anchors."; + << "file::2:23: QML Rectangle: Cannot specify left, right, and hcenter anchors."; foreach (const QString &side, QStringList() << "left" << "right") { QTest::newRow("H - anchor to V") << QString("Rectangle { Rectangle { anchors.%1: parent.top } }").arg(side) - << "QML Rectangle (file::2:13) Cannot anchor a horizontal edge to a vertical edge."; + << "file::2:13: QML Rectangle: Cannot anchor a horizontal edge to a vertical edge."; QTest::newRow("H - anchor to non parent/sibling") << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side) - << "QML Rectangle (file::2:45) Cannot anchor to an item that isn't a parent or sibling."; + << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling."; QTest::newRow("H - anchor to self") << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side) - << "QML Rectangle (file::2:1) Cannot anchor item to self."; + << "file::2:1: QML Rectangle: Cannot anchor item to self."; } QTest::newRow("V - too many anchors") << "Rectangle { id: rect; Rectangle { anchors.top: rect.top; anchors.bottom: rect.bottom; anchors.verticalCenter: rect.verticalCenter } }" - << "QML Rectangle (file::2:23) Cannot specify top, bottom, and vcenter anchors."; + << "file::2:23: QML Rectangle: Cannot specify top, bottom, and vcenter anchors."; QTest::newRow("V - too many anchors with baseline") << "Rectangle { Text { id: text1; text: \"Hello\" } Text { anchors.baseline: text1.baseline; anchors.top: text1.top; } }" - << "QML Text (file::2:47) Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors."; + << "file::2:47: QML Text: Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors."; foreach (const QString &side, QStringList() << "top" << "bottom" << "baseline") { QTest::newRow("V - anchor to H") << QString("Rectangle { Rectangle { anchors.%1: parent.left } }").arg(side) - << "QML Rectangle (file::2:13) Cannot anchor a vertical edge to a horizontal edge."; + << "file::2:13: QML Rectangle: Cannot anchor a vertical edge to a horizontal edge."; QTest::newRow("V - anchor to non parent/sibling") << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side) - << "QML Rectangle (file::2:45) Cannot anchor to an item that isn't a parent or sibling."; + << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling."; QTest::newRow("V - anchor to self") << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side) - << "QML Rectangle (file::2:1) Cannot anchor item to self."; + << "file::2:1: QML Rectangle: Cannot anchor item to self."; } QTest::newRow("centerIn - anchor to non parent/sibling") << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.centerIn: rect} }" - << "QML Rectangle (file::2:45) Cannot anchor to an item that isn't a parent or sibling."; + << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling."; QTest::newRow("fill - anchor to non parent/sibling") << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.fill: rect} }" - << "QML Rectangle (file::2:45) Cannot anchor to an item that isn't a parent or sibling."; + << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling."; } void tst_qdeclarativeanchors::reset() @@ -437,7 +437,7 @@ void tst_qdeclarativeanchors::nullItem() const QMetaObject *meta = item->anchors()->metaObject(); QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData())); - QTest::ignoreMessage(QtWarningMsg, "QML Item (unknown location) Cannot anchor to a null item."); + QTest::ignoreMessage(QtWarningMsg, ": QML Item: Cannot anchor to a null item."); QVERIFY(p.write(item->anchors(), qVariantFromValue(anchor))); delete item; @@ -461,7 +461,7 @@ void tst_qdeclarativeanchors::crash1() { QUrl source(QUrl::fromLocalFile(SRCDIR "/data/crash1.qml")); - QString expect = "QML Text (" + source.toString() + ":4:5" + ") Possible anchor loop detected on fill."; + QString expect = source.toString() + ":4:5: QML Text: Possible anchor loop detected on fill."; QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp index 0fb080c..237a436 100644 --- a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp +++ b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp @@ -199,7 +199,7 @@ void tst_qdeclarativeanimatedimage::invalidSource() component.setData("import Qt 4.7\n AnimatedImage { source: \"no-such-file.gif\" }", QUrl::fromLocalFile("")); QVERIFY(component.isReady()); - QTest::ignoreMessage(QtWarningMsg, "Error Reading Animated Image File QUrl( \"file:no-such-file.gif\" ) "); + QTest::ignoreMessage(QtWarningMsg, "file::2:2: QML AnimatedImage: Error Reading Animated Image File file:no-such-file.gif"); QDeclarativeAnimatedImage *anim = qobject_cast(component.create()); QVERIFY(anim); diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp index 959cc19..e217e34 100644 --- a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp +++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp @@ -339,13 +339,13 @@ void tst_qdeclarativeanimations::badProperties() QDeclarativeEngine engine; QDeclarativeComponent c1(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml")); - QByteArray message = "QML ColorAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml").toString().toUtf8() + ":18:9) Cannot animate non-existent property \"border.colr\""; + QByteArray message = QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate non-existent property \"border.colr\""; QTest::ignoreMessage(QtWarningMsg, message); QDeclarativeRectangle *rect = qobject_cast(c1.create()); QVERIFY(rect); QDeclarativeComponent c2(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml")); - message = "QML ColorAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml").toString().toUtf8() + ":18:9) Cannot animate read-only property \"border\""; + message = QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate read-only property \"border\""; QTest::ignoreMessage(QtWarningMsg, message); rect = qobject_cast(c2.create()); QVERIFY(rect); @@ -549,12 +549,12 @@ void tst_qdeclarativeanimations::propertiesTransition() void tst_qdeclarativeanimations::invalidDuration() { QDeclarativePropertyAnimation *animation = new QDeclarativePropertyAnimation; - QTest::ignoreMessage(QtWarningMsg, "QML PropertyAnimation (unknown location) Cannot set a duration of < 0"); + QTest::ignoreMessage(QtWarningMsg, ": QML PropertyAnimation: Cannot set a duration of < 0"); animation->setDuration(-1); QCOMPARE(animation->duration(), 250); QDeclarativePauseAnimation *pauseAnimation = new QDeclarativePauseAnimation; - QTest::ignoreMessage(QtWarningMsg, "QML PauseAnimation (unknown location) Cannot set a duration of < 0"); + QTest::ignoreMessage(QtWarningMsg, ": QML PauseAnimation: Cannot set a duration of < 0"); pauseAnimation->setDuration(-1); QCOMPARE(pauseAnimation->duration(), 250); } @@ -620,7 +620,8 @@ void tst_qdeclarativeanimations::dontStart() QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart.qml")); - QTest::ignoreMessage(QtWarningMsg, "QDeclarativeAbstractAnimation: setRunning() cannot be used on non-root animation nodes"); + QString warning = c.url().toString() + ":14:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes."; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); QDeclarativeRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); @@ -634,7 +635,8 @@ void tst_qdeclarativeanimations::dontStart() QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart2.qml")); - QTest::ignoreMessage(QtWarningMsg, "QDeclarativeAbstractAnimation: setRunning() cannot be used on non-root animation nodes"); + QString warning = c.url().toString() + ":15:17: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes."; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); QDeclarativeRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp index 3bff2f5..ee9e282 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp @@ -272,7 +272,8 @@ void tst_qdeclarativebehaviors::reassignedAnimation() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml")); - QTest::ignoreMessage(QtWarningMsg, QString("QML Behavior (" + QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml").toString() + ":9:9) Cannot change the animation assigned to a Behavior.").toUtf8().constData()); + QString warning = QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml").toString() + ":9:9: QML Behavior: Cannot change the animation assigned to a Behavior."; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); QDeclarativeRectangle *rect = qobject_cast(c.create()); QTRY_VERIFY(rect); QTRY_COMPARE(qobject_cast( @@ -303,7 +304,8 @@ void tst_qdeclarativebehaviors::dontStart() QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart.qml")); - QTest::ignoreMessage(QtWarningMsg, "QDeclarativeAbstractAnimation: setRunning() cannot be used on non-root animation nodes"); + QString warning = c.url().toString() + ":13:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes."; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); QDeclarativeRectangle *rect = qobject_cast(c.create()); QTRY_VERIFY(rect); diff --git a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp index 8621239..69b4a89 100644 --- a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp +++ b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp @@ -121,10 +121,10 @@ void tst_qdeclarativeborderimage::imageSource_data() QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << false << ""; QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() << false - << "QML BorderImage (file::2:1) Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString(); + << "file::2:1: QML BorderImage: Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString(); QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << ""; QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true - << "QML BorderImage (file::2:1) Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found"; + << "file::2:1: QML BorderImage: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found"; } void tst_qdeclarativeborderimage::imageSource() @@ -304,8 +304,8 @@ void tst_qdeclarativeborderimage::sciSource_data() void tst_qdeclarativeborderimage::invalidSciFile() { - QTest::ignoreMessage(QtWarningMsg, "Unknown tile rule specified. Using Stretch "); // for "Roun" - QTest::ignoreMessage(QtWarningMsg, "Unknown tile rule specified. Using Stretch "); // for "Repea" + QTest::ignoreMessage(QtWarningMsg, "QDeclarativeGridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Roun" + QTest::ignoreMessage(QtWarningMsg, "QDeclarativeGridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Repea" QString componentStr = "import Qt 4.7\nBorderImage { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/invalid.sci").toString() +"\"; width: 300; height: 300 }"; QDeclarativeComponent component(&engine); diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 098ac36..a94f4f6 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -320,7 +320,7 @@ void tst_qdeclarativeecmascript::methods() void tst_qdeclarativeecmascript::bindingLoop() { QDeclarativeComponent component(&engine, TEST_FILE("bindingLoop.qml")); - QString warning = "QML MyQmlObject (" + component.url().toString() + ":9:9) Binding loop detected for property \"stringProperty\""; + QString warning = component.url().toString() + ":9:9: QML MyQmlObject: Binding loop detected for property \"stringProperty\""; QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); QObject *object = component.create(); QVERIFY(object != 0); diff --git a/tests/auto/declarative/qdeclarativeflipable/tst_qdeclarativeflipable.cpp b/tests/auto/declarative/qdeclarativeflipable/tst_qdeclarativeflipable.cpp index 4155edb..f32cdbd 100644 --- a/tests/auto/declarative/qdeclarativeflipable/tst_qdeclarativeflipable.cpp +++ b/tests/auto/declarative/qdeclarativeflipable/tst_qdeclarativeflipable.cpp @@ -103,11 +103,11 @@ void tst_qdeclarativeflipable::setFrontAndBack() QVERIFY(obj->front() != 0); QVERIFY(obj->back() != 0); - QString message = "QML Flipable (" + c.url().toString() + ":3:1) front is a write-once property"; + QString message = c.url().toString() + ":3:1: QML Flipable: front is a write-once property"; QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); obj->setFront(new QDeclarativeRectangle()); - message = "QML Flipable (" + c.url().toString() + ":3:1) back is a write-once property"; + message = c.url().toString() + ":3:1: QML Flipable: back is a write-once property"; QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); obj->setBack(new QDeclarativeRectangle()); delete obj; diff --git a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp index 5cdc96c..36908d9 100644 --- a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp +++ b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp @@ -121,7 +121,7 @@ void tst_qdeclarativefontloader::localFont() void tst_qdeclarativefontloader::failLocalFont() { QString componentStr = "import Qt 4.7\nFontLoader { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/dummy.ttf").toString() + "\" }"; - QTest::ignoreMessage(QtWarningMsg, QString("Cannot load font: QUrl( \"" + QUrl::fromLocalFile(SRCDIR "/data/dummy.ttf").toString() + "\" ) ").toUtf8().constData()); + QTest::ignoreMessage(QtWarningMsg, QString("file::2:1: QML FontLoader: Cannot load font: \"" + QUrl::fromLocalFile(SRCDIR "/data/dummy.ttf").toString() + "\"").toUtf8().constData()); QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); @@ -165,7 +165,7 @@ void tst_qdeclarativefontloader::redirWebFont() void tst_qdeclarativefontloader::failWebFont() { QString componentStr = "import Qt 4.7\nFontLoader { source: \"http://localhost:14448/nonexist.ttf\" }"; - QTest::ignoreMessage(QtWarningMsg, "Cannot load font: QUrl( \"http://localhost:14448/nonexist.ttf\" ) "); + QTest::ignoreMessage(QtWarningMsg, "file::2:1: QML FontLoader: Cannot load font: \"http://localhost:14448/nonexist.ttf\""); QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index 854bcdd..f94692b 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -124,13 +124,13 @@ void tst_qdeclarativeimage::imageSource_data() QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << 120.0 << 120.0 << false << false << ""; QTest::newRow("local async") << QUrl::fromLocalFile(SRCDIR "/data/colors1.png").toString() << 120.0 << 120.0 << false << true << ""; QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() << 0.0 << 0.0 << false - << false << "QML Image (file::2:1) Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString(); + << false << "file::2:1: QML Image: Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString(); QTest::newRow("local async not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString() << 0.0 << 0.0 << false - << true << "QML Image (file::2:1) Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString(); + << true << "file::2:1: QML Image: Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString(); QTest::newRow("remote") << SERVER_ADDR "/colors.png" << 120.0 << 120.0 << true << false << ""; QTest::newRow("remote svg") << SERVER_ADDR "/heart.svg" << 550.0 << 500.0 << true << false << ""; QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << 0.0 << 0.0 << true - << false << "QML Image (file::2:1) Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found"; + << false << "file::2:1: QML Image: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found"; } diff --git a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp index aca951b..cc4ec20 100644 --- a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp +++ b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp @@ -96,9 +96,9 @@ void tst_qdeclarativeimageprovider::imageSource_data() QTest::newRow("exists") << "image://test/exists.png" << "" << QSize(100,100) << ""; QTest::newRow("scaled") << "image://test/exists.png" << "sourceSize: \"80x30\"" << QSize(80,30) << ""; QTest::newRow("missing") << "image://test/no-such-file.png" << "" << QSize() - << "QML Image (file::2:1) Failed to get image from provider: image://test/no-such-file.png"; + << "file::2:1: QML Image: Failed to get image from provider: image://test/no-such-file.png"; QTest::newRow("unknown provider") << "image://bogus/exists.png" << "" << QSize() - << "QML Image (file::2:1) Failed to get image from provider: image://bogus/exists.png"; + << "file::2:1: QML Image: Failed to get image from provider: image://bogus/exists.png"; } @@ -158,7 +158,7 @@ void tst_qdeclarativeimageprovider::removeProvider() QCOMPARE(obj->width(), 100.0); // remove the provider and confirm - QString error("QML Image (file::2:1) Failed to get image from provider: image://test2/exists2.png"); + QString error("file::2:1: QML Image: Failed to get image from provider: image://test2/exists2.png"); QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); diff --git a/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp b/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp index aa3f03b..36db448 100644 --- a/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp +++ b/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp @@ -75,14 +75,14 @@ void tst_qdeclarativeinfo::qmlObject() QObject *object = component.create(); QVERIFY(object != 0); - QString message = "QML QObject_QML_0 (" + component.url().toString() + ":3:1) Test Message"; + QString message = component.url().toString() + ":3:1: QML QObject_QML_0: Test Message"; QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); qmlInfo(object) << "Test Message"; QObject *nested = qvariant_cast(object->property("nested")); QVERIFY(nested != 0); - message = "QML QtObject (" + component.url().toString() + ":6:13) Second Test Message"; + message = component.url().toString() + ":6:13: QML QtObject: Second Test Message"; QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); qmlInfo(nested) << "Second Test Message"; } @@ -99,11 +99,11 @@ void tst_qdeclarativeinfo::nestedQmlObject() QObject *nested2 = qvariant_cast(object->property("nested2")); QVERIFY(nested2 != 0); - QString message = "QML NestedObject (" + component.url().toString() + ":5:13) Outer Object"; + QString message = component.url().toString() + ":5:13: QML NestedObject: Outer Object"; QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); qmlInfo(nested) << "Outer Object"; - message = "QML QtObject (" + TEST_FILE("NestedObject.qml").toString() + ":6:14) Inner Object"; + message = TEST_FILE("NestedObject.qml").toString() + ":6:14: QML QtObject: Inner Object"; QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); qmlInfo(nested2) << "Inner Object"; } @@ -111,17 +111,17 @@ void tst_qdeclarativeinfo::nestedQmlObject() void tst_qdeclarativeinfo::nonQmlObject() { QObject object; - QTest::ignoreMessage(QtWarningMsg, "QML QtObject (unknown location) Test Message"); + QTest::ignoreMessage(QtWarningMsg, ": QML QtObject: Test Message"); qmlInfo(&object) << "Test Message"; QPushButton pbObject; - QTest::ignoreMessage(QtWarningMsg, "QML QPushButton (unknown location) Test Message"); + QTest::ignoreMessage(QtWarningMsg, ": QML QPushButton: Test Message"); qmlInfo(&pbObject) << "Test Message"; } void tst_qdeclarativeinfo::nullObject() { - QTest::ignoreMessage(QtWarningMsg, "QML (unknown location) Null Object Test Message"); + QTest::ignoreMessage(QtWarningMsg, ": Null Object Test Message"); qmlInfo(0) << "Null Object Test Message"; } @@ -130,7 +130,7 @@ void tst_qdeclarativeinfo::nonQmlContextedObject() QObject object; QDeclarativeContext context(&engine); QDeclarativeEngine::setContextForObject(&object, &context); - QTest::ignoreMessage(QtWarningMsg, "QML QtObject (unknown location) Test Message"); + QTest::ignoreMessage(QtWarningMsg, ": QML QtObject: Test Message"); qmlInfo(&object) << "Test Message"; } diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index 4400116..d2c328e 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -385,12 +385,15 @@ void tst_QDeclarativeItem::mapCoordinates() Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); QCOMPARE(result.value(), qobject_cast(a)->mapFromScene(x, y)); - QTest::ignoreMessage(QtWarningMsg, "mapToItem() given argument \"1122\" which is neither null nor an Item"); + QString warning1 = QUrl::fromLocalFile(SRCDIR "/data/mapCoordinates.qml").toString() + ":7:5: QML Item: mapToItem() given argument \"1122\" which is neither null nor an Item"; + QString warning2 = QUrl::fromLocalFile(SRCDIR "/data/mapCoordinates.qml").toString() + ":7:5: QML Item: mapFromItem() given argument \"1122\" which is neither null nor an Item"; + + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QVERIFY(QMetaObject::invokeMethod(root, "checkMapAToInvalid", Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); QVERIFY(result.toBool()); - QTest::ignoreMessage(QtWarningMsg, "mapFromItem() given argument \"1122\" which is neither null nor an Item"); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); QVERIFY(QMetaObject::invokeMethod(root, "checkMapAFromInvalid", Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); QVERIFY(result.toBool()); diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 8feab32..9d4a1f5 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -779,8 +779,7 @@ void tst_qdeclarativelanguage::valueTypes() QDeclarativeComponent component(&engine, TEST_FILE("valueTypes.qml")); VERIFY_ERRORS(0); - QString message = QLatin1String("QML MyTypeObject (") + component.url().toString() + - QLatin1String(":2:1) Binding loop detected for property \"rectProperty.width\""); + QString message = component.url().toString() + ":2:1: QML MyTypeObject: Binding loop detected for property \"rectProperty.width\""; QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index 9d61ad0..b44a4f7 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -183,58 +183,58 @@ void tst_QDeclarativeListModel::dynamic_data() QTest::newRow("count") << "count" << 0 << ""; - QTest::newRow("get1") << "{get(0)}" << 0 << "QML ListModel (unknown location) get: index 0 out of range"; - QTest::newRow("get2") << "{get(-1)}" << 0 << "QML ListModel (unknown location) get: index -1 out of range"; + QTest::newRow("get1") << "{get(0)}" << 0 << ": QML ListModel: get: index 0 out of range"; + QTest::newRow("get2") << "{get(-1)}" << 0 << ": QML ListModel: get: index -1 out of range"; QTest::newRow("append1") << "{append({'foo':123});count}" << 1 << ""; QTest::newRow("append2") << "{append({'foo':123,'bar':456});count}" << 1 << ""; QTest::newRow("append3a") << "{append({'foo':123});append({'foo':456});get(0).foo}" << 123 << ""; QTest::newRow("append3b") << "{append({'foo':123});append({'foo':456});get(1).foo}" << 456 << ""; - QTest::newRow("append4a") << "{append(123)}" << 0 << "QML ListModel (unknown location) append: value is not an object"; - QTest::newRow("append4b") << "{append([1,2,3])}" << 0 << "QML ListModel (unknown location) append: value is not an object"; + QTest::newRow("append4a") << "{append(123)}" << 0 << ": QML ListModel: append: value is not an object"; + QTest::newRow("append4b") << "{append([1,2,3])}" << 0 << ": QML ListModel: append: value is not an object"; QTest::newRow("clear1") << "{append({'foo':456});clear();count}" << 0 << ""; QTest::newRow("clear2") << "{append({'foo':123});append({'foo':456});clear();count}" << 0 << ""; - QTest::newRow("clear3") << "{append({'foo':123});clear();get(0).foo}" << 0 << "QML ListModel (unknown location) get: index 0 out of range"; + QTest::newRow("clear3") << "{append({'foo':123});clear();get(0).foo}" << 0 << ": QML ListModel: get: index 0 out of range"; QTest::newRow("remove1") << "{append({'foo':123});remove(0);count}" << 0 << ""; QTest::newRow("remove2a") << "{append({'foo':123});append({'foo':456});remove(0);count}" << 1 << ""; QTest::newRow("remove2b") << "{append({'foo':123});append({'foo':456});remove(0);get(0).foo}" << 456 << ""; QTest::newRow("remove2c") << "{append({'foo':123});append({'foo':456});remove(1);get(0).foo}" << 123 << ""; - QTest::newRow("remove3") << "{append({'foo':123});remove(0);get(0).foo}" << 0 << "QML ListModel (unknown location) get: index 0 out of range"; - QTest::newRow("remove3a") << "{append({'foo':123});remove(-1);count}" << 1 << "QML ListModel (unknown location) remove: index -1 out of range"; - QTest::newRow("remove4a") << "{remove(0)}" << 0 << "QML ListModel (unknown location) remove: index 0 out of range"; - QTest::newRow("remove4b") << "{append({'foo':123});remove(0);remove(0);count}" << 0 << "QML ListModel (unknown location) remove: index 0 out of range"; - QTest::newRow("remove4c") << "{append({'foo':123});remove(1);count}" << 1 << "QML ListModel (unknown location) remove: index 1 out of range"; + QTest::newRow("remove3") << "{append({'foo':123});remove(0);get(0).foo}" << 0 << ": QML ListModel: get: index 0 out of range"; + QTest::newRow("remove3a") << "{append({'foo':123});remove(-1);count}" << 1 << ": QML ListModel: remove: index -1 out of range"; + QTest::newRow("remove4a") << "{remove(0)}" << 0 << ": QML ListModel: remove: index 0 out of range"; + QTest::newRow("remove4b") << "{append({'foo':123});remove(0);remove(0);count}" << 0 << ": QML ListModel: remove: index 0 out of range"; + QTest::newRow("remove4c") << "{append({'foo':123});remove(1);count}" << 1 << ": QML ListModel: remove: index 1 out of range"; QTest::newRow("insert1") << "{insert(0,{'foo':123});count}" << 1 << ""; - QTest::newRow("insert2") << "{insert(1,{'foo':123});count}" << 0 << "QML ListModel (unknown location) insert: index 1 out of range"; + QTest::newRow("insert2") << "{insert(1,{'foo':123});count}" << 0 << ": QML ListModel: insert: index 1 out of range"; QTest::newRow("insert3a") << "{append({'foo':123});insert(1,{'foo':456});count}" << 2 << ""; QTest::newRow("insert3b") << "{append({'foo':123});insert(1,{'foo':456});get(0).foo}" << 123 << ""; QTest::newRow("insert3c") << "{append({'foo':123});insert(1,{'foo':456});get(1).foo}" << 456 << ""; QTest::newRow("insert3d") << "{append({'foo':123});insert(0,{'foo':456});get(0).foo}" << 456 << ""; QTest::newRow("insert3e") << "{append({'foo':123});insert(0,{'foo':456});get(1).foo}" << 123 << ""; - QTest::newRow("insert4") << "{append({'foo':123});insert(-1,{'foo':456});count}" << 1 << "QML ListModel (unknown location) insert: index -1 out of range"; - QTest::newRow("insert5a") << "{insert(0,123)}" << 0 << "QML ListModel (unknown location) insert: value is not an object"; - QTest::newRow("insert5b") << "{insert(0,[1,2,3])}" << 0 << "QML ListModel (unknown location) insert: value is not an object"; + QTest::newRow("insert4") << "{append({'foo':123});insert(-1,{'foo':456});count}" << 1 << ": QML ListModel: insert: index -1 out of range"; + QTest::newRow("insert5a") << "{insert(0,123)}" << 0 << ": QML ListModel: insert: value is not an object"; + QTest::newRow("insert5b") << "{insert(0,[1,2,3])}" << 0 << ": QML ListModel: insert: value is not an object"; QTest::newRow("set1") << "{append({'foo':123});set(0,{'foo':456});count}" << 1 << ""; QTest::newRow("set2") << "{append({'foo':123});set(0,{'foo':456});get(0).foo}" << 456 << ""; QTest::newRow("set3a") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).foo}" << 999 << ""; QTest::newRow("set3b") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).bar}" << 456 << ""; - QTest::newRow("set4a") << "{set(0,{'foo':456})}" << 0 << "QML ListModel (unknown location) set: index 0 out of range"; - QTest::newRow("set4c") << "{set(-1,{'foo':456})}" << 0 << "QML ListModel (unknown location) set: index -1 out of range"; - QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123);count}" << 1 << "QML ListModel (unknown location) set: value is not an object"; - QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3]);count}" << 1 << "QML ListModel (unknown location) set: value is not an object"; + QTest::newRow("set4a") << "{set(0,{'foo':456})}" << 0 << ": QML ListModel: set: index 0 out of range"; + QTest::newRow("set4c") << "{set(-1,{'foo':456})}" << 0 << ": QML ListModel: set: index -1 out of range"; + QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123);count}" << 1 << ": QML ListModel: set: value is not an object"; + QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3]);count}" << 1 << ": QML ListModel: set: value is not an object"; QTest::newRow("set6") << "{append({'foo':123});set(1,{'foo':456});count}" << 2 << ""; QTest::newRow("setprop1") << "{append({'foo':123});setProperty(0,'foo',456);count}" << 1 << ""; QTest::newRow("setprop2") << "{append({'foo':123});setProperty(0,'foo',456);get(0).foo}" << 456 << ""; QTest::newRow("setprop3a") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).foo}" << 999 << ""; QTest::newRow("setprop3b") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).bar}" << 456 << ""; - QTest::newRow("setprop4a") << "{setProperty(0,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index 0 out of range"; - QTest::newRow("setprop4b") << "{setProperty(-1,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index -1 out of range"; - QTest::newRow("setprop4c") << "{append({'foo':123,'bar':456});setProperty(1,'foo',456);count}" << 1 << "QML ListModel (unknown location) set: index 1 out of range"; + QTest::newRow("setprop4a") << "{setProperty(0,'foo',456)}" << 0 << ": QML ListModel: set: index 0 out of range"; + QTest::newRow("setprop4b") << "{setProperty(-1,'foo',456)}" << 0 << ": QML ListModel: set: index -1 out of range"; + QTest::newRow("setprop4c") << "{append({'foo':123,'bar':456});setProperty(1,'foo',456);count}" << 1 << ": QML ListModel: set: index 1 out of range"; QTest::newRow("setprop5") << "{append({'foo':123,'bar':456});append({'foo':111});setProperty(1,'bar',222);get(1).bar}" << 222 << ""; QTest::newRow("move1a") << "{append({'foo':123});append({'foo':456});move(0,1,1);count}" << 2 << ""; @@ -246,10 +246,10 @@ void tst_QDeclarativeListModel::dynamic_data() QTest::newRow("move2b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(0).foo}" << 789 << ""; QTest::newRow("move2c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(1).foo}" << 123 << ""; QTest::newRow("move2d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(2).foo}" << 456 << ""; - QTest::newRow("move3a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,3);count}" << 3 << "QML ListModel (unknown location) move: out of range"; - QTest::newRow("move3b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,-1,1);count}" << 3 << "QML ListModel (unknown location) move: out of range"; - QTest::newRow("move3c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,-1);count}" << 3 << "QML ListModel (unknown location) move: out of range"; - QTest::newRow("move3d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,3,1);count}" << 3 << "QML ListModel (unknown location) move: out of range"; + QTest::newRow("move3a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,3);count}" << 3 << ": QML ListModel: move: out of range"; + QTest::newRow("move3b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,-1,1);count}" << 3 << ": QML ListModel: move: out of range"; + QTest::newRow("move3c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,-1);count}" << 3 << ": QML ListModel: move: out of range"; + QTest::newRow("move3d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,3,1);count}" << 3 << ": QML ListModel: move: out of range"; // Nested models @@ -323,7 +323,7 @@ void tst_QDeclarativeListModel::dynamic_worker() // execute a set of commands on the worker list model, then check the // changes are reflected in the list model in the main thread if (QByteArray(QTest::currentDataTag()).startsWith("nested")) - QTest::ignoreMessage(QtWarningMsg, "QML ListModel (unknown location) Cannot add nested list values when modifying or after modification from a worker script"); + QTest::ignoreMessage(QtWarningMsg, ": QML ListModel: Cannot add nested list values when modifying or after modification from a worker script"); QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", Q_ARG(QVariant, operations.mid(0, operations.length()-1)))); @@ -359,7 +359,7 @@ void tst_QDeclarativeListModel::convertNestedToFlat_fail() model.append(nestedListValue(&s_eng)); QCOMPARE(model.count(), 2); - QTest::ignoreMessage(QtWarningMsg, "QML ListModel (unknown location) List contains nested list values and cannot be used from a worker script"); + QTest::ignoreMessage(QtWarningMsg, ": QML ListModel: List contains nested list values and cannot be used from a worker script"); QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", Q_ARG(QVariant, script))); waitForWorker(item); @@ -411,7 +411,7 @@ void tst_QDeclarativeListModel::convertNestedToFlat_ok() QCOMPARE(model.count(), count+1); QScriptValue nested = nestedListValue(&s_eng); - const char *warning = "QML ListModel (unknown location) Cannot add nested list values when modifying or after modification from a worker script"; + const char *warning = ": QML ListModel: Cannot add nested list values when modifying or after modification from a worker script"; QTest::ignoreMessage(QtWarningMsg, warning); model.append(nested); diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp index 4a82b50..1b17a56 100644 --- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp +++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp @@ -138,7 +138,7 @@ void tst_QDeclarativeLoader::component() void tst_QDeclarativeLoader::invalidUrl() { - QTest::ignoreMessage(QtWarningMsg, QString("(:-1: File error for URL " + QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml").toString() + ") ").toUtf8().constData()); + QTest::ignoreMessage(QtWarningMsg, QString(": File error for URL " + QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml").toString()).toUtf8().constData()); QDeclarativeComponent component(&engine); component.setData(QByteArray("import Qt 4.7\nLoader { source: \"IDontExist.qml\" }"), TEST_FILE("")); @@ -465,7 +465,7 @@ void tst_QDeclarativeLoader::failNetworkRequest() QVERIFY(server.isValid()); server.serveDirectory(SRCDIR "/data"); - QTest::ignoreMessage(QtWarningMsg, "(:-1: Network error for URL http://127.0.0.1:14450/IDontExist.qml) "); + QTest::ignoreMessage(QtWarningMsg, ": Network error for URL http://127.0.0.1:14450/IDontExist.qml"); QDeclarativeComponent component(&engine); component.setData(QByteArray("import Qt 4.7\nLoader { source: \"http://127.0.0.1:14450/IDontExist.qml\" }"), QUrl::fromLocalFile("http://127.0.0.1:14450/dummy.qml")); @@ -505,7 +505,7 @@ void tst_QDeclarativeLoader::deleteComponentCrash() void tst_QDeclarativeLoader::nonItem() { QDeclarativeComponent component(&engine, TEST_FILE("nonItem.qml")); - QString err = QString("QML Loader (") + QUrl::fromLocalFile(SRCDIR).toString() + QString("/data/nonItem.qml:3:1) Loader does not support loading non-visual elements."); + QString err = QUrl::fromLocalFile(SRCDIR).toString() + "/data/nonItem.qml:3:1: QML Loader: Loader does not support loading non-visual elements."; QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData()); QDeclarativeLoader *loader = qobject_cast(component.create()); diff --git a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp index 7d51bb6..53614fe 100644 --- a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp +++ b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp @@ -310,7 +310,7 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object() QCOMPARE(prop.propertyTypeName(), "int"); QCOMPARE(QString(prop.property().name()), QString("defaultProperty")); QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); - QTest::ignoreMessage(QtWarningMsg, ":-1: Unable to assign null to int"); + QTest::ignoreMessage(QtWarningMsg, ": Unable to assign null to int"); QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding != 0); QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding.data()); @@ -409,7 +409,7 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string() QCOMPARE(prop.propertyTypeName(), "int"); QCOMPARE(QString(prop.property().name()), QString("defaultProperty")); QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); - QTest::ignoreMessage(QtWarningMsg, ":-1: Unable to assign null to int"); + QTest::ignoreMessage(QtWarningMsg, ": Unable to assign null to int"); QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding != 0); QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding.data()); @@ -602,7 +602,7 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_context() QCOMPARE(prop.propertyTypeName(), "int"); QCOMPARE(QString(prop.property().name()), QString("defaultProperty")); QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); - QTest::ignoreMessage(QtWarningMsg, ":-1: Unable to assign null to int"); + QTest::ignoreMessage(QtWarningMsg, ": Unable to assign null to int"); QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding != 0); QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding.data()); @@ -701,7 +701,7 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.propertyTypeName(), "int"); QCOMPARE(QString(prop.property().name()), QString("defaultProperty")); QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); - QTest::ignoreMessage(QtWarningMsg, ":-1: Unable to assign null to int"); + QTest::ignoreMessage(QtWarningMsg, ": Unable to assign null to int"); QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding != 0); QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding.data()); diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp index 578bcb4..1446920 100644 --- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp +++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp @@ -522,7 +522,7 @@ void tst_qdeclarativestates::parentChangeErrors() QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QVERIFY(innerRect != 0); - QTest::ignoreMessage(QtWarningMsg, QByteArray("QML ParentChange (" + fullDataPath("/data/parentChange4.qml") + ":25:9) Unable to preserve appearance under non-uniform scale").constData()); + QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/parentChange4.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under non-uniform scale"); rect->setState("reparented"); QCOMPARE(innerRect->rotation(), qreal(0)); QCOMPARE(innerRect->scale(), qreal(1)); @@ -538,7 +538,7 @@ void tst_qdeclarativestates::parentChangeErrors() QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QVERIFY(innerRect != 0); - QTest::ignoreMessage(QtWarningMsg, QByteArray("QML ParentChange (" + fullDataPath("/data/parentChange5.qml") + ":25:9) Unable to preserve appearance under complex transform").constData()); + QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/parentChange5.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under complex transform"); rect->setState("reparented"); QCOMPARE(innerRect->rotation(), qreal(0)); QCOMPARE(innerRect->scale(), qreal(1)); @@ -813,8 +813,8 @@ void tst_qdeclarativestates::propertyErrors() QCOMPARE(rect->color(),QColor("red")); - QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/propertyErrors.qml") + ":8:9) Cannot assign to non-existent property \"colr\"").constData()); - QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/propertyErrors.qml") + ":8:9) Cannot assign to read-only property \"wantsFocus\"").constData()); + QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\""); + QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to read-only property \"wantsFocus\""); rect->setState("blue"); } @@ -946,7 +946,7 @@ void tst_qdeclarativestates::illegalTempState() QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QTest::ignoreMessage(QtWarningMsg, "Can't apply a state change as part of a state definition. "); + QTest::ignoreMessage(QtWarningMsg, ": QML StateGroup: Can't apply a state change as part of a state definition."); rect->setState("placed"); QCOMPARE(rect->state(), QLatin1String("placed")); } @@ -959,7 +959,7 @@ void tst_qdeclarativestates::nonExistantProperty() QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/nonExistantProp.qml") + ":9:9) Cannot assign to non-existent property \"colr\"").constData()); + QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/nonExistantProp.qml") + ":9:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\""); rect->setState("blue"); QCOMPARE(rect->state(), QLatin1String("blue")); } diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp index edb4a32..551e17b 100644 --- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp +++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp @@ -871,10 +871,10 @@ void tst_qdeclarativetext::embeddedImages_data() QTest::addColumn("error"); QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesLocal.qml") << ""; QTest::newRow("local-error") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesLocalError.qml") - << "QML Text ("+QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesLocalError.qml").toString()+":3:1) Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/http/notexists.png").toString(); + << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesLocalError.qml").toString()+":3:1: QML Text: Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/http/notexists.png").toString(); QTest::newRow("remote") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesRemote.qml") << ""; QTest::newRow("remote-error") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesRemoteError.qml") - << "QML Text ("+QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesRemoteError.qml").toString()+":3:1) Error downloading http://127.0.0.1:14453/notexists.png - server replied: Not found"; + << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesRemoteError.qml").toString()+":3:1: QML Text: Error downloading http://127.0.0.1:14453/notexists.png - server replied: Not found"; } void tst_qdeclarativetext::embeddedImages() diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 25101ba..3307b7c 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -649,7 +649,7 @@ void tst_qdeclarativetextedit::delegateLoading_data() // import installed QTest::newRow("pass") << "cursorHttpTestPass.qml" << ""; - QTest::newRow("fail1") << "cursorHttpTestFail1.qml" << ":-1: Network error for URL http://localhost:42332/FailItem.qml "; + QTest::newRow("fail1") << "cursorHttpTestFail1.qml" << ": Network error for URL http://localhost:42332/FailItem.qml "; QTest::newRow("fail2") << "cursorHttpTestFail2.qml" << "http://localhost:42332/ErrItem.qml:4:5: Fungus is not a type "; } -- cgit v0.12 From ffe9f4b839da5bc2758845a5eb6ddc78776b06df Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 19 Apr 2010 14:14:30 +1000 Subject: Partial revert of 348d1f6d421a6e23b769af99608fa6d81631a6c3 (accidentally committed changes) --- src/testlib/qtestlightxmlstreamer.cpp | 3 +-- src/testlib/qtestlogger.cpp | 3 --- src/testlib/qtestxmlstreamer.cpp | 3 +-- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/testlib/qtestlightxmlstreamer.cpp b/src/testlib/qtestlightxmlstreamer.cpp index 8c22a4f..0ac9ea8 100644 --- a/src/testlib/qtestlightxmlstreamer.cpp +++ b/src/testlib/qtestlightxmlstreamer.cpp @@ -87,13 +87,12 @@ void QTestLightXmlStreamer::formatStart(const QTestElement *element, QTestCharBu QXmlTestLogger::xmlQuote("edFile, element->attributeValue(QTest::AI_File)); QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description)); - QTest::qt_asprintf(formatted, "\n %s\n\n", + QTest::qt_asprintf(formatted, "\n \n\n", element->attributeValue(QTest::AI_Type), element->attributeName(QTest::AI_File), quotedFile.constData(), element->attributeName(QTest::AI_Line), element->attributeValue(QTest::AI_Line), - element->attributeValue(QTest::AI_Tag) ? element->attributeValue(QTest::AI_Tag) : "", cdataDesc.constData()); break; } diff --git a/src/testlib/qtestlogger.cpp b/src/testlib/qtestlogger.cpp index 79bb84c..6c76388 100644 --- a/src/testlib/qtestlogger.cpp +++ b/src/testlib/qtestlogger.cpp @@ -318,9 +318,6 @@ void QTestLogger::addMessage(MessageTypes type, const char *message, const char break; } - const char *tag = QTestResult::currentDataTag(); - if (tag) - errorElement->addAttribute(QTest::AI_Tag, tag); errorElement->addAttribute(QTest::AI_Type, typeBuf); errorElement->addAttribute(QTest::AI_Description, message); diff --git a/src/testlib/qtestxmlstreamer.cpp b/src/testlib/qtestxmlstreamer.cpp index 9addb31..b9946e5 100644 --- a/src/testlib/qtestxmlstreamer.cpp +++ b/src/testlib/qtestxmlstreamer.cpp @@ -111,13 +111,12 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, QTestCharBuffer QXmlTestLogger::xmlQuote("edFile, element->attributeValue(QTest::AI_File)); QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description)); - QTest::qt_asprintf(formatted, "\n %s\n \n\n", + QTest::qt_asprintf(formatted, "\n \n\n", element->attributeValue(QTest::AI_Type), element->attributeName(QTest::AI_File), quotedFile.constData(), element->attributeName(QTest::AI_Line), element->attributeValue(QTest::AI_Line), - element->attributeValue(QTest::AI_Tag) ? element->attributeValue(QTest::AI_Tag) : "", cdataDesc.constData()); break; } -- cgit v0.12 From 7de92b5b4cee9179d7163a477c03ed411c3975d6 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 19 Apr 2010 14:44:03 +1000 Subject: Compile --- src/declarative/qml/qdeclarativeinfo.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/declarative/qml/qdeclarativeinfo.h b/src/declarative/qml/qdeclarativeinfo.h index 36de7b1..3d5a111 100644 --- a/src/declarative/qml/qdeclarativeinfo.h +++ b/src/declarative/qml/qdeclarativeinfo.h @@ -43,6 +43,7 @@ #define QDECLARATIVEINFO_H #include +#include #include QT_BEGIN_HEADER @@ -82,6 +83,7 @@ public: inline QDeclarativeInfo &operator<<(const void * t) { QDebug::operator<<(t); return *this; } inline QDeclarativeInfo &operator<<(QTextStreamFunction f) { QDebug::operator<<(f); return *this; } inline QDeclarativeInfo &operator<<(QTextStreamManipulator m) { QDebug::operator<<(m); return *this; } + inline QDeclarativeInfo &operator<<(const QUrl &t) { static_cast(*this) << t; return *this; } private: QDeclarativeInfoPrivate *d; -- cgit v0.12 From 16d2b97e03ff99583ab25977880affecc1c4463b Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Mon, 19 Apr 2010 14:47:11 +1000 Subject: QDeclarativeImage should stretch in one direction when tiling in the other. Task-number: QTBUG-6716 Reviewed-by: Michael Brasser --- .../graphicsitems/qdeclarativeimage.cpp | 25 +++++-- .../declarative/qdeclarativeimage/data/green.png | Bin 0 -> 314 bytes .../declarative/qdeclarativeimage/data/tiling.qml | 16 +++++ .../qdeclarativeimage/tst_qdeclarativeimage.cpp | 77 ++++++++++++++++++++- 4 files changed, 112 insertions(+), 6 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativeimage/data/green.png create mode 100644 tests/auto/declarative/qdeclarativeimage/data/tiling.qml diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp index 37b07bf..1ca8fe2 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp @@ -366,12 +366,27 @@ void QDeclarativeImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWi if (width() != d->pix.width() || height() != d->pix.height()) { if (d->fillMode >= Tile) { - if (d->fillMode == Tile) + if (d->fillMode == Tile) { p->drawTiledPixmap(QRectF(0,0,width(),height()), d->pix); - else if (d->fillMode == TileVertically) - p->drawTiledPixmap(QRectF(0,0,d->pix.width(),height()), d->pix); - else - p->drawTiledPixmap(QRectF(0,0,width(),d->pix.height()), d->pix); + } else { + qreal widthScale = width() / qreal(d->pix.width()); + qreal heightScale = height() / qreal(d->pix.height()); + + QTransform scale; + if (d->fillMode == TileVertically) { + scale.scale(widthScale, 1.0); + QTransform old = p->transform(); + p->setWorldTransform(scale * old); + p->drawTiledPixmap(QRectF(0,0,d->pix.width(),height()), d->pix); + p->setWorldTransform(old); + } else { + scale.scale(1.0, heightScale); + QTransform old = p->transform(); + p->setWorldTransform(scale * old); + p->drawTiledPixmap(QRectF(0,0,width(),d->pix.height()), d->pix); + p->setWorldTransform(old); + } + } } else { qreal widthScale = width() / qreal(d->pix.width()); qreal heightScale = height() / qreal(d->pix.height()); diff --git a/tests/auto/declarative/qdeclarativeimage/data/green.png b/tests/auto/declarative/qdeclarativeimage/data/green.png new file mode 100644 index 0000000..0a2e153 Binary files /dev/null and b/tests/auto/declarative/qdeclarativeimage/data/green.png differ diff --git a/tests/auto/declarative/qdeclarativeimage/data/tiling.qml b/tests/auto/declarative/qdeclarativeimage/data/tiling.qml new file mode 100644 index 0000000..32839bb --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimage/data/tiling.qml @@ -0,0 +1,16 @@ +import Qt 4.7 + +Rectangle { + width: 800; height: 600 + + Image { + objectName: "vTiling"; height: 550; width: 200 + source: "green.png"; fillMode: Image.TileVertically + } + + Image { + objectName: "hTiling"; x: 225; height: 250; width: 550 + source: "green.png"; fillMode: Image.TileHorizontally + } +} + diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index f94692b..73aefaf 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include "../shared/testhttpserver.h" @@ -86,8 +87,12 @@ private slots: void pixmap(); void svg(); void big(); + void tiling_QTBUG_6716(); private: + template + T *findItem(QGraphicsObject *parent, const QString &id, int index=-1); + QDeclarativeEngine engine; }; @@ -161,7 +166,7 @@ void tst_qdeclarativeimage::imageSource() if (async) QVERIFY(obj->asynchronous() == true); - + if (remote || async) TRY_WAIT(obj->status() == QDeclarativeImage::Loading); @@ -339,6 +344,76 @@ void tst_qdeclarativeimage::big() delete obj; } +void tst_qdeclarativeimage::tiling_QTBUG_6716() +{ + QDeclarativeView *canvas = new QDeclarativeView(0); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/tiling.qml")); + canvas->show(); + qApp->processEvents(); + + QDeclarativeImage *vTiling = findItem(canvas->rootObject(), "vTiling"); + QDeclarativeImage *hTiling = findItem(canvas->rootObject(), "hTiling"); + + QVERIFY(vTiling != 0); + QVERIFY(hTiling != 0); + + { + QPixmap pm(vTiling->width(), vTiling->height()); + QPainter p(&pm); + vTiling->paint(&p, 0, 0); + + QImage img = pm.toImage(); + for (int x = 0; x < vTiling->width(); ++x) { + for (int y = 0; y < vTiling->height(); ++y) { + QVERIFY(img.pixel(x, y) == qRgb(0, 255, 0)); + } + } + } + + { + QPixmap pm(hTiling->width(), hTiling->height()); + QPainter p(&pm); + hTiling->paint(&p, 0, 0); + + QImage img = pm.toImage(); + for (int x = 0; x < hTiling->width(); ++x) { + for (int y = 0; y < hTiling->height(); ++y) { + QVERIFY(img.pixel(x, y) == qRgb(0, 255, 0)); + } + } + } +} + +/* + Find an item with the specified objectName. If index is supplied then the + item must also evaluate the {index} expression equal to index +*/ +template +T *tst_qdeclarativeimage::findItem(QGraphicsObject *parent, const QString &objectName, int index) +{ + const QMetaObject &mo = T::staticMetaObject; + //qDebug() << parent->childItems().count() << "children"; + for (int i = 0; i < parent->childItems().count(); ++i) { + QDeclarativeItem *item = qobject_cast(parent->childItems().at(i)); + if(!item) + continue; + //qDebug() << "try" << item; + if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { + if (index != -1) { + QDeclarativeExpression e(qmlContext(item), "index", item); + if (e.value().toInt() == index) + return static_cast(item); + } else { + return static_cast(item); + } + } + item = findItem(item, objectName, index); + if (item) + return static_cast(item); + } + + return 0; +} QTEST_MAIN(tst_qdeclarativeimage) -- cgit v0.12 From cb54ab7c6f60cadc85c25750a1b2aa3bc96a1505 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 19 Apr 2010 15:38:14 +1000 Subject: Reference count ObjectData's to correctly delete objects with no parent QTBUG-9872 --- src/declarative/qml/qdeclarativedata_p.h | 3 ++- src/declarative/qml/qdeclarativeobjectscriptclass.cpp | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/declarative/qml/qdeclarativedata_p.h b/src/declarative/qml/qdeclarativedata_p.h index 2ddd7e5..4a56536 100644 --- a/src/declarative/qml/qdeclarativedata_p.h +++ b/src/declarative/qml/qdeclarativedata_p.h @@ -75,7 +75,7 @@ public: : ownMemory(true), ownContext(false), indestructible(true), explicitIndestructibleSet(false), context(0), outerContext(0), bindings(0), nextContextObject(0), prevContextObject(0), bindingBitsSize(0), bindingBits(0), lineNumber(0), columnNumber(0), deferredComponent(0), deferredIdx(0), - attachedProperties(0), scriptValue(0), propertyCache(0), guards(0) { + attachedProperties(0), scriptValue(0), objectDataRefCount(0), propertyCache(0), guards(0) { init(); } @@ -128,6 +128,7 @@ public: // ### Can we make this QScriptValuePrivate so we incur no additional allocation // cost? QScriptValue *scriptValue; + quint32 objectDataRefCount; QDeclarativePropertyCache *propertyCache; QDeclarativeGuard *guards; diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp index 5773fe6..a27d19d 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp @@ -59,12 +59,17 @@ Q_DECLARE_METATYPE(QScriptValue); QT_BEGIN_NAMESPACE struct ObjectData : public QScriptDeclarativeClass::Object { - ObjectData(QObject *o, int t) : object(o), type(t) {} + ObjectData(QObject *o, int t) : object(o), type(t) { + if (o) { + QDeclarativeData *ddata = QDeclarativeData::get(object, true); + if (ddata) ddata->objectDataRefCount++; + } + } virtual ~ObjectData() { if (object && !object->parent()) { QDeclarativeData *ddata = QDeclarativeData::get(object, false); - if (ddata && !ddata->indestructible) + if (ddata && !ddata->indestructible && 0 == --ddata->objectDataRefCount) object->deleteLater(); } } -- cgit v0.12 From 8e414cb69e1d27b66f51cd68a7126c5ac647c974 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Mon, 19 Apr 2010 15:49:44 +1000 Subject: Documentation fixes. --- src/declarative/graphicsitems/qdeclarativeborderimage.cpp | 10 +++++----- src/declarative/graphicsitems/qdeclarativeimage.cpp | 9 ++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp index 7858a7a..06f8363 100644 --- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp @@ -264,9 +264,9 @@ void QDeclarativeBorderImage::load() When the image is scaled: \list \i the corners (sections 1, 3, 7, and 9) are not scaled at all - \i the middle (section 5) is scaled according to BorderImage::horizontalTileMode and BorderImage::verticalTileMode - \i sections 2 and 8 are scaled according to BorderImage::horizontalTileMode - \i sections 4 and 6 are scaled according to BorderImage::verticalTileMode + \i sections 2 and 8 are scaled according to \l{BorderImage::horizontalTileMode}{horizontalTileMode} + \i sections 4 and 6 are scaled according to \l{BorderImage::verticalTileMode}{verticalTileMode} + \i the middle (section 5) is scaled according to both \l{BorderImage::horizontalTileMode}{horizontalTileMode} and \l{BorderImage::verticalTileMode}{verticalTileMode} \endlist Each border line (left, right, top, and bottom) specifies an offset from the respective side. For example, \c{border.bottom: 10} sets the bottom line 10 pixels up from the bottom of the image. @@ -282,8 +282,8 @@ QDeclarativeScaleGrid *QDeclarativeBorderImage::border() } /*! - \qmlproperty TileMode BorderImage::horizontalTileMode - \qmlproperty TileMode BorderImage::verticalTileMode + \qmlproperty enumeration BorderImage::horizontalTileMode + \qmlproperty enumeration BorderImage::verticalTileMode This property describes how to repeat or stretch the middle parts of the border image. diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp index 1ca8fe2..247e348 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp @@ -236,9 +236,12 @@ qreal QDeclarativeImage::paintedHeight() const to react to the change in status you need to do it yourself, for example in one of the following ways: \list - \o Create a state, so that a state change occurs, e.g. State{name: 'loaded'; when: image.status = Image.Ready;} - \o Do something inside the onStatusChanged signal handler, e.g. Image{id: image; onStatusChanged: if(image.status == Image.Ready) console.log('Loaded');} - \o Bind to the status variable somewhere, e.g. Text{text: if(image.status!=Image.Ready){'Not Loaded';}else{'Loaded';}} + \o Create a state, so that a state change occurs, e.g. + \qml State { name: 'loaded'; when: image.status = Image.Ready } \endqml + \o Do something inside the onStatusChanged signal handler, e.g. + \qml Image { id: image; onStatusChanged: if (image.status == Image.Ready) console.log('Loaded') } \endqml + \o Bind to the status variable somewhere, e.g. + \qml Text { text: if (image.status != Image.Ready) { 'Not Loaded' } else { 'Loaded' } } \endqml \endlist \sa progress -- cgit v0.12