summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp17
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml10
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp20
-rw-r--r--tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/formatting.qml10
-rw-r--r--tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp15
6 files changed, 65 insertions, 9 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/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/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 97fced4..d0a2f7c 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();
@@ -543,6 +544,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"));
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);