diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-04-30 05:22:33 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-04-30 05:22:33 (GMT) |
commit | 500474fcd985893da0b675e24298ac98c29f8a76 (patch) | |
tree | bcd9dde70fb1d896f536316634f4ad3f3cc528c8 /src | |
parent | f7bf3edaec8fe4306506cb385eed62eed2e82c9a (diff) | |
download | Qt-500474fcd985893da0b675e24298ac98c29f8a76.zip Qt-500474fcd985893da0b675e24298ac98c29f8a76.tar.gz Qt-500474fcd985893da0b675e24298ac98c29f8a76.tar.bz2 |
Fix crash in QmlDomDocument::load()
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/qml/qmlcompositetypemanager_p.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmldom.cpp | 20 |
2 files changed, 19 insertions, 3 deletions
diff --git a/src/declarative/qml/qmlcompositetypemanager_p.h b/src/declarative/qml/qmlcompositetypemanager_p.h index ffa4fda..bc86fcf 100644 --- a/src/declarative/qml/qmlcompositetypemanager_p.h +++ b/src/declarative/qml/qmlcompositetypemanager_p.h @@ -52,6 +52,7 @@ class QmlEngine; class QmlCompiledComponent; class QmlComponentPrivate; class QmlComponent; +class QmlDomDocument; struct QmlCompositeTypeData : public QmlRefCount { QmlCompositeTypeData(); @@ -98,6 +99,7 @@ struct QmlCompositeTypeData : public QmlRefCount private: friend class QmlCompositeTypeManager; friend class QmlCompiler; + friend class QmlDomDocument; QmlScriptParser data; QList<QmlComponentPrivate *> waiters; diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp index 72c1c76..4e8e1f7 100644 --- a/src/declarative/qml/qmldom.cpp +++ b/src/declarative/qml/qmldom.cpp @@ -42,6 +42,7 @@ #include "qmldom.h" #include "qmldom_p.h" #include "private/qmlcompiler_p.h" +#include "private/qmlengine_p.h" #include "qmlcompiledcomponent_p.h" #include <QtCore/qbytearray.h> #include <QtCore/qstring.h> @@ -159,15 +160,28 @@ bool QmlDomDocument::load(QmlEngine *engine, const QByteArray &data) QmlCompiledComponent component; QmlCompiler compiler; - // ### -// compiler.compile(engine, parser, &component); + + QmlCompositeTypeData *td = ((QmlEnginePrivate *)QmlEnginePrivate::get(engine))->typeManager.getImmediate(data, QUrl());; + + if(td->status == QmlCompositeTypeData::Error) { + d->error = td->errorDescription; + td->release(); + return false; + } else if(td->status == QmlCompositeTypeData::Waiting) { + d->error = QLatin1String("QmlDomDocument supports local types only"); + td->release(); + return false; + } + + compiler.compile(engine, td, &component); if (compiler.isError()) { d->error = compiler.errorDescription(); + td->release(); return false; } - if (parser.tree()) { + if (td->data.tree()) { component.dump(0, parser.tree()); d->root = parser.tree(); d->root->addref(); |