summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Smith <msmith@trolltech.com>2009-05-08 13:06:58 (GMT)
committerMartin Smith <msmith@trolltech.com>2009-05-08 13:06:58 (GMT)
commitc75bf17bfac77b01fcbaf848542c81ba64988e28 (patch)
tree7a022950bba4783d4dd5122cc8957038872bf9dc
parent94d44efa7066961211a4d2824e093ba71483b4ed (diff)
parent7d67d5c24ce3e707c1bb9bc6f181765cccc4090d (diff)
downloadQt-c75bf17bfac77b01fcbaf848542c81ba64988e28.zip
Qt-c75bf17bfac77b01fcbaf848542c81ba64988e28.tar.gz
Qt-c75bf17bfac77b01fcbaf848542c81ba64988e28.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--src/declarative/canvas/qsimplecanvas.h12
-rw-r--r--src/declarative/qml/qmldom.cpp17
-rw-r--r--src/declarative/qml/qmldom.h3
-rw-r--r--src/declarative/qml/qmldom_p.h3
-rw-r--r--src/declarative/qml/qmlscriptparser.cpp15
-rw-r--r--src/declarative/qml/qmlscriptparser_p.h18
-rw-r--r--tests/auto/declarative/qmlparser/tst_qmlparser.cpp9
7 files changed, 63 insertions, 14 deletions
diff --git a/src/declarative/canvas/qsimplecanvas.h b/src/declarative/canvas/qsimplecanvas.h
index 20dab28..d57ada4 100644
--- a/src/declarative/canvas/qsimplecanvas.h
+++ b/src/declarative/canvas/qsimplecanvas.h
@@ -48,12 +48,12 @@
#include <QtGui/qmatrix4x4.h>
#endif
-#include <QTransform>
-#include <QPainter>
-#include <QDebug>
-#include <QWidget>
-#include <QImage>
-#include <QKeyEvent>
+#include <QtGui/QTransform>
+#include <QtGui/QPainter>
+#include <QtCore/QDebug>
+#include <QtGui/QWidget>
+#include <QtGui/QImage>
+#include <QtGui/QKeyEvent>
QT_BEGIN_HEADER
diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp
index a31be81..4e754a3 100644
--- a/src/declarative/qml/qmldom.cpp
+++ b/src/declarative/qml/qmldom.cpp
@@ -143,7 +143,15 @@ int QmlDomDocument::version() const
}
/*!
- Loads a QmlDomDocument from \a data. \a data should be valid QML XML
+ Return the URIs listed by "import <dir>" in the qml.
+*/
+QList<QUrl> QmlDomDocument::imports() const
+{
+ return d->imports;
+}
+
+/*!
+ Loads a QmlDomDocument from \a data. \a data should be valid QML
data. On success, true is returned. If the \a data is malformed, false
is returned and QmlDomDocument::loadError() contains an error description.
@@ -153,11 +161,12 @@ bool QmlDomDocument::load(QmlEngine *engine, const QByteArray &data, const QUrl
{
Q_UNUSED(engine);
d->errors.clear();
+ d->imports.clear();
QmlCompiledComponent component;
QmlCompiler compiler;
- QmlCompositeTypeData *td = ((QmlEnginePrivate *)QmlEnginePrivate::get(engine))->typeManager.getImmediate(data, url);;
+ QmlCompositeTypeData *td = ((QmlEnginePrivate *)QmlEnginePrivate::get(engine))->typeManager.getImmediate(data, url);
if(td->status == QmlCompositeTypeData::Error) {
d->errors = td->errors;
@@ -179,6 +188,10 @@ bool QmlDomDocument::load(QmlEngine *engine, const QByteArray &data, const QUrl
return false;
}
+ for (int i = 0; i < td->data.imports().size(); ++i) {
+ d->imports += QUrl(td->data.imports().at(i).uri);
+ }
+
if (td->data.tree()) {
td->data.tree()->dump();
d->root = td->data.tree();
diff --git a/src/declarative/qml/qmldom.h b/src/declarative/qml/qmldom.h
index f90fb08..8b503fa 100644
--- a/src/declarative/qml/qmldom.h
+++ b/src/declarative/qml/qmldom.h
@@ -71,7 +71,8 @@ public:
QmlDomDocument &operator=(const QmlDomDocument &);
int version() const;
-
+ QList<QUrl> imports() const;
+
QList<QmlError> errors() const;
bool load(QmlEngine *, const QByteArray &, const QUrl & = QUrl());
QByteArray save() const;
diff --git a/src/declarative/qml/qmldom_p.h b/src/declarative/qml/qmldom_p.h
index 4c3ca44..74edd47 100644
--- a/src/declarative/qml/qmldom_p.h
+++ b/src/declarative/qml/qmldom_p.h
@@ -42,6 +42,8 @@
#ifndef QMLDOM_P_H
#define QMLDOM_P_H
+#include <QtCore/QtGlobal>
+
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -58,6 +60,7 @@ public:
~QmlDomDocumentPrivate();
QList<QmlError> errors;
+ QList<QUrl> imports;
QmlParser::Object *root;
};
diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp
index 4385601..8506933 100644
--- a/src/declarative/qml/qmlscriptparser.cpp
+++ b/src/declarative/qml/qmlscriptparser.cpp
@@ -362,6 +362,16 @@ bool ProcessAST::visit(AST::UiImport *node)
{
QString fileName = node->fileName->asString();
_parser->addNamespacePath(fileName);
+
+ AST::SourceLocation startLoc = node->importToken;
+ AST::SourceLocation endLoc = node->semicolonToken;
+
+ QmlScriptParser::Import import;
+ import.location = location(startLoc, endLoc);
+ import.uri = fileName;
+
+ _parser->_imports << import;
+
return false;
}
@@ -686,6 +696,11 @@ Object *QmlScriptParser::tree() const
return root;
}
+QList<QmlScriptParser::Import> QmlScriptParser::imports() const
+{
+ return _imports;
+}
+
QList<QmlError> QmlScriptParser::errors() const
{
return _errors;
diff --git a/src/declarative/qml/qmlscriptparser_p.h b/src/declarative/qml/qmlscriptparser_p.h
index 4155bba..8a5466f 100644
--- a/src/declarative/qml/qmlscriptparser_p.h
+++ b/src/declarative/qml/qmlscriptparser_p.h
@@ -4,22 +4,28 @@
#include <QtCore/QList>
#include <QtCore/QUrl>
#include <QtDeclarative/qmlerror.h>
-#include <qml.h>
+#include "qmlparser_p.h"
+
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-namespace QmlParser {
- class Object;
-}
-
class QByteArray;
class QmlScriptParser
{
public:
+ class Import
+ {
+ public:
+ Import() {}
+
+ QString uri;
+ QmlParser::LocationSpan location;
+ };
+
QmlScriptParser();
~QmlScriptParser();
@@ -29,6 +35,7 @@ public:
QStringList types() const;
QmlParser::Object *tree() const;
+ QList<Import> imports() const;
void clear();
@@ -48,6 +55,7 @@ public:
QMap<QString,QString> _nameSpacePaths;
QmlParser::Object *root;
+ QList<Import> _imports;
QStringList _typeNames;
QString _scriptFile;
};
diff --git a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
index 96f6f4f..efd45d3 100644
--- a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
+++ b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
@@ -156,6 +156,9 @@ private slots:
//void cannotAssignBindingToSignal();
void assignObjectToSignal();
+ // regression tests for crashes
+ void crash1();
+
private:
QmlEngine engine;
};
@@ -439,6 +442,12 @@ void tst_qmlparser::assignObjectToSignal()
emit object->basicSignal();
}
+void tst_qmlparser::crash1()
+{
+ QmlComponent component(&engine, "Component {}");
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+}
+
QTEST_MAIN(tst_qmlparser)
#include "tst_qmlparser.moc"