aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/jsapi/qjsvalue.cpp2
-rw-r--r--src/qml/jsapi/qjsvalue_p.h3
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp26
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp6
-rw-r--r--src/qml/jsruntime/qv4script.cpp2
-rw-r--r--src/qml/jsruntime/qv4serialize.cpp1
-rw-r--r--src/qml/jsruntime/qv4value.cpp6
-rw-r--r--src/qml/jsruntime/qv4value_p.h10
-rw-r--r--src/qml/jsruntime/qv4variantobject.cpp2
-rw-r--r--src/qml/qml/qqmlboundsignal.cpp2
-rw-r--r--src/qml/qml/qqmlcomponent.cpp12
-rw-r--r--src/qml/qml/qqmljavascriptexpression.cpp6
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp10
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp16
-rw-r--r--src/qml/qml/v8/qv8engine.cpp3
-rw-r--r--src/qml/types/qqmldelegatemodel.cpp2
-rw-r--r--src/qml/types/qqmllistmodel.cpp6
-rw-r--r--src/qml/util/qqmladaptormodel.cpp2
-rw-r--r--src/quick/items/qquickloader.cpp6
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp30
20 files changed, 81 insertions, 72 deletions
diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp
index 908e9a4519..6b3d15df59 100644
--- a/src/qml/jsapi/qjsvalue.cpp
+++ b/src/qml/jsapi/qjsvalue.cpp
@@ -63,7 +63,7 @@ QV4::ReturnedValue QJSValuePrivate::getValue(QV4::ExecutionEngine *e)
this->engine = e;
else if (this->engine != e) {
qWarning("JSValue can't be reassigned to another engine.");
- return QV4::Value::emptyValue().asReturnedValue();
+ return QV4::Encode::undefined();
}
if (value.asString() == &string) {
value = QV4::Value::fromString(engine->newString(string.toQString()));
diff --git a/src/qml/jsapi/qjsvalue_p.h b/src/qml/jsapi/qjsvalue_p.h
index f99fed7c44..a0dfa010ab 100644
--- a/src/qml/jsapi/qjsvalue_p.h
+++ b/src/qml/jsapi/qjsvalue_p.h
@@ -72,8 +72,7 @@ public:
QJSValuePrivate(QV4::ExecutionEngine *engine, const QV4::Value &v)
: PersistentValuePrivate(v, engine)
{
- if (value.isEmpty())
- value = QV4::Value::undefinedValue();
+ Q_ASSERT(!value.isEmpty());
}
QJSValuePrivate(QV4::Object *o)
: PersistentValuePrivate(QV4::Value::fromObject(o))
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index d774014073..a779a41293 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -544,10 +544,10 @@ ReturnedValue QObjectWrapper::wrap(ExecutionEngine *engine, QObject *object)
Scope scope(engine);
- if (ddata->jsEngineId == engine->m_engineId && !ddata->jsWrapper.isEmpty()) {
+ if (ddata->jsEngineId == engine->m_engineId && !ddata->jsWrapper.isUndefined()) {
// We own the JS object
return ddata->jsWrapper.value().asReturnedValue();
- } else if (ddata->jsWrapper.isEmpty() &&
+ } else if (ddata->jsWrapper.isUndefined() &&
(ddata->jsEngineId == engine->m_engineId || // We own the QObject
ddata->jsEngineId == 0 || // No one owns the QObject
!ddata->hasTaintedV8Object)) { // Someone else has used the QObject, but it isn't tainted
@@ -566,7 +566,7 @@ ReturnedValue QObjectWrapper::wrap(ExecutionEngine *engine, QObject *object)
// If our tainted handle doesn't exist or has been collected, and there isn't
// a handle in the ddata, we can assume ownership of the ddata->v8object
- if (ddata->jsWrapper.isEmpty() && !alternateWrapper) {
+ if (ddata->jsWrapper.isUndefined() && !alternateWrapper) {
QV4::ScopedValue result(scope, create(engine, ddata, object));
ddata->jsWrapper = result;
ddata->jsEngineId = engine->m_engineId;
@@ -698,7 +698,7 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase
Scope scope(v4);
QV4::ScopedCallData callData(scope, argCount);
- callData->thisObject = This->thisObject.isEmpty() ? Value::fromObject(v4->globalObject) : This->thisObject.value();
+ callData->thisObject = This->thisObject.isUndefined() ? Value::fromObject(v4->globalObject) : This->thisObject.value();
for (int ii = 0; ii < argCount; ++ii) {
int type = argsTypes[ii + 1];
if (type == qMetaTypeId<QVariant>()) {
@@ -722,7 +722,7 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase
break;
case Compare: {
QObjectSlotDispatcher *connection = static_cast<QObjectSlotDispatcher*>(this_);
- if (connection->function.isEmpty()) {
+ if (connection->function.isUndefined()) {
*ret = false;
return;
}
@@ -744,8 +744,8 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase
if (slotIndexToDisconnect != -1) {
// This is a QObject function wrapper
- if (connection->thisObject.isEmpty() == thisObject->isEmpty() &&
- (connection->thisObject.isEmpty() || __qmljs_strict_equal(connection->thisObject, thisObject))) {
+ if (connection->thisObject.isUndefined() == thisObject->isUndefined() &&
+ (connection->thisObject.isUndefined() || __qmljs_strict_equal(connection->thisObject, thisObject))) {
QPair<QObject *, int> connectedFunctionData = extractQtMethod(connection->function.value().asFunctionObject());
if (connectedFunctionData.first == receiverToDisconnect &&
@@ -757,8 +757,8 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase
} else {
// This is a normal JS function
if (__qmljs_strict_equal(connection->function, function) &&
- connection->thisObject.isEmpty() == thisObject->isEmpty() &&
- (connection->thisObject.isEmpty() || __qmljs_strict_equal(connection->thisObject, thisObject))) {
+ connection->thisObject.isUndefined() == thisObject->isUndefined() &&
+ (connection->thisObject.isUndefined() || __qmljs_strict_equal(connection->thisObject, thisObject))) {
*ret = true;
return;
}
@@ -806,7 +806,7 @@ ReturnedValue QObjectWrapper::method_connect(SimpleCallContext *ctx)
if (!slot->function.value().asFunctionObject())
V4THROW_ERROR("Function.prototype.connect: target is not a function");
- if (!slot->thisObject.isEmpty() && !slot->thisObject.value().isObject())
+ if (!slot->thisObject.isUndefined() && !slot->thisObject.value().isObject())
V4THROW_ERROR("Function.prototype.connect: target this is not an object");
QObjectPrivate::connect(signalObject, signalIndex, slot, Qt::AutoConnection);
@@ -832,8 +832,8 @@ ReturnedValue QObjectWrapper::method_disconnect(SimpleCallContext *ctx)
if (signalIndex < 0 || signalObject->metaObject()->method(signalIndex).methodType() != QMetaMethod::Signal)
V4THROW_ERROR("Function.prototype.disconnect: this object is not a signal");
- QV4::Value functionValue = QV4::Value::emptyValue();
- QV4::Value functionThisValue = QV4::Value::emptyValue();
+ QV4::Value functionValue = QV4::Value::undefinedValue();
+ QV4::Value functionThisValue = QV4::Value::undefinedValue();
if (ctx->argumentCount == 1) {
functionValue = ctx->arguments[0];
@@ -845,7 +845,7 @@ ReturnedValue QObjectWrapper::method_disconnect(SimpleCallContext *ctx)
if (!functionValue.asFunctionObject())
V4THROW_ERROR("Function.prototype.disconnect: target is not a function");
- if (!functionThisValue.isEmpty() && !functionThisValue.isObject())
+ if (!functionThisValue.isUndefined() && !functionThisValue.isObject())
V4THROW_ERROR("Function.prototype.disconnect: target this is not an object");
QPair<QObject *, int> functionData = extractQtMethod(functionValue.asFunctionObject());
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 446ea9df3a..f440ade430 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -616,8 +616,9 @@ Returned<Object> *__qmljs_convert_to_object(ExecutionContext *ctx, const ValueRe
Returned<String> *__qmljs_convert_to_string(ExecutionContext *ctx, const ValueRef value)
{
switch (value->type()) {
- case Value::Undefined_Type:
case Value::Empty_Type:
+ Q_ASSERT(!"empty Value encountered");
+ case Value::Undefined_Type:
return ctx->engine->id_undefined->asReturned<String>();
case Value::Null_Type:
return ctx->engine->id_null->asReturned<String>();
@@ -970,7 +971,8 @@ ReturnedValue __qmljs_call_property(ExecutionContext *context, String *name, Cal
Scope scope(context);
Scoped<Object> baseObject(scope, callData->thisObject);
if (!baseObject) {
- if (callData->thisObject.isNullOrUndefined() || callData->thisObject.isEmpty()) {
+ Q_ASSERT(!callData->thisObject.isEmpty());
+ if (callData->thisObject.isNullOrUndefined()) {
QString message = QStringLiteral("Cannot call method '%1' of %2").arg(name->toQString()).arg(callData->thisObject.toQStringNoThrow());
context->throwTypeError(message);
}
diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp
index 7dd3bbeb66..fe61168d3c 100644
--- a/src/qml/jsruntime/qv4script.cpp
+++ b/src/qml/jsruntime/qv4script.cpp
@@ -221,7 +221,7 @@ ReturnedValue Script::run()
QV4::ExecutionEngine *engine = scope->engine;
QV4::Scope valueScope(engine);
- if (qml.isEmpty()) {
+ if (qml.isUndefined()) {
TemporaryAssignment<Function*> savedGlobalCode(engine->globalCode, vmFunction);
bool strict = scope->strictMode;
diff --git a/src/qml/jsruntime/qv4serialize.cpp b/src/qml/jsruntime/qv4serialize.cpp
index 35022acfd5..390c3382f2 100644
--- a/src/qml/jsruntime/qv4serialize.cpp
+++ b/src/qml/jsruntime/qv4serialize.cpp
@@ -153,6 +153,7 @@ void Serialize::serialize(QByteArray &data, const QV4::Value &v, QV8Engine *engi
QV4::Scope scope(v4);
if (v.isEmpty()) {
+ Q_ASSERT(!"Serialize: got empty value");
} else if (v.isUndefined()) {
push(data, valueheader(WorkerUndefined));
} else if (v.isNull()) {
diff --git a/src/qml/jsruntime/qv4value.cpp b/src/qml/jsruntime/qv4value.cpp
index 570ba9e82e..197b1c2ee5 100644
--- a/src/qml/jsruntime/qv4value.cpp
+++ b/src/qml/jsruntime/qv4value.cpp
@@ -107,8 +107,9 @@ double Value::toNumberImpl() const
QString Value::toQStringNoThrow() const
{
switch (type()) {
- case Value::Undefined_Type:
case Value::Empty_Type:
+ Q_ASSERT(!"empty Value encountered");
+ case Value::Undefined_Type:
return QStringLiteral("undefined");
case Value::Null_Type:
return QStringLiteral("null");
@@ -156,8 +157,9 @@ QString Value::toQStringNoThrow() const
QString Value::toQString() const
{
switch (type()) {
- case Value::Undefined_Type:
case Value::Empty_Type:
+ Q_ASSERT(!"empty Value encountered");
+ case Value::Undefined_Type:
return QStringLiteral("undefined");
case Value::Null_Type:
return QStringLiteral("null");
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h
index 6cefe13ae6..bfad395b3b 100644
--- a/src/qml/jsruntime/qv4value_p.h
+++ b/src/qml/jsruntime/qv4value_p.h
@@ -391,7 +391,7 @@ public:
~PersistentValue();
Value value() const {
- return d ? d->value : Value::emptyValue();
+ return d ? d->value : Value::undefinedValue();
}
ExecutionEngine *engine() {
@@ -403,7 +403,8 @@ public:
operator Value() const { return value(); }
- bool isEmpty() const { return !d || d->value.isEmpty(); }
+ bool isUndefined() const { return !d || d->value.isUndefined(); }
+ bool isNullOrUndefined() const { return !d || d->value.isNullOrUndefined(); }
void clear() {
*this = PersistentValue();
}
@@ -431,7 +432,7 @@ public:
~WeakValue();
Value value() const {
- return d ? d->value : Value::emptyValue();
+ return d ? d->value : Value::undefinedValue();
}
ExecutionEngine *engine() {
@@ -443,7 +444,8 @@ public:
operator Value() const { return value(); }
- bool isEmpty() const { return !d || d->value.isEmpty(); }
+ bool isUndefined() const { return !d || d->value.isUndefined(); }
+ bool isNullOrUndefined() const { return !d || d->value.isNullOrUndefined(); }
void clear() {
*this = WeakValue();
}
diff --git a/src/qml/jsruntime/qv4variantobject.cpp b/src/qml/jsruntime/qv4variantobject.cpp
index ed3342aa58..cea946b66b 100644
--- a/src/qml/jsruntime/qv4variantobject.cpp
+++ b/src/qml/jsruntime/qv4variantobject.cpp
@@ -86,7 +86,7 @@ QVariant VariantObject::toVariant(const QV4::Value &v)
}
if (v.isNull())
return QVariant(QMetaType::VoidStar, 0);
- assert (v.isUndefined() || v.isEmpty());
+ Q_ASSERT(v.isUndefined());
return QVariant();
}
diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp
index 36cbc39d40..3a0d58d87c 100644
--- a/src/qml/qml/qqmlboundsignal.cpp
+++ b/src/qml/qml/qqmlboundsignal.cpp
@@ -181,7 +181,7 @@ void QQmlBoundSignalExpression::evaluate(void **a)
m_v8function = evalFunction(context(), scopeObject(), expression,
m_fileName, m_line, &m_v8qmlscope);
- if (m_v8function.isEmpty() || m_v8function.value().isNull()) {
+ if (m_v8function.isUndefined() || m_v8function.value().isNull()) {
ep->dereferenceScarceResources();
return; // could not evaluate function. Not valid.
}
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index 149cbf2c49..623efb54b2 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -1206,7 +1206,7 @@ void QQmlComponent::createObject(QQmlV4Function *args)
Q_ASSERT(args);
QObject *parent = 0;
- QV4::Value valuemap = QV4::Value::emptyValue();
+ QV4::Value valuemap = QV4::Value::undefinedValue();
if (args->length() >= 1) {
if (QV4::QObjectWrapper *qobjectWrapper = (*args)[0].as<QV4::QObjectWrapper>())
@@ -1242,7 +1242,7 @@ void QQmlComponent::createObject(QQmlV4Function *args)
QV4::ScopedValue object(scope, QV4::QObjectWrapper::wrap(v4engine, rv));
Q_ASSERT(object->isObject());
- if (!valuemap.isEmpty()) {
+ if (!valuemap.isUndefined()) {
QQmlComponentExtension *e = componentExtension(v8engine);
QV4::Scoped<QV4::FunctionObject> f(scope, QV4::Script::evaluate(v4engine, QString::fromLatin1(INITIALPROPERTIES_SOURCE), args->qmlGlobal().asObject()));
QV4::ScopedCallData callData(scope, 2);
@@ -1330,7 +1330,7 @@ void QQmlComponent::incubateObject(QQmlV4Function *args)
Q_ASSERT(args);
QObject *parent = 0;
- QV4::Value valuemap = QV4::Value::emptyValue();
+ QV4::Value valuemap = QV4::Value::undefinedValue();
QQmlIncubator::IncubationMode mode = QQmlIncubator::Asynchronous;
if (args->length() >= 1) {
@@ -1364,7 +1364,7 @@ void QQmlComponent::incubateObject(QQmlV4Function *args)
QmlIncubatorObject *r = new (v4->memoryManager) QmlIncubatorObject(args->engine(), mode);
r->setPrototype(e->incubationProto.value().asObject());
- if (!valuemap.isEmpty()) {
+ if (!valuemap.isUndefined()) {
r->valuemap = valuemap;
r->qmlGlobal = args->qmlGlobal();
}
@@ -1390,7 +1390,7 @@ void QQmlComponentPrivate::initializeObjectWithInitialProperties(const QV4::Valu
QV4::ScopedValue object(scope, QV4::QObjectWrapper::wrap(v4engine, toCreate));
Q_ASSERT(object->asObject());
- if (!valuemap.isEmpty()) {
+ if (!valuemap.isUndefined()) {
QQmlComponentExtension *e = componentExtension(v8engine);
QV4::Scoped<QV4::FunctionObject> f(scope, QV4::Script::evaluate(QV8Engine::getV4(v8engine),
QString::fromLatin1(INITIALPROPERTIES_SOURCE), qmlGlobal.asObject()));
@@ -1492,7 +1492,7 @@ void QmlIncubatorObject::setInitialState(QObject *o)
{
QQmlComponent_setQmlParent(o, parent);
- if (!valuemap.isEmpty()) {
+ if (!valuemap.isUndefined()) {
QQmlComponentExtension *e = componentExtension(v8);
QV4::ExecutionEngine *v4 = QV8Engine::getV4(v8);
diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp
index d16d421ed2..5c3e61759a 100644
--- a/src/qml/qml/qqmljavascriptexpression.cpp
+++ b/src/qml/qml/qqmljavascriptexpression.cpp
@@ -135,10 +135,10 @@ QV4::ReturnedValue QQmlJavaScriptExpression::evaluate(QQmlContextData *context,
{
Q_ASSERT(context && context->engine);
- if (function.isEmpty() || function.isUndefined()) {
+ if (function.isUndefined()) {
if (isUndefined)
*isUndefined = true;
- return QV4::Value::emptyValue().asReturnedValue();
+ return QV4::Value::undefinedValue().asReturnedValue();
}
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context->engine);
@@ -187,7 +187,7 @@ QV4::ReturnedValue QQmlJavaScriptExpression::evaluate(QQmlContextData *context,
if (isUndefined)
*isUndefined = true;
if (!watcher.wasDeleted()) {
- if (!ex->isEmpty()) {
+ if (!ex->isUndefined()) {
delayedError()->setError(e);
} else {
if (hasDelayedError())
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index 6739143979..e3a6621ab4 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -71,7 +71,7 @@ QQmlVMEVariantQObjectPtr::~QQmlVMEVariantQObjectPtr()
void QQmlVMEVariantQObjectPtr::objectDestroyed(QObject *)
{
if (m_target && m_index >= 0) {
- if (m_isVar && m_target->varPropertiesInitialized && !m_target->varProperties.isEmpty()) {
+ if (m_isVar && m_target->varPropertiesInitialized && !m_target->varProperties.isUndefined()) {
// Set the var property to NULL
QV4::ArrayObject *a = m_target->varProperties.value().asArrayObject();
if (a)
@@ -966,13 +966,13 @@ QV4::ReturnedValue QQmlVMEMetaObject::method(int index)
{
if (!ctxt || !ctxt->isValid()) {
qWarning("QQmlVMEMetaObject: Internal error - attempted to evaluate a function in an invalid context");
- return QV4::Value::emptyValue().asReturnedValue();
+ return QV4::Value::undefinedValue().asReturnedValue();
}
if (!v8methods)
v8methods = new QV4::PersistentValue[metaData->methodCount];
- if (v8methods[index].isEmpty()) {
+ if (v8methods[index].isUndefined()) {
QQmlVMEMetaData::MethodData *data = metaData->methodData() + index;
const char *body = ((const char*)metaData) + data->bodyOffset;
@@ -994,7 +994,7 @@ QV4::ReturnedValue QQmlVMEMetaObject::readVarProperty(int id)
if (ensureVarPropertiesAllocated())
return varProperties.value().asObject()->getIndexed(id - firstVarPropertyIndex);
- return QV4::Value::emptyValue().asReturnedValue();
+ return QV4::Value::undefinedValue().asReturnedValue();
}
QVariant QQmlVMEMetaObject::readPropertyAsVariant(int id)
@@ -1208,7 +1208,7 @@ bool QQmlVMEMetaObject::ensureVarPropertiesAllocated()
// QObject ptr will not yet have been deleted (eg, waiting on deleteLater).
// In this situation, the varProperties handle will be (and should remain)
// empty.
- return !varProperties.isEmpty();
+ return !varProperties.isUndefined();
}
void QQmlVMEMetaObject::ensureQObjectWrapper()
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index bef943fd51..131fb1c51f 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -580,7 +580,7 @@ ReturnedValue NodePrototype::method_get_attributes(SimpleCallContext *ctx)
Value NodePrototype::getProto(ExecutionEngine *v4)
{
QQmlXMLHttpRequestData *d = xhrdata(v4->v8Engine);
- if (d->nodePrototype.isEmpty()) {
+ if (d->nodePrototype.isUndefined()) {
Object *p = new (v4->memoryManager) NodePrototype(v4);
d->nodePrototype = Value::fromObject(p);
v4->v8Engine->freezeObject(d->nodePrototype.value());
@@ -625,7 +625,7 @@ Value Node::create(QV8Engine *engine, NodeImpl *data)
Value Element::prototype(ExecutionEngine *engine)
{
QQmlXMLHttpRequestData *d = xhrdata(engine->v8Engine);
- if (d->elementPrototype.isEmpty()) {
+ if (d->elementPrototype.isUndefined()) {
Scope scope(engine);
Scoped<Object> p(scope, engine->newObject());
p->setPrototype(NodePrototype::getProto(engine).asObject());
@@ -639,7 +639,7 @@ Value Element::prototype(ExecutionEngine *engine)
Value Attr::prototype(ExecutionEngine *engine)
{
QQmlXMLHttpRequestData *d = xhrdata(engine->v8Engine);
- if (d->attrPrototype.isEmpty()) {
+ if (d->attrPrototype.isUndefined()) {
Scope scope(engine);
Scoped<Object> p(scope, engine->newObject());
p->setPrototype(NodePrototype::getProto(engine).asObject());
@@ -695,7 +695,7 @@ ReturnedValue CharacterData::method_length(SimpleCallContext *ctx)
Value CharacterData::prototype(ExecutionEngine *v4)
{
QQmlXMLHttpRequestData *d = xhrdata(v4->v8Engine);
- if (d->characterDataPrototype.isEmpty()) {
+ if (d->characterDataPrototype.isUndefined()) {
Scope scope(v4);
Scoped<Object> p(scope, v4->newObject());
p->setPrototype(NodePrototype::getProto(v4).asObject());
@@ -728,7 +728,7 @@ ReturnedValue Text::method_wholeText(SimpleCallContext *ctx)
Value Text::prototype(ExecutionEngine *v4)
{
QQmlXMLHttpRequestData *d = xhrdata(v4->v8Engine);
- if (d->textPrototype.isEmpty()) {
+ if (d->textPrototype.isUndefined()) {
Scope scope(v4);
Scoped<Object> p(scope, v4->newObject());
p->setPrototype(CharacterData::prototype(v4).asObject());
@@ -744,7 +744,7 @@ Value CDATA::prototype(ExecutionEngine *v4)
{
// ### why not just use TextProto???
QQmlXMLHttpRequestData *d = xhrdata(v4->v8Engine);
- if (d->cdataPrototype.isEmpty()) {
+ if (d->cdataPrototype.isUndefined()) {
Scope scope(v4);
Scoped<Object> p(scope, v4->newObject());
p->setPrototype(Text::prototype(v4).asObject());
@@ -757,7 +757,7 @@ Value CDATA::prototype(ExecutionEngine *v4)
Value Document::prototype(ExecutionEngine *v4)
{
QQmlXMLHttpRequestData *d = xhrdata(v4->v8Engine);
- if (d->documentPrototype.isEmpty()) {
+ if (d->documentPrototype.isUndefined()) {
Scope scope(v4);
Scoped<Object> p(scope, v4->newObject());
p->setPrototype(NodePrototype::getProto(v4).asObject());
@@ -1419,7 +1419,7 @@ void QQmlXMLHttpRequest::finished()
dispatchCallback(m_me);
Scope scope(v4);
- ScopedValue v(scope, Value::emptyValue());
+ ScopedValue v(scope, Value::undefinedValue());
setMe(v);
}
diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp
index b62d8c173d..73ad2807b5 100644
--- a/src/qml/qml/v8/qv8engine.cpp
+++ b/src/qml/qml/v8/qv8engine.cpp
@@ -119,8 +119,7 @@ QV8Engine::~QV8Engine()
QVariant QV8Engine::toVariant(const QV4::Value &value, int typeHint)
{
- if (value.isEmpty())
- return QVariant();
+ Q_ASSERT (!value.isEmpty());
if (QV4::VariantObject *v = value.as<QV4::VariantObject>())
return v->data;
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp
index b9f78da96e..c0b0b59f1d 100644
--- a/src/qml/types/qqmldelegatemodel.cpp
+++ b/src/qml/types/qqmldelegatemodel.cpp
@@ -2383,7 +2383,7 @@ QQmlV4Handle QQmlDelegateModelGroup::get(int index)
model->m_compositor.setFlags(it, 1, Compositor::CacheFlag);
}
- if (model->m_cacheMetaType->modelItemProto.isEmpty())
+ if (model->m_cacheMetaType->modelItemProto.isUndefined())
model->m_cacheMetaType->initializePrototype();
QV8Engine *v8 = model->m_cacheMetaType->v8Engine;
QV4::ExecutionEngine *v4 = QV8Engine::getV4(v8);
diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp
index 20d1211716..4ce5047c8f 100644
--- a/src/qml/types/qqmllistmodel.cpp
+++ b/src/qml/types/qqmllistmodel.cpp
@@ -464,7 +464,7 @@ void ListModel::set(int elementIndex, QV4::Object *object, QVector<int> *roles,
if (role.type == ListLayout::Role::VariantMap)
roleIndex = e->setVariantMapProperty(role, o, eng);
}
- } else if (propertyValue.isEmpty() || propertyValue.isUndefined() || propertyValue.isNull()) {
+ } else if (propertyValue.isUndefined() || propertyValue.isNull()) {
const ListLayout::Role *r = m_layout->getExistingRole(propertyName.getPointer());
if (r)
e->clearProperty(*r);
@@ -540,7 +540,7 @@ void ListModel::set(int elementIndex, QV4::Object *object, QV8Engine *eng)
if (role.type == ListLayout::Role::VariantMap)
e->setVariantMapFast(role, o, eng);
}
- } else if (propertyValue.isEmpty() || propertyValue.isUndefined() || propertyValue.isNull()) {
+ } else if (propertyValue.isUndefined() || propertyValue.isNull()) {
const ListLayout::Role *r = m_layout->getExistingRole(propertyName.getPointer());
if (r)
e->clearProperty(*r);
@@ -1198,7 +1198,7 @@ int ListElement::setJsProperty(const ListLayout::Role &role, const QV4::Value &d
} else if (role.type == ListLayout::Role::VariantMap) {
roleIndex = setVariantMapProperty(role, o, eng);
}
- } else if (d.isEmpty() || d.isUndefined() || d.isNull()) {
+ } else if (d.isUndefined() || d.isNull()) {
clearProperty(role);
}
diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp
index add422b8da..6c12d7310f 100644
--- a/src/qml/util/qqmladaptormodel.cpp
+++ b/src/qml/util/qqmladaptormodel.cpp
@@ -425,7 +425,7 @@ public:
QV4::ReturnedValue get()
{
- if (type->prototype.isEmpty()) {
+ if (type->prototype.isUndefined()) {
QQmlAdaptorModelEngineData * const data = engineData(v4->v8Engine);
type->initializeConstructor(data);
}
diff --git a/src/quick/items/qquickloader.cpp b/src/quick/items/qquickloader.cpp
index a24439cb19..ec71bd4e93 100644
--- a/src/quick/items/qquickloader.cpp
+++ b/src/quick/items/qquickloader.cpp
@@ -575,7 +575,7 @@ void QQuickLoader::setSource(QQmlV4Function *args)
d->clear();
QUrl sourceUrl = d->resolveSourceUrl(args);
- if (!ipv.isEmpty()) {
+ if (!ipv.isUndefined()) {
d->disposeInitialPropertyValues();
d->initialPropertyValues = ipv;
d->qmlGlobalForIpv = args->qmlGlobal();
@@ -639,7 +639,7 @@ void QQuickLoaderPrivate::setInitialState(QObject *obj)
itemContext = 0;
}
- if (initialPropertyValues.isEmpty())
+ if (initialPropertyValues.isUndefined())
return;
QQmlComponentPrivate *d = QQmlComponentPrivate::get(component);
@@ -933,7 +933,7 @@ QUrl QQuickLoaderPrivate::resolveSourceUrl(QQmlV4Function *args)
QV4::Value QQuickLoaderPrivate::extractInitialPropertyValues(QQmlV4Function *args, QObject *loader, bool *error)
{
- QV4::Value valuemap = QV4::Value::emptyValue();
+ QV4::Value valuemap = QV4::Value::undefinedValue();
if (args->length() >= 2) {
QV4::Value v = (*args)[1];
if (!v.isObject() || v.asArrayObject()) {
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 837b73dfa9..a42fdc9be3 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -2330,7 +2330,7 @@ static inline QV4::Value evaluate(QV8Engine *engine, const QV4::Value & o,
try {
QV4::Scoped<QV4::FunctionObject> function(scope, program.run());
if (!function)
- return QV4::Value::emptyValue();
+ return QV4::Value::undefinedValue();
QV4::ScopedCallData d(scope, 1);
d->args[0] = o;
d->thisObject = engine->global();
@@ -2339,7 +2339,7 @@ static inline QV4::Value evaluate(QV8Engine *engine, const QV4::Value & o,
} catch (QV4::Exception &e) {
e.accept(ctx);
}
- return QV4::Value::emptyValue();
+ return QV4::Value::undefinedValue();
}
#define EVALUATE_ERROR(source) evaluate_error(engine, object, source)
@@ -2424,7 +2424,7 @@ void tst_qqmlecmascript::callQtInvokables()
o->reset();
{
QV4::Value ret = EVALUATE("object.method_NoArgs_QPointF()");
- QVERIFY(!ret.isEmpty());
+ QVERIFY(!ret.isUndefined());
QCOMPARE(engine->toVariant(ret, -1), QVariant(QPointF(123, 4.5)));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 3);
@@ -3641,6 +3641,10 @@ void tst_qqmlecmascript::signalWithJSValueInVariant_twoEngines()
QTest::ignoreMessage(QtWarningMsg, "JSValue can't be reassigned to another engine.");
emit object->signalWithVariant(QVariant::fromValue(value));
+ if (expression == "undefined")
+ // if the engine is wrong, we return undefined to the other engine,
+ // making this one case pass
+ return;
QVERIFY(!object->property("pass").toBool());
}
@@ -3898,7 +3902,7 @@ void tst_qqmlecmascript::verifyContextLifetime(QQmlContextData *ctxt) {
foreach (const QV4::PersistentValue& qmlglobal, ctxt->importedScripts) {
QQmlContextData *scriptContext, *newContext;
- if (qmlglobal.isEmpty())
+ if (qmlglobal.isUndefined())
continue;
scriptContext = QV4::QmlContextWrapper::getContext(qmlglobal);
@@ -4992,11 +4996,11 @@ void tst_qqmlecmascript::propertyVarInheritance()
tmp = QV4::Value::fromReturnedValue(ccovmemo->vmeProperty(cco5->metaObject()->indexOfProperty("circ")));
ccoCanaryHandle = tmp;
tmp = QV4::Value::nullValue();
- QVERIFY(!icoCanaryHandle.isEmpty());
- QVERIFY(!ccoCanaryHandle.isEmpty());
+ QVERIFY(!icoCanaryHandle.isUndefined());
+ QVERIFY(!ccoCanaryHandle.isUndefined());
gc(engine);
- QVERIFY(!icoCanaryHandle.isEmpty());
- QVERIFY(!ccoCanaryHandle.isEmpty());
+ QVERIFY(!icoCanaryHandle.isUndefined());
+ QVERIFY(!ccoCanaryHandle.isUndefined());
}
// now we deassign the var prop, which should trigger collection of item subtrees.
QMetaObject::invokeMethod(object, "deassignCircular"); // cause deassignment and gc
@@ -5007,8 +5011,8 @@ void tst_qqmlecmascript::propertyVarInheritance()
QSKIP("This test does not work reliably with MSVC.");
#endif
#if !defined(Q_CC_CLANG)
- QVERIFY(icoCanaryHandle.isEmpty());
- QVERIFY(ccoCanaryHandle.isEmpty());
+ QVERIFY(icoCanaryHandle.isUndefined());
+ QVERIFY(ccoCanaryHandle.isUndefined());
#endif
delete object;
// since there are no parent vmemo's to keep implicit references alive, and the only handles
@@ -5036,9 +5040,9 @@ void tst_qqmlecmascript::propertyVarInheritance2()
QV4::Value tmp = QV4::Value::fromReturnedValue(QQmlVMEMetaObject::get(childObject)->vmeProperty(childObject->metaObject()->indexOfProperty("vp")));
childObjectVarArrayValueHandle = tmp;
tmp = QV4::Value::nullValue();
- QVERIFY(!childObjectVarArrayValueHandle.isEmpty());
+ QVERIFY(!childObjectVarArrayValueHandle.isUndefined());
gc(engine);
- QVERIFY(!childObjectVarArrayValueHandle.isEmpty()); // should not have been collected yet.
+ QVERIFY(!childObjectVarArrayValueHandle.isUndefined()); // should not have been collected yet.
QCOMPARE(childObject->property("vp").value<QObject*>(), rootObject);
QCOMPARE(childObject->property("textCanary").toInt(), 10);
}
@@ -5046,7 +5050,7 @@ void tst_qqmlecmascript::propertyVarInheritance2()
gc(engine);
// an equivalent for pragma GCC optimize is still work-in-progress for CLang, so this test will fail.
#if !defined(Q_CC_CLANG)
- QVERIFY(childObjectVarArrayValueHandle.isEmpty()); // should have been collected now.
+ QVERIFY(childObjectVarArrayValueHandle.isUndefined()); // should have been collected now.
#endif
delete object;
}