diff options
9 files changed, 102 insertions, 11 deletions
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index f31cf53..0ee6dfe 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -294,6 +294,10 @@ QNetworkAccessManager *QDeclarativeScriptEngine::networkAccessManager() QDeclarativeEnginePrivate::~QDeclarativeEnginePrivate() { + Q_ASSERT(inProgressCreations == 0); + Q_ASSERT(bindValues.isEmpty()); + Q_ASSERT(parserStatus.isEmpty()); + while (cleanup) { QDeclarativeCleanup *c = cleanup; cleanup = c->next; @@ -318,10 +322,6 @@ QDeclarativeEnginePrivate::~QDeclarativeEnginePrivate() delete globalClass; globalClass = 0; - for(int ii = 0; ii < bindValues.count(); ++ii) - clear(bindValues[ii]); - for(int ii = 0; ii < parserStatus.count(); ++ii) - clear(parserStatus[ii]); for(QHash<int, QDeclarativeCompiledData*>::ConstIterator iter = m_compositeTypes.constBegin(); iter != m_compositeTypes.constEnd(); ++iter) (*iter)->release(); for(QHash<const QMetaObject *, QDeclarativePropertyCache *>::Iterator iter = propertyCache.begin(); iter != propertyCache.end(); ++iter) @@ -771,7 +771,9 @@ void QDeclarativeEngine::setObjectOwnership(QObject *object, ObjectOwnership own if (!object) return; - QDeclarativeData *ddata = QDeclarativeData::get(object, true); + // No need to do anything if CppOwnership and there is no QDeclarativeData as + // the current ownership must be CppOwnership + QDeclarativeData *ddata = QDeclarativeData::get(object, ownership == JavaScriptOwnership); if (!ddata) return; @@ -809,9 +811,6 @@ void qmlExecuteDeferred(QObject *object) data->deferredComponent = 0; QDeclarativeComponentPrivate::complete(ep, &state); - - if (!state.errors.isEmpty()) - ep->warning(state.errors); } } @@ -1162,7 +1161,7 @@ QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScr } else if (ctxt->argument(1).isNumber()) { enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32()); } else { - return ctxt->throwError("Qt.formatDateTime(): Invalid datetime formate"); + return ctxt->throwError("Qt.formatDateTime(): Invalid datetime format"); } } return engine->newVariant(qVariantFromValue(date.toString(enumFormat))); diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp index d9ea8dc..5fcb7ee 100644 --- a/src/declarative/qml/qdeclarativemetatype.cpp +++ b/src/declarative/qml/qdeclarativemetatype.cpp @@ -247,7 +247,7 @@ static void clone(QMetaObjectBuilder &builder, const QMetaObject *mo, QMetaProperty property = mo->property(ii); int otherIndex = ignoreEnd->indexOfProperty(property.name()); - if (otherIndex >= ignoreStart->classInfoOffset() + ignoreStart->classInfoCount()) { + if (otherIndex >= ignoreStart->propertyOffset() + ignoreStart->propertyCount()) { builder.addProperty(QByteArray("__qml_ignore__") + property.name(), QByteArray("void")); // Skip } else { diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h index 04731b1..75c2bb1 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h @@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE class QGL2PaintEngineExPrivate; -class QGLTextureGlyphCache : public QObject, public QTextureGlyphCache +class Q_OPENGL_EXPORT QGLTextureGlyphCache : public QObject, public QTextureGlyphCache { Q_OBJECT public: diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml new file mode 100644 index 0000000..9c46c3f --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml @@ -0,0 +1,10 @@ +import Qt.test 1.0 +import Qt 4.7 + +MyDeferredObject { + value: undefined // error is resolved before complete + objectProperty: undefined // immediate error + objectProperty2: QtObject { + Component.onCompleted: value = 10 + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp index 154ff4d..8a4605a 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp @@ -39,6 +39,8 @@ ** ****************************************************************************/ #include "testtypes.h" +#include <QWidget> +#include <QPlainTextEdit> class BaseExtensionObject : public QObject { @@ -80,6 +82,24 @@ public: DefaultPropertyExtensionObject(QObject *parent) : QObject(parent) {} }; +class QWidgetDeclarativeUI : public QObject +{ + Q_OBJECT + + Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged) + +signals: + void widthChanged(); + +public: + QWidgetDeclarativeUI(QObject *other) : QObject(other) { } + +public: + int width() const { return 0; } + void setWidth(int) { } +}; + + void registerTypes() { qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObject"); @@ -91,6 +111,9 @@ void registerTypes() qmlRegisterType<NumberAssignment>("Qt.test", 1,0, "NumberAssignment"); qmlRegisterExtendedType<DefaultPropertyExtendedObject, DefaultPropertyExtensionObject>("Qt.test", 1,0, "DefaultPropertyExtendedObject"); qmlRegisterType<OverrideDefaultPropertyObject>("Qt.test", 1,0, "OverrideDefaultPropertyObject"); + + qmlRegisterExtendedType<QWidget,QWidgetDeclarativeUI>("Qt.test",1,0,"QWidget"); + qmlRegisterType<QPlainTextEdit>("Qt.test",1,0,"QPlainTextEdit"); } #include "testtypes.moc" diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 97fced4..491a736 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -89,6 +89,7 @@ private slots: void contextPropertiesTriggerReeval(); void objectPropertiesTriggerReeval(); void deferredProperties(); + void deferredPropertiesErrors(); void extensionObjects(); void overrideExtensionProperties(); void attachedProperties(); @@ -133,6 +134,7 @@ private slots: void numberAssignment(); void bug1(); + void bug2(); void dynamicCreationCrash(); void regExpBug(); void nullObjectBinding(); @@ -543,6 +545,25 @@ void tst_qdeclarativeecmascript::deferredProperties() QCOMPARE(qmlObject->value(), 19); } +// Check errors on deferred properties are correctly emitted +void tst_qdeclarativeecmascript::deferredPropertiesErrors() +{ + QDeclarativeComponent component(&engine, TEST_FILE("deferredPropertiesErrors.qml")); + MyDeferredObject *object = + qobject_cast<MyDeferredObject *>(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->value(), 0); + QVERIFY(object->objectProperty() == 0); + QVERIFY(object->objectProperty2() == 0); + + QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QObject*"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + + qmlExecuteDeferred(object); + + delete object; +} + void tst_qdeclarativeecmascript::extensionObjects() { QDeclarativeComponent component(&engine, TEST_FILE("extensionObjects.qml")); @@ -1231,6 +1252,17 @@ void tst_qdeclarativeecmascript::bug1() delete object; } +void tst_qdeclarativeecmascript::bug2() +{ + QDeclarativeComponent component(&engine); + component.setData("import Qt.test 1.0;\nQPlainTextEdit { width: 100 }", QUrl()); + + QObject *object = component.create(); + QVERIFY(object != 0); + + delete object; +} + // Don't crash in createObject when the component has errors. void tst_qdeclarativeecmascript::dynamicCreationCrash() { diff --git a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp index ee320aa..b0db771 100644 --- a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp +++ b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp @@ -297,6 +297,8 @@ void tst_qdeclarativeengine::objectOwnership() { QObject o; QCOMPARE(QDeclarativeEngine::objectOwnership(&o), QDeclarativeEngine::CppOwnership); + QDeclarativeEngine::setObjectOwnership(&o, QDeclarativeEngine::CppOwnership); + QCOMPARE(QDeclarativeEngine::objectOwnership(&o), QDeclarativeEngine::CppOwnership); QDeclarativeEngine::setObjectOwnership(&o, QDeclarativeEngine::JavaScriptOwnership); QCOMPARE(QDeclarativeEngine::objectOwnership(&o), QDeclarativeEngine::JavaScriptOwnership); QDeclarativeEngine::setObjectOwnership(&o, QDeclarativeEngine::CppOwnership); diff --git a/tests/auto/declarative/qdeclarativeqt/data/formatting.qml b/tests/auto/declarative/qdeclarativeqt/data/formatting.qml index 59a15929..7f48639 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/formatting.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/formatting.qml @@ -16,4 +16,14 @@ QtObject { property string test8: Qt.formatDateTime(dateTime1) property string test9: Qt.formatDateTime(dateTime1, Qt.DefaultLocaleLongDate) property string test10: Qt.formatDateTime(dateTime1, "M/d/yy H:m:s a") + + // Error cases + property string test11: Qt.formatDate() + property string test12: Qt.formatDate(new Date, new Object) + + property string test13: Qt.formatTime() + property string test14: Qt.formatTime(new Date, new Object) + + property string test15: Qt.formatDateTime() + property string test16: Qt.formatDateTime(new Date, new Object) } diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp index f5d5926..7cbd8db 100644 --- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp +++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp @@ -398,6 +398,21 @@ void tst_qdeclarativeqt::consoleLog() void tst_qdeclarativeqt::formatting() { QDeclarativeComponent component(&engine, TEST_FILE("formatting.qml")); + + QString warning1 = component.url().toString() + ":22: Error: Qt.formatDate(): Invalid date format"; + QString warning2 = component.url().toString() + ":21: Error: Qt.formatDate(): Invalid arguments"; + QString warning3 = component.url().toString() + ":28: Error: Qt.formatDateTime(): Invalid datetime format"; + QString warning4 = component.url().toString() + ":27: Error: Qt.formatDateTime(): Invalid arguments"; + QString warning5 = component.url().toString() + ":25: Error: Qt.formatTime(): Invalid time format"; + QString warning6 = component.url().toString() + ":24: Error: Qt.formatTime(): Invalid arguments"; + + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning5)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning6)); + QObject *object = component.create(); QVERIFY(object != 0); |