summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/qml/qmlcompiler.cpp4
-rw-r--r--src/declarative/qml/qmlcomponent.h3
-rw-r--r--src/declarative/qml/qmlengine.cpp75
3 files changed, 46 insertions, 36 deletions
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 2cb44a3..9000339 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -2044,12 +2044,12 @@ bool QmlCompiler::checkDynamicMeta(QmlParser::Object *obj)
if (prop.isDefaultProperty) {
if (seenDefaultProperty)
- COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","Duplicate default property"));
+ COMPILE_EXCEPTION(&prop, qApp->translate("QmlCompiler","Duplicate default property"));
seenDefaultProperty = true;
}
if (propNames.contains(prop.name))
- COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","Duplicate property name"));
+ COMPILE_EXCEPTION(&prop, qApp->translate("QmlCompiler","Duplicate property name"));
propNames.insert(prop.name);
}
diff --git a/src/declarative/qml/qmlcomponent.h b/src/declarative/qml/qmlcomponent.h
index 835bdc5..0abb58f 100644
--- a/src/declarative/qml/qmlcomponent.h
+++ b/src/declarative/qml/qmlcomponent.h
@@ -67,6 +67,9 @@ class Q_DECLARATIVE_EXPORT QmlComponent : public QObject
Q_PROPERTY(bool isReady READ isReady NOTIFY statusChanged)
Q_PROPERTY(bool isError READ isError NOTIFY statusChanged)
Q_PROPERTY(bool isLoading READ isLoading NOTIFY statusChanged)
+ Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
+ Q_PROPERTY(QUrl url READ url CONSTANT)
public:
QmlComponent(QObject *parent = 0);
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index 1483c8c..9abd216 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -572,23 +572,23 @@ QmlContext *QmlEnginePrivate::getContext(QScriptContext *ctxt)
QScriptValue QmlEnginePrivate::createComponent(QScriptContext *ctxt,
QScriptEngine *engine)
{
- QmlComponent* c;
-
QmlEnginePrivate *activeEnginePriv =
static_cast<QmlScriptEngine*>(engine)->p;
QmlEngine* activeEngine = activeEnginePriv->q_func();
QmlContext* context = activeEnginePriv->getContext(ctxt);
+ Q_ASSERT(context);
if(ctxt->argumentCount() != 1) {
- c = new QmlComponent(activeEngine);
+ return engine->nullValue();
}else{
- QUrl url = QUrl(context->resolvedUrl(ctxt->argument(0).toString()));
- if(!url.isValid())
- url = QUrl(ctxt->argument(0).toString());
- c = new QmlComponent(activeEngine, url, activeEngine);
+ QString arg = ctxt->argument(0).toString();
+ if (arg.isEmpty())
+ return engine->nullValue();
+ QUrl url = QUrl(context->resolvedUrl(arg));
+ QmlComponent *c = new QmlComponent(activeEngine, url, activeEngine);
+ c->setCreationContext(context);
+ return activeEnginePriv->objectClass->newQObject(c, qMetaTypeId<QmlComponent*>());
}
- c->setCreationContext(context);
- return engine->newQObject(c);
}
QScriptValue QmlEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngine *engine)
@@ -597,57 +597,64 @@ QScriptValue QmlEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngi
static_cast<QmlScriptEngine*>(engine)->p;
QmlEngine* activeEngine = activeEnginePriv->q_func();
- if(ctxt->argumentCount() < 2)
+ if(ctxt->argumentCount() < 2 || ctxt->argumentCount() > 3)
return engine->nullValue();
+ QmlContext* context = activeEnginePriv->getContext(ctxt);
+ Q_ASSERT(context);
+
QString qml = ctxt->argument(0).toString();
+ if (qml.isEmpty())
+ return engine->nullValue();
+
QUrl url;
if(ctxt->argumentCount() > 2)
url = QUrl(ctxt->argument(2).toString());
+
+ if (url.isValid() && url.isRelative())
+ url = context->resolvedUrl(url);
+
QObject *parentArg = activeEnginePriv->objectClass->toQObject(ctxt->argument(1));
- QmlContext *qmlCtxt = qmlContext(parentArg);
- if(!parentArg || !qmlCtxt){
- //TODO: Could use a qmlInfo() like function for script functions
- qWarning() << "createQmlObject called with invalid parent object";
+ if(!parentArg)
return engine->nullValue();
- }
- if (url.isEmpty()) {
- url = qmlCtxt->resolvedUrl(QUrl(QLatin1String("<Unknown File>")));
- } else {
- url = qmlCtxt->resolvedUrl(url);
- }
QmlComponent component(activeEngine, qml.toUtf8(), url);
if(component.isError()) {
QList<QmlError> errors = component.errors();
- qWarning() <<"QmlEngine::createQmlObject():";
+ qWarning().nospace() << "QmlEngine::createQmlObject():";
foreach (const QmlError &error, errors)
- qWarning() << " " << error;
+ qWarning().nospace() << " " << error;
+
+ return engine->nullValue();
+ }
+
+ if (!component.isReady()) {
+ qWarning().nospace() << "QmlEngine::createQmlObject(): Component is not ready";
return engine->nullValue();
}
- QObject *obj = component.create(qmlCtxt);
+ QObject *obj = component.create(context);
if(component.isError()) {
QList<QmlError> errors = component.errors();
- qWarning() <<"QmlEngine::createQmlObject():";
+ qWarning().nospace() << "QmlEngine::createQmlObject():";
foreach (const QmlError &error, errors)
- qWarning() << " " << error;
+ qWarning().nospace() << " " << error;
return engine->nullValue();
}
- if(obj) {
- obj->setParent(parentArg);
- QGraphicsObject* gobj = qobject_cast<QGraphicsObject*>(obj);
- QGraphicsObject* gparent = qobject_cast<QGraphicsObject*>(parentArg);
- if(gobj && gparent)
- gobj->setParentItem(gparent);
- return qmlScriptObject(obj, activeEngine);
- }
- return engine->nullValue();
+ Q_ASSERT(obj);
+
+ obj->setParent(parentArg);
+ QGraphicsObject* gobj = qobject_cast<QGraphicsObject*>(obj);
+ QGraphicsObject* gparent = qobject_cast<QGraphicsObject*>(parentArg);
+ if(gobj && gparent)
+ gobj->setParentItem(gparent);
+
+ return qmlScriptObject(obj, activeEngine);
}
QScriptValue QmlEnginePrivate::vector(QScriptContext *ctxt, QScriptEngine *engine)