aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/imports/localstorage/plugin.cpp3
-rw-r--r--src/imports/statemachine/signaltransition.cpp5
-rw-r--r--src/qml/jsruntime/qv4arraydata.cpp8
-rw-r--r--src/qml/jsruntime/qv4arraydata_p.h4
-rw-r--r--src/qml/jsruntime/qv4identifier_p.h12
-rw-r--r--src/qml/jsruntime/qv4managed_p.h16
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp10
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp9
-rw-r--r--src/qml/jsruntime/qv4scopedvalue_p.h10
-rw-r--r--src/qml/jsruntime/qv4sequenceobject.cpp2
-rw-r--r--src/qml/jsruntime/qv4variantobject.cpp4
-rw-r--r--src/qml/qml/qqml.h4
-rw-r--r--src/qml/qml/qqmlbinding.cpp3
-rw-r--r--src/qml/qml/qqmlcomponent.cpp6
-rw-r--r--src/qml/qml/qqmlcontextwrapper.cpp16
-rw-r--r--src/qml/qml/qqmllistwrapper.cpp24
-rw-r--r--src/qml/qml/qqmllocale_p.h3
-rw-r--r--src/qml/qml/qqmltypewrapper.cpp19
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp27
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp28
-rw-r--r--src/qml/types/qqmldelegatemodel.cpp13
-rw-r--r--src/quick/items/context2d/qquickcanvasitem.cpp12
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp12
-rw-r--r--src/quick/items/qquickborderimage.cpp8
-rw-r--r--src/quick/items/qquickimagebase_p_p.h1
-rw-r--r--src/quick/items/qquickitem.cpp7
-rw-r--r--src/quick/items/qquickitemview.cpp6
-rw-r--r--src/quick/items/qquickpathview.cpp6
-rw-r--r--src/quick/items/qquickrepeater.cpp6
-rw-r--r--src/quick/items/qquicktextcontrol.cpp28
-rw-r--r--src/quick/items/qquicktextedit_p_p.h2
-rw-r--r--tests/auto/quick/qquickgridview/tst_qquickgridview.cpp29
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp29
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp28
-rw-r--r--tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp28
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp21
-rw-r--r--tests/auto/quick/touchmouse/data/twosiblingitems.qml24
-rw-r--r--tests/auto/quick/touchmouse/tst_touchmouse.cpp83
38 files changed, 383 insertions, 173 deletions
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp
index f87bee55ec..8b90f5a685 100644
--- a/src/imports/localstorage/plugin.cpp
+++ b/src/imports/localstorage/plugin.cpp
@@ -234,7 +234,8 @@ static ReturnedValue qmlsqldatabase_rows_index(QQmlSqlDatabaseWrapper *r, Execut
ReturnedValue QQmlSqlDatabaseWrapper::getIndexed(Managed *m, uint index, bool *hasProperty)
{
QV4::Scope scope(m->engine());
- QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, m->as<QQmlSqlDatabaseWrapper>());
+ Q_ASSERT(m->as<QQmlSqlDatabaseWrapper>());
+ QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, static_cast<QQmlSqlDatabaseWrapper *>(m));
if (!r || r->d()->type != QQmlSqlDatabaseWrapper::Rows)
return Object::getIndexed(m, index, hasProperty);
diff --git a/src/imports/statemachine/signaltransition.cpp b/src/imports/statemachine/signaltransition.cpp
index eb842914a1..37edd6eb87 100644
--- a/src/imports/statemachine/signaltransition.cpp
+++ b/src/imports/statemachine/signaltransition.cpp
@@ -91,10 +91,7 @@ void SignalTransition::setSignal(const QJSValue &signal)
QV4::ExecutionEngine *jsEngine = QV8Engine::getV4(QQmlEngine::contextForObject(this)->engine());
QV4::Scope scope(jsEngine);
- QV4::Scoped<QV4::FunctionObject> function(scope, QJSValuePrivate::get(m_signal)->getValue(jsEngine));
- Q_ASSERT(function);
-
- QV4::Scoped<QV4::QObjectMethod> qobjectSignal(scope, function->as<QV4::QObjectMethod>());
+ QV4::Scoped<QV4::QObjectMethod> qobjectSignal(scope, QJSValuePrivate::get(m_signal)->getValue(jsEngine));
Q_ASSERT(qobjectSignal);
QObject *sender = qobjectSignal->object();
diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp
index 3235a116ee..35bd6e5501 100644
--- a/src/qml/jsruntime/qv4arraydata.cpp
+++ b/src/qml/jsruntime/qv4arraydata.cpp
@@ -104,6 +104,8 @@ void ArrayData::realloc(Object *o, Type newType, uint requested, bool enforceAtt
if (requested <= d->alloc() && newType == d->type() && hasAttrs == enforceAttributes)
return;
+ if (alloc < d->alloc())
+ alloc = d->alloc();
if (d->type() < Sparse) {
offset = static_cast<SimpleArrayData *>(d)->d()->offset;
@@ -569,21 +571,21 @@ bool SparseArrayData::putArray(Object *o, uint index, Value *values, uint n)
uint ArrayData::append(Object *obj, ArrayObject *otherObj, uint n)
{
- Q_ASSERT(!obj->arrayData()->hasAttributes());
+ Q_ASSERT(!obj->arrayData() || !obj->arrayData()->hasAttributes());
if (!n)
return obj->getLength();
ArrayData *other = otherObj->arrayData();
- if (other->isSparse())
+ if (other && other->isSparse())
obj->initSparseArray();
else
obj->arrayCreate();
uint oldSize = obj->getLength();
- if (other->isSparse()) {
+ if (other && other->isSparse()) {
SparseArrayData *os = static_cast<SparseArrayData *>(other);
if (otherObj->hasAccessorProperty() && other->hasAttributes()) {
Scope scope(obj->engine());
diff --git a/src/qml/jsruntime/qv4arraydata_p.h b/src/qml/jsruntime/qv4arraydata_p.h
index c2deb3e385..b69d200665 100644
--- a/src/qml/jsruntime/qv4arraydata_p.h
+++ b/src/qml/jsruntime/qv4arraydata_p.h
@@ -113,14 +113,14 @@ struct Q_QML_EXPORT ArrayData : public Managed
Value *arrayData() { return &d()->arrayData[0]; }
const ArrayVTable *vtable() const { return reinterpret_cast<const ArrayVTable *>(internalClass()->vtable); }
- bool isSparse() const { return this && type() == Sparse; }
+ bool isSparse() const { return type() == Sparse; }
uint length() const {
return vtable()->length(this);
}
bool hasAttributes() const {
- return this && attrs();
+ return attrs();
}
PropertyAttributes attributes(int i) const {
Q_ASSERT(this);
diff --git a/src/qml/jsruntime/qv4identifier_p.h b/src/qml/jsruntime/qv4identifier_p.h
index 9ca6714b90..afed5c646f 100644
--- a/src/qml/jsruntime/qv4identifier_p.h
+++ b/src/qml/jsruntime/qv4identifier_p.h
@@ -56,9 +56,9 @@ struct IdentifierHashEntry {
int value;
void *pointer;
};
- int get(int *) const { return this ? value : -1; }
- bool get(bool *) const { return this != 0; }
- void *get(void **) const { return this ? pointer : 0; }
+ static int get(const IdentifierHashEntry *This, int *) { return This ? This->value : -1; }
+ static bool get(const IdentifierHashEntry *This, bool *) { return This != 0; }
+ static void *get(const IdentifierHashEntry *This, void **) { return This ? This->pointer : 0; }
};
struct IdentifierHashData
@@ -181,13 +181,13 @@ void IdentifierHash<T>::add(const QString &str, const T &value)
template<typename T>
inline T IdentifierHash<T>::value(const QString &str) const
{
- return lookup(str)->get((T*)0);
+ return IdentifierHashEntry::get(lookup(str), (T*)0);
}
template<typename T>
inline T IdentifierHash<T>::value(String *str) const
{
- return lookup(str)->get((T*)0);
+ return IdentifierHashEntry::get(lookup(str), (T*)0);
}
@@ -197,7 +197,7 @@ QString IdentifierHash<T>::findId(T value) const
IdentifierHashEntry *e = d->entries;
IdentifierHashEntry *end = e + d->alloc;
while (e < end) {
- if (e->identifier && e->get((T*)0) == value)
+ if (e->identifier && IdentifierHashEntry::get(e, (T*)0) == value)
return e->identifier->string;
++e;
}
diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h
index 636c89c5e4..c062ec4f5b 100644
--- a/src/qml/jsruntime/qv4managed_p.h
+++ b/src/qml/jsruntime/qv4managed_p.h
@@ -269,9 +269,7 @@ public:
template <typename T>
T *as() {
- // ### FIXME:
- if (!this || !internalClass())
- return 0;
+ Q_ASSERT(internalClass());
#if !defined(QT_NO_QOBJECT_CHECK)
static_cast<T *>(this)->qt_check_for_QMANAGED_macro(static_cast<T *>(this));
#endif
@@ -285,9 +283,7 @@ public:
}
template <typename T>
const T *as() const {
- // ### FIXME:
- if (!this)
- return 0;
+ Q_ASSERT(internalClass());
#if !defined(QT_NO_QOBJECT_CHECK)
static_cast<T *>(this)->qt_check_for_QMANAGED_macro(static_cast<T *>(const_cast<Managed *>(this)));
#endif
@@ -362,23 +358,23 @@ inline Managed *value_cast(const Value &v) {
template<typename T>
inline T *managed_cast(Managed *m)
{
- return m->as<T>();
+ return m ? m->as<T>() : 0;
}
template<>
inline String *managed_cast(Managed *m)
{
- return m->asString();
+ return m ? m->asString() : 0;
}
template<>
inline Object *managed_cast(Managed *m)
{
- return m->asObject();
+ return m ? m->asObject() : 0;
}
template<>
inline FunctionObject *managed_cast(Managed *m)
{
- return m->asFunctionObject();
+ return m ? m->asFunctionObject() : 0;
}
}
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index 32379f7f1e..f2c30e618f 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -650,9 +650,13 @@ void QObjectWrapper::setProperty(ExecutionContext *ctx, int propertyIndex, const
bool QObjectWrapper::isEqualTo(Managed *a, Managed *b)
{
- QV4::QObjectWrapper *qobjectWrapper = a->as<QV4::QObjectWrapper>();
- if (QV4::QmlTypeWrapper *qmlTypeWrapper = b->asObject()->as<QV4::QmlTypeWrapper>())
- return qmlTypeWrapper->toVariant().value<QObject*>() == qobjectWrapper->object();
+ Q_ASSERT(a->as<QV4::QObjectWrapper>());
+ QV4::QObjectWrapper *qobjectWrapper = static_cast<QV4::QObjectWrapper *>(a);
+ QV4::Object *o = b->asObject();
+ if (o) {
+ if (QV4::QmlTypeWrapper *qmlTypeWrapper = o->as<QV4::QmlTypeWrapper>())
+ return qmlTypeWrapper->toVariant().value<QObject*>() == qobjectWrapper->object();
+ }
return false;
}
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 048ff935bf..f72f25bd58 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -1276,7 +1276,8 @@ ReturnedValue Runtime::regexpLiteral(ExecutionContext *ctx, int id)
ReturnedValue Runtime::getQmlIdArray(NoThrowContext *ctx)
{
- return ctx->engine()->qmlContextObject()->getPointer()->as<QmlContextWrapper>()->idObjectsArray();
+ Q_ASSERT(ctx->engine()->qmlContextObject()->getPointer()->as<QmlContextWrapper>());
+ return static_cast<QmlContextWrapper *>(ctx->engine()->qmlContextObject()->getPointer())->idObjectsArray();
}
ReturnedValue Runtime::getQmlContextObject(NoThrowContext *ctx)
@@ -1290,7 +1291,7 @@ ReturnedValue Runtime::getQmlContextObject(NoThrowContext *ctx)
ReturnedValue Runtime::getQmlScopeObject(NoThrowContext *ctx)
{
Scope scope(ctx);
- QV4::Scoped<QmlContextWrapper> c(scope, ctx->engine()->qmlContextObject()->getPointer()->as<QmlContextWrapper>());
+ QV4::Scoped<QmlContextWrapper> c(scope, ctx->engine()->qmlContextObject(), Scoped<QmlContextWrapper>::Cast);
return QObjectWrapper::wrap(ctx->d()->engine, c->getScopeObject());
}
@@ -1308,7 +1309,7 @@ ReturnedValue Runtime::getQmlQObjectProperty(ExecutionContext *ctx, const ValueR
QV4::ReturnedValue Runtime::getQmlAttachedProperty(ExecutionContext *ctx, int attachedPropertiesId, int propertyIndex)
{
Scope scope(ctx);
- QV4::Scoped<QmlContextWrapper> c(scope, ctx->engine()->qmlContextObject()->getPointer()->as<QmlContextWrapper>());
+ QV4::Scoped<QmlContextWrapper> c(scope, ctx->engine()->qmlContextObject(), Scoped<QmlContextWrapper>::Cast);
QObject *scopeObject = c->getScopeObject();
QObject *attachedObject = qmlAttachedPropertiesObjectById(attachedPropertiesId, scopeObject);
@@ -1349,7 +1350,7 @@ ReturnedValue Runtime::getQmlImportedScripts(NoThrowContext *ctx)
QV4::ReturnedValue Runtime::getQmlSingleton(QV4::NoThrowContext *ctx, String *name)
{
- return ctx->engine()->qmlContextObject()->getPointer()->as<QmlContextWrapper>()->qmlSingletonWrapper(ctx->engine()->v8Engine, name);
+ return static_cast<QmlContextWrapper *>(ctx->engine()->qmlContextObject()->getPointer())->qmlSingletonWrapper(ctx->engine()->v8Engine, name);
}
void Runtime::convertThisToObject(ExecutionContext *ctx)
diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h
index 9e9a6e60c9..b1b4d5da8d 100644
--- a/src/qml/jsruntime/qv4scopedvalue_p.h
+++ b/src/qml/jsruntime/qv4scopedvalue_p.h
@@ -288,6 +288,16 @@ struct Scoped
#endif
}
+ template<typename X>
+ Scoped(const Scope &scope, Returned<X> *x, _Cast)
+ {
+ ptr = scope.engine->jsStackTop++;
+ setPointer(managed_cast<T>(x->getPointer()));
+#ifndef QT_NO_DEBUG
+ ++scope.size;
+#endif
+ }
+
Scoped(const Scope &scope, const ReturnedValue &v)
{
ptr = scope.engine->jsStackTop++;
diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp
index a45f4cabc5..7a0a643a7e 100644
--- a/src/qml/jsruntime/qv4sequenceobject.cpp
+++ b/src/qml/jsruntime/qv4sequenceobject.cpp
@@ -331,6 +331,8 @@ public:
bool containerIsEqualTo(Managed *other)
{
+ if (!other)
+ return false;
QQmlSequence<Container> *otherSequence = other->as<QQmlSequence<Container> >();
if (!otherSequence)
return false;
diff --git a/src/qml/jsruntime/qv4variantobject.cpp b/src/qml/jsruntime/qv4variantobject.cpp
index 68b08fb3ca..3cde96992e 100644
--- a/src/qml/jsruntime/qv4variantobject.cpp
+++ b/src/qml/jsruntime/qv4variantobject.cpp
@@ -92,8 +92,8 @@ void VariantObject::destroy(Managed *that)
bool VariantObject::isEqualTo(Managed *m, Managed *other)
{
- QV4::VariantObject *lv = m->as<QV4::VariantObject>();
- assert(lv);
+ Q_ASSERT(m->as<QV4::VariantObject>());
+ QV4::VariantObject *lv = static_cast<QV4::VariantObject *>(m);
if (QV4::VariantObject *rv = other->as<QV4::VariantObject>())
return lv->d()->data == rv->d()->data;
diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h
index 0cab824aca..77beb5722d 100644
--- a/src/qml/qml/qqml.h
+++ b/src/qml/qml/qqml.h
@@ -502,7 +502,7 @@ namespace QtQml {
}
#endif
-#ifdef Q_CC_CLANG
+#if defined(Q_CC_CLANG) && !defined(Q_CC_INTEL)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wheader-hygiene"
#endif
@@ -510,7 +510,7 @@ namespace QtQml {
// This is necessary to allow for QtQuick1 and QtQuick2 scenes in a single application.
using namespace QtQml;
-#ifdef Q_CC_CLANG
+#if defined(Q_CC_CLANG) && !defined(Q_CC_INTEL)
#pragma clang diagnostic pop
#endif
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp
index 6033395629..7babcd2f4e 100644
--- a/src/qml/qml/qqmlbinding.cpp
+++ b/src/qml/qml/qqmlbinding.cpp
@@ -171,7 +171,8 @@ void QQmlBinding::update(QQmlPropertyPrivate::WriteFlags flags)
QV4::ScopedFunctionObject f(scope, v4function.value());
Q_ASSERT(f);
if (f->bindingKeyFlag()) {
- QQmlSourceLocation loc = f->as<QV4::QQmlBindingFunction>()->d()->bindingLocation;
+ Q_ASSERT(f->as<QV4::QQmlBindingFunction>());
+ QQmlSourceLocation loc = static_cast<QV4::QQmlBindingFunction *>(f.getPointer())->d()->bindingLocation;
url = loc.sourceFile;
lineNumber = loc.line;
columnNumber = loc.column;
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index c772e16ca9..63a43966b1 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -1500,13 +1500,13 @@ void QmlIncubatorObject::setInitialState(QObject *o)
void QmlIncubatorObject::destroy(Managed *that)
{
- that->as<QmlIncubatorObject>()->d()->~Data();
+ static_cast<QmlIncubatorObject *>(that)->d()->~Data();
}
void QmlIncubatorObject::markObjects(QV4::Managed *that, QV4::ExecutionEngine *e)
{
- QmlIncubatorObject *o = that->as<QmlIncubatorObject>();
- Q_ASSERT(o);
+ QmlIncubatorObject *o = static_cast<QmlIncubatorObject *>(that);
+ Q_ASSERT(that->as<QmlIncubatorObject>());
o->d()->valuemap.mark(e);
o->d()->qmlGlobal.mark(e);
o->d()->statusChanged.mark(e);
diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp
index e78f9cf7a4..0816bc05df 100644
--- a/src/qml/qml/qqmlcontextwrapper.cpp
+++ b/src/qml/qml/qqmlcontextwrapper.cpp
@@ -97,7 +97,7 @@ ReturnedValue QmlContextWrapper::urlScope(QV8Engine *v8, const QUrl &url)
QQmlContextData *QmlContextWrapper::callingContext(ExecutionEngine *v4)
{
Scope scope(v4);
- QV4::Scoped<QmlContextWrapper> c(scope, v4->qmlContextObject()->getPointer()->as<QmlContextWrapper>());
+ QV4::Scoped<QmlContextWrapper> c(scope, v4->qmlContextObject(), QV4::Scoped<QmlContextWrapper>::Cast);
return !!c ? c->getContext() : 0;
}
@@ -128,11 +128,10 @@ void QmlContextWrapper::takeContextOwnership(const ValueRef qmlglobal)
ReturnedValue QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty)
{
+ Q_ASSERT(m->as<QmlContextWrapper>());
QV4::ExecutionEngine *v4 = m->engine();
QV4::Scope scope(v4);
- QmlContextWrapper *resource = m->as<QmlContextWrapper>();
- if (!resource)
- return v4->currentContext()->throwTypeError();
+ QmlContextWrapper *resource = static_cast<QmlContextWrapper *>(m);
// In V8 the JS global object would come _before_ the QML global object,
// so simulate that here.
@@ -273,15 +272,12 @@ ReturnedValue QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty
void QmlContextWrapper::put(Managed *m, String *name, const ValueRef value)
{
+ Q_ASSERT(m->as<QmlContextWrapper>());
ExecutionEngine *v4 = m->engine();
QV4::Scope scope(v4);
if (scope.hasException())
return;
- QV4::Scoped<QmlContextWrapper> wrapper(scope, m->as<QmlContextWrapper>());
- if (!wrapper) {
- v4->currentContext()->throwTypeError();
- return;
- }
+ QV4::Scoped<QmlContextWrapper> wrapper(scope, static_cast<QmlContextWrapper *>(m));
PropertyAttributes attrs;
Property *pd = wrapper->__getOwnProperty__(name, &attrs);
@@ -372,7 +368,7 @@ void QmlContextWrapper::registerQmlDependencies(ExecutionEngine *engine, const C
return;
QV4::Scope scope(engine);
- QV4::Scoped<QmlContextWrapper> contextWrapper(scope, engine->qmlContextObject()->getPointer()->as<QmlContextWrapper>());
+ QV4::Scoped<QmlContextWrapper> contextWrapper(scope, engine->qmlContextObject(), QV4::Scoped<QmlContextWrapper>::Cast);
QQmlContextData *qmlContext = contextWrapper->getContext();
const quint32 *idObjectDependency = compiledFunction->qmlIdObjectDependencyTable();
diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp
index 9a51767ef1..13e5e49b55 100644
--- a/src/qml/qml/qqmllistwrapper.cpp
+++ b/src/qml/qml/qqmllistwrapper.cpp
@@ -98,10 +98,9 @@ QVariant QmlListWrapper::toVariant() const
ReturnedValue QmlListWrapper::get(Managed *m, String *name, bool *hasProperty)
{
+ Q_ASSERT(m->as<QmlListWrapper>());
QV4::ExecutionEngine *v4 = m->engine();
- QmlListWrapper *w = m->as<QmlListWrapper>();
- if (!w)
- return v4->currentContext()->throwTypeError();
+ QmlListWrapper *w = static_cast<QmlListWrapper *>(m);
if (name->equals(v4->id_length) && !w->d()->object.isNull()) {
quint32 count = w->d()->property.count ? w->d()->property.count(&w->d()->property) : 0;
@@ -119,19 +118,15 @@ ReturnedValue QmlListWrapper::getIndexed(Managed *m, uint index, bool *hasProper
{
Q_UNUSED(hasProperty);
- QV4::ExecutionEngine *e = m->engine();
- QmlListWrapper *w = m->as<QmlListWrapper>();
- if (!w) {
- if (hasProperty)
- *hasProperty = false;
- return e->currentContext()->throwTypeError();
- }
+ Q_ASSERT(m->as<QmlListWrapper>());
+ QV4::ExecutionEngine *v4 = m->engine();
+ QmlListWrapper *w = static_cast<QmlListWrapper *>(m);
quint32 count = w->d()->property.count ? w->d()->property.count(&w->d()->property) : 0;
if (index < count && w->d()->property.at) {
if (hasProperty)
*hasProperty = true;
- return QV4::QObjectWrapper::wrap(e, w->d()->property.at(&w->d()->property, index));
+ return QV4::QObjectWrapper::wrap(v4, w->d()->property.at(&w->d()->property, index));
}
if (hasProperty)
@@ -149,15 +144,16 @@ void QmlListWrapper::put(Managed *m, String *name, const ValueRef value)
void QmlListWrapper::destroy(Managed *that)
{
- QmlListWrapper *w = that->as<QmlListWrapper>();
- w->d()->~Data();
+ Q_ASSERT(that->as<QmlListWrapper>());
+ static_cast<QmlListWrapper *>(that)->d()->~Data();
}
void QmlListWrapper::advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attrs)
{
name = (String *)0;
*index = UINT_MAX;
- QmlListWrapper *w = m->as<QmlListWrapper>();
+ Q_ASSERT(m->as<QmlListWrapper>());
+ QmlListWrapper *w = static_cast<QmlListWrapper *>(m);
quint32 count = w->d()->property.count ? w->d()->property.count(&w->d()->property) : 0;
if (it->arrayIndex < count) {
*index = it->arrayIndex;
diff --git a/src/qml/qml/qqmllocale_p.h b/src/qml/qml/qqmllocale_p.h
index 24cb3a8c42..a29b86fbea 100644
--- a/src/qml/qml/qqmllocale_p.h
+++ b/src/qml/qml/qqmllocale_p.h
@@ -134,7 +134,8 @@ struct QQmlLocaleData : public QV4::Object
V4_OBJECT(Object)
static QLocale *getThisLocale(QV4::CallContext *ctx) {
- QQmlLocaleData *thisObject = ctx->d()->callData->thisObject.asObject()->as<QQmlLocaleData>();
+ QV4::Object *o = ctx->d()->callData->thisObject.asObject();
+ QQmlLocaleData *thisObject = o ? o->as<QQmlLocaleData>() : 0;
if (!thisObject) {
ctx->throwTypeError();
return 0;
diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp
index 627b701512..d8f282c030 100644
--- a/src/qml/qml/qqmltypewrapper.cpp
+++ b/src/qml/qml/qqmltypewrapper.cpp
@@ -125,13 +125,12 @@ ReturnedValue QmlTypeWrapper::create(QV8Engine *v8, QObject *o, QQmlTypeNameCach
ReturnedValue QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
{
+ Q_ASSERT(m->as<QmlTypeWrapper>());
+
QV4::ExecutionEngine *v4 = m->engine();
QV4::Scope scope(v4);
- Scoped<QmlTypeWrapper> w(scope, m->as<QmlTypeWrapper>());
- if (!w)
- return v4->currentContext()->throwTypeError();
-
+ Scoped<QmlTypeWrapper> w(scope, static_cast<QmlTypeWrapper *>(m));
if (hasProperty)
*hasProperty = true;
@@ -235,14 +234,11 @@ ReturnedValue QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
void QmlTypeWrapper::put(Managed *m, String *name, const ValueRef value)
{
- QmlTypeWrapper *w = m->as<QmlTypeWrapper>();
+ Q_ASSERT(m->as<QmlTypeWrapper>());
+ QmlTypeWrapper *w = static_cast<QmlTypeWrapper *>(m);
QV4::ExecutionEngine *v4 = m->engine();
if (v4->hasException)
return;
- if (!w) {
- v4->currentContext()->throwTypeError();
- return;
- }
QV4::Scope scope(v4);
QV8Engine *v8engine = v4->v8Engine;
@@ -290,8 +286,9 @@ void QmlTypeWrapper::destroy(Managed *that)
bool QmlTypeWrapper::isEqualTo(Managed *a, Managed *b)
{
- QV4::QmlTypeWrapper *qmlTypeWrapperA = a->asObject()->as<QV4::QmlTypeWrapper>();
- if (QV4::QmlTypeWrapper *qmlTypeWrapperB = b->asObject()->as<QV4::QmlTypeWrapper>())
+ Q_ASSERT(a->as<QV4::QmlTypeWrapper>());
+ QV4::QmlTypeWrapper *qmlTypeWrapperA = static_cast<QV4::QmlTypeWrapper *>(a);
+ if (QV4::QmlTypeWrapper *qmlTypeWrapperB = b->as<QV4::QmlTypeWrapper>())
return qmlTypeWrapperA->toVariant() == qmlTypeWrapperB->toVariant();
else if (QV4::QObjectWrapper *qobjectWrapper = b->as<QV4::QObjectWrapper>())
return qmlTypeWrapperA->toVariant().value<QObject*>() == qobjectWrapper->object();
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index 0599745d95..b0125b4c13 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -180,7 +180,8 @@ QVariant QmlValueTypeWrapper::toVariant() const
void QmlValueTypeWrapper::destroy(Managed *that)
{
- QmlValueTypeWrapper *w = that->as<QmlValueTypeWrapper>();
+ Q_ASSERT(that->as<QmlValueTypeWrapper>());
+ QmlValueTypeWrapper *w = static_cast<QmlValueTypeWrapper *>(that);
if (w->d()->objectType == Reference)
static_cast<QmlValueTypeReference *>(w)->d()->~Data();
else
@@ -189,8 +190,8 @@ void QmlValueTypeWrapper::destroy(Managed *that)
bool QmlValueTypeWrapper::isEqualTo(Managed *m, Managed *other)
{
- QV4::QmlValueTypeWrapper *lv = m->as<QmlValueTypeWrapper>();
- Q_ASSERT(lv);
+ Q_ASSERT(m && m->as<QmlValueTypeWrapper>() && other);
+ QV4::QmlValueTypeWrapper *lv = static_cast<QmlValueTypeWrapper *>(m);
if (QV4::VariantObject *rv = other->as<VariantObject>())
return lv->isEqual(rv->d()->data);
@@ -203,12 +204,8 @@ bool QmlValueTypeWrapper::isEqualTo(Managed *m, Managed *other)
PropertyAttributes QmlValueTypeWrapper::query(const Managed *m, String *name)
{
- const QmlValueTypeWrapper *r = m->as<const QmlValueTypeWrapper>();
- QV4::ExecutionEngine *v4 = m->engine();
- if (!r) {
- v4->currentContext()->throwTypeError();
- return PropertyAttributes();
- }
+ Q_ASSERT(m->as<const QmlValueTypeWrapper>());
+ const QmlValueTypeWrapper *r = static_cast<const QmlValueTypeWrapper *>(m);
QQmlPropertyData local;
QQmlPropertyData *result = 0;
@@ -267,10 +264,9 @@ ReturnedValue QmlValueTypeWrapper::method_toString(CallContext *ctx)
ReturnedValue QmlValueTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
{
- QmlValueTypeWrapper *r = m->as<QmlValueTypeWrapper>();
+ Q_ASSERT(m->as<QmlValueTypeWrapper>());
+ QmlValueTypeWrapper *r = static_cast<QmlValueTypeWrapper *>(m);
QV4::ExecutionEngine *v4 = m->engine();
- if (!r)
- return v4->currentContext()->throwTypeError();
// Note: readReferenceValue() can change the reference->type.
if (r->d()->objectType == QmlValueTypeWrapper::Reference) {
@@ -329,16 +325,13 @@ ReturnedValue QmlValueTypeWrapper::get(Managed *m, String *name, bool *hasProper
void QmlValueTypeWrapper::put(Managed *m, String *name, const ValueRef value)
{
+ Q_ASSERT(m->as<QmlValueTypeWrapper>());
ExecutionEngine *v4 = m->engine();
Scope scope(v4);
if (scope.hasException())
return;
- Scoped<QmlValueTypeWrapper> r(scope, m->as<QmlValueTypeWrapper>());
- if (!r) {
- v4->currentContext()->throwTypeError();
- return;
- }
+ Scoped<QmlValueTypeWrapper> r(scope, static_cast<QmlValueTypeWrapper *>(m));
QByteArray propName = name->toQString().toUtf8();
if (r->d()->objectType == QmlValueTypeWrapper::Reference) {
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index 233dd9c239..9e0a1872be 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -204,7 +204,7 @@ public:
// JS API
static void destroy(Managed *that) {
- that->as<NamedNodeMap>()->d()->~Data();
+ static_cast<NamedNodeMap *>(that)->d()->~Data();
}
static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
@@ -235,7 +235,7 @@ public:
// JS API
static void destroy(Managed *that) {
- that->as<NodeList>()->d()->~Data();
+ static_cast<NodeList *>(that)->d()->~Data();
}
static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
@@ -325,7 +325,7 @@ struct Node : public Object
// JS API
static void destroy(Managed *that) {
- that->as<Node>()->d()->~Data();
+ static_cast<Node *>(that)->d()->~Data();
}
// C++ API
@@ -917,10 +917,9 @@ ReturnedValue NamedNodeMap::getIndexed(Managed *m, uint index, bool *hasProperty
ReturnedValue NamedNodeMap::get(Managed *m, String *name, bool *hasProperty)
{
- NamedNodeMap *r = m->as<NamedNodeMap>();
+ Q_ASSERT(m->as<NamedNodeMap>());
+ NamedNodeMap *r = static_cast<NamedNodeMap *>(m);
QV4::ExecutionEngine *v4 = m->engine();
- if (!r)
- return v4->currentContext()->throwTypeError();
name->makeIdentifier();
if (name->equals(v4->id_length))
@@ -950,13 +949,9 @@ ReturnedValue NamedNodeMap::create(QV8Engine *engine, NodeImpl *data, const QLis
ReturnedValue NodeList::getIndexed(Managed *m, uint index, bool *hasProperty)
{
+ Q_ASSERT(m->as<NodeList>());
QV4::ExecutionEngine *v4 = m->engine();
- NodeList *r = m->as<NodeList>();
- if (!r) {
- if (hasProperty)
- *hasProperty = false;
- return v4->currentContext()->throwTypeError();
- }
+ NodeList *r = static_cast<NodeList *>(m);
QV8Engine *engine = v4->v8Engine;
@@ -972,10 +967,9 @@ ReturnedValue NodeList::getIndexed(Managed *m, uint index, bool *hasProperty)
ReturnedValue NodeList::get(Managed *m, String *name, bool *hasProperty)
{
+ Q_ASSERT(m->as<NodeList>());
QV4::ExecutionEngine *v4 = m->engine();
- NodeList *r = m->as<NodeList>();
- if (!r)
- return v4->currentContext()->throwTypeError();
+ NodeList *r = static_cast<NodeList *>(m);
name->makeIdentifier();
@@ -1616,7 +1610,7 @@ struct QQmlXMLHttpRequestWrapper : public Object
V4_OBJECT(Object)
static void destroy(Managed *that) {
- that->as<QQmlXMLHttpRequestWrapper>()->d()->~Data();
+ static_cast<QQmlXMLHttpRequestWrapper *>(that)->d()->~Data();
}
};
@@ -1646,7 +1640,7 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject
};
V4_OBJECT(FunctionObject)
static void markObjects(Managed *that, ExecutionEngine *e) {
- QQmlXMLHttpRequestCtor *c = that->as<QQmlXMLHttpRequestCtor>();
+ QQmlXMLHttpRequestCtor *c = static_cast<QQmlXMLHttpRequestCtor *>(that);
if (c->d()->proto)
c->d()->proto->mark(e);
FunctionObject::markObjects(that, e);
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp
index e8b29b2e44..639df4f846 100644
--- a/src/qml/types/qqmldelegatemodel.cpp
+++ b/src/qml/types/qqmldelegatemodel.cpp
@@ -3277,11 +3277,10 @@ public:
static QV4::ReturnedValue getIndexed(QV4::Managed *m, uint index, bool *hasProperty)
{
+ Q_ASSERT(m->as<QQmlDelegateModelGroupChangeArray>());
QV4::ExecutionEngine *v4 = m->engine();
QV4::Scope scope(v4);
- QV4::Scoped<QQmlDelegateModelGroupChangeArray> array(scope, m->as<QQmlDelegateModelGroupChangeArray>());
- if (!array)
- return v4->currentContext()->throwTypeError();
+ QV4::Scoped<QQmlDelegateModelGroupChangeArray> array(scope, static_cast<QQmlDelegateModelGroupChangeArray *>(m));
if (index >= array->count()) {
if (hasProperty)
@@ -3303,9 +3302,8 @@ public:
static QV4::ReturnedValue get(QV4::Managed *m, QV4::String *name, bool *hasProperty)
{
- QQmlDelegateModelGroupChangeArray *array = m->as<QQmlDelegateModelGroupChangeArray>();
- if (!array)
- return m->engine()->currentContext()->throwTypeError();
+ Q_ASSERT(m->as<QQmlDelegateModelGroupChangeArray>());
+ QQmlDelegateModelGroupChangeArray *array = static_cast<QQmlDelegateModelGroupChangeArray *>(m);
if (name->equals(m->engine()->id_length)) {
if (hasProperty)
@@ -3316,8 +3314,7 @@ public:
return Object::get(m, name, hasProperty);
}
static void destroy(Managed *that) {
- QQmlDelegateModelGroupChangeArray *array = that->as<QQmlDelegateModelGroupChangeArray>();
- array->d()->~Data();
+ static_cast<QQmlDelegateModelGroupChangeArray *>(that)->d()->~Data();
}
};
diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp
index 15eb28350e..c31b7726c4 100644
--- a/src/quick/items/context2d/qquickcanvasitem.cpp
+++ b/src/quick/items/context2d/qquickcanvasitem.cpp
@@ -313,7 +313,7 @@ QQuickCanvasItem::~QQuickCanvasItem()
}
/*!
- \qmlproperty size QtQuick::Canvas::available
+ \qmlproperty bool QtQuick::Canvas::available
Indicates when Canvas is able to provide a drawing context to operate on.
*/
@@ -790,18 +790,18 @@ QSGTextureProvider *QQuickCanvasItem::textureProvider() const
}
/*!
- \qmlmethod object QtQuick::Canvas::getContext(string contextId, any... args)
+ \qmlmethod object QtQuick::Canvas::getContext(string contextId, ... args)
- Returns a drawing context or null if no context available.
+ Returns a drawing context, or \c null if no context is available.
The \a contextId parameter names the required context. The Canvas item
will return a context that implements the required drawing mode. After the
- first call to getContext any subsequent call to getContext with the same
+ first call to getContext, any subsequent call to getContext with the same
contextId will return the same context object.
If the context type is not supported or the canvas has previously been
- requested to provide a different and incompatible context type, null will
- be returned.
+ requested to provide a different and incompatible context type, \c null
+ will be returned.
Canvas only supports a 2d context.
*/
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index b1af6f10dd..0101e0edf4 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -3093,11 +3093,12 @@ QV4::ReturnedValue QQuickJSContext2DPixelData::proto_get_length(QV4::CallContext
QV4::ReturnedValue QQuickJSContext2DPixelData::getIndexed(QV4::Managed *m, uint index, bool *hasProperty)
{
+ Q_ASSERT(m->as<QQuickJSContext2DPixelData>());
QV4::ExecutionEngine *v4 = m->engine();
QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2DPixelData> r(scope, m->as<QQuickJSContext2DPixelData>());
+ QV4::Scoped<QQuickJSContext2DPixelData> r(scope, static_cast<QQuickJSContext2DPixelData *>(m));
- if (r && index < static_cast<quint32>(r->d()->image.width() * r->d()->image.height() * 4)) {
+ if (index < static_cast<quint32>(r->d()->image.width() * r->d()->image.height() * 4)) {
if (hasProperty)
*hasProperty = true;
const quint32 w = r->d()->image.width();
@@ -3123,16 +3124,13 @@ QV4::ReturnedValue QQuickJSContext2DPixelData::getIndexed(QV4::Managed *m, uint
void QQuickJSContext2DPixelData::putIndexed(QV4::Managed *m, uint index, const QV4::ValueRef value)
{
+ Q_ASSERT(m->as<QQuickJSContext2DPixelData>());
QV4::ExecutionEngine *v4 = m->engine();
QV4::Scope scope(v4);
if (scope.hasException())
return;
- QV4::Scoped<QQuickJSContext2DPixelData> r(scope, m->as<QQuickJSContext2DPixelData>());
- if (!r) {
- scope.engine->currentContext()->throwTypeError();
- return;
- }
+ QV4::Scoped<QQuickJSContext2DPixelData> r(scope, static_cast<QQuickJSContext2DPixelData *>(m));
const int v = value->toInt32();
if (r && index < static_cast<quint32>(r->d()->image.width() * r->d()->image.height() * 4) && v >= 0 && v <= 255) {
diff --git a/src/quick/items/qquickborderimage.cpp b/src/quick/items/qquickborderimage.cpp
index 8d8e4b6a02..07b8958664 100644
--- a/src/quick/items/qquickborderimage.cpp
+++ b/src/quick/items/qquickborderimage.cpp
@@ -582,10 +582,16 @@ QSGNode *QQuickBorderImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDat
qMax<qreal>(0, width() - border->right() - border->left()),
qMax<qreal>(0, height() - border->bottom() - border->top()));
- if (innerSourceRect != d->oldInnerSourceRect || innerTargetRect != d->oldInnerTargetRect)
+ QSizeF newSize(width(), height());
+ if (innerSourceRect != d->oldInnerSourceRect
+ || innerTargetRect != d->oldInnerTargetRect
+ || newSize != d->oldSize) {
updateNode = true;
+ }
+
d->oldInnerSourceRect = innerSourceRect;
d->oldInnerTargetRect = innerTargetRect;
+ d->oldSize = newSize;
}
bool updatePixmap = d->pixmapChanged;
diff --git a/src/quick/items/qquickimagebase_p_p.h b/src/quick/items/qquickimagebase_p_p.h
index ec2f0bb73e..21d11a7448 100644
--- a/src/quick/items/qquickimagebase_p_p.h
+++ b/src/quick/items/qquickimagebase_p_p.h
@@ -77,6 +77,7 @@ public:
qreal devicePixelRatio;
QRectF oldInnerSourceRect;
QRectF oldInnerTargetRect;
+ QSizeF oldSize;
bool async : 1;
bool cache : 1;
bool mirror: 1;
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 41e9e0e57a..25f139549d 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -6957,6 +6957,13 @@ void QQuickItem::grabTouchPoints(const QVector<int> &ids)
windowPriv->itemForTouchPointId[ids.at(i)] = this;
if (oldGrabber)
ungrab.insert(oldGrabber);
+
+ QQuickItem *mouseGrabber = windowPriv->mouseGrabberItem;
+ if (windowPriv->touchMouseId == ids.at(i) && mouseGrabber && mouseGrabber != this) {
+ windowPriv->mouseGrabberItem = 0;
+ QEvent ev(QEvent::UngrabMouse);
+ d->window->sendEvent(mouseGrabber, &ev);
+ }
}
foreach (QQuickItem *oldGrabber, ungrab)
oldGrabber->touchUngrabEvent();
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp
index 2fd79715e1..93cb5e4e9d 100644
--- a/src/quick/items/qquickitemview.cpp
+++ b/src/quick/items/qquickitemview.cpp
@@ -273,9 +273,13 @@ QVariant QQuickItemView::model() const
return d->modelVariant;
}
-void QQuickItemView::setModel(const QVariant &model)
+void QQuickItemView::setModel(const QVariant &m)
{
Q_D(QQuickItemView);
+ QVariant model = m;
+ if (model.userType() == qMetaTypeId<QJSValue>())
+ model = model.value<QJSValue>().toVariant();
+
if (d->modelVariant == model)
return;
if (d->model) {
diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp
index 825845eca9..6cf3e33de9 100644
--- a/src/quick/items/qquickpathview.cpp
+++ b/src/quick/items/qquickpathview.cpp
@@ -607,9 +607,13 @@ QVariant QQuickPathView::model() const
return d->modelVariant;
}
-void QQuickPathView::setModel(const QVariant &model)
+void QQuickPathView::setModel(const QVariant &m)
{
Q_D(QQuickPathView);
+ QVariant model = m;
+ if (model.userType() == qMetaTypeId<QJSValue>())
+ model = model.value<QJSValue>().toVariant();
+
if (d->modelVariant == model)
return;
diff --git a/src/quick/items/qquickrepeater.cpp b/src/quick/items/qquickrepeater.cpp
index 8e13947d78..e2a3043857 100644
--- a/src/quick/items/qquickrepeater.cpp
+++ b/src/quick/items/qquickrepeater.cpp
@@ -183,9 +183,13 @@ QVariant QQuickRepeater::model() const
return d->dataSource;
}
-void QQuickRepeater::setModel(const QVariant &model)
+void QQuickRepeater::setModel(const QVariant &m)
{
Q_D(QQuickRepeater);
+ QVariant model = m;
+ if (model.userType() == qMetaTypeId<QJSValue>())
+ model = model.value<QJSValue>().toVariant();
+
if (d->dataSource == model)
return;
diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp
index 2585caefb5..0ad21ccff3 100644
--- a/src/quick/items/qquicktextcontrol.cpp
+++ b/src/quick/items/qquicktextcontrol.cpp
@@ -965,7 +965,6 @@ QRectF QQuickTextControlPrivate::rectForPosition(int position) const
const QTextBlock block = doc->findBlock(position);
if (!block.isValid())
return QRectF();
- const QAbstractTextDocumentLayout *docLayout = doc->documentLayout();
const QTextLayout *layout = block.layout();
const QPointF layoutPos = q->blockBoundingRect(block).topLeft();
int relativePos = position - block.position();
@@ -980,24 +979,14 @@ QRectF QQuickTextControlPrivate::rectForPosition(int position) const
#endif
QTextLine line = layout->lineForTextPosition(relativePos);
- int cursorWidth;
- {
- bool ok = false;
-#ifndef QT_NO_PROPERTIES
- cursorWidth = docLayout->property("cursorWidth").toInt(&ok);
-#endif
- if (!ok)
- cursorWidth = 1;
- }
-
QRectF r;
if (line.isValid()) {
qreal x = line.cursorToX(relativePos);
qreal w = 0;
- r = QRectF(layoutPos.x() + x, layoutPos.y() + line.y(), cursorWidth + w, line.height());
+ r = QRectF(layoutPos.x() + x, layoutPos.y() + line.y(), textCursorWidth + w, line.height());
} else {
- r = QRectF(layoutPos.x(), layoutPos.y(), cursorWidth, 10); // #### correct height
+ r = QRectF(layoutPos.x(), layoutPos.y(), textCursorWidth, 10); // #### correct height
}
return r;
@@ -1510,19 +1499,6 @@ QString QQuickTextControl::anchorAt(const QPointF &pos) const
return d->doc->documentLayout()->anchorAt(pos);
}
-void QQuickTextControl::setCursorWidth(int width)
-{
- Q_D(QQuickTextControl);
-#ifdef QT_NO_PROPERTIES
- Q_UNUSED(width);
-#else
- if (width == -1)
- width = textCursorWidth;
- d->doc->documentLayout()->setProperty("cursorWidth", width);
-#endif
- d->repaintCursor();
-}
-
void QQuickTextControl::setAcceptRichText(bool accept)
{
Q_D(QQuickTextControl);
diff --git a/src/quick/items/qquicktextedit_p_p.h b/src/quick/items/qquicktextedit_p_p.h
index 41a5107ccf..5233413cd7 100644
--- a/src/quick/items/qquicktextedit_p_p.h
+++ b/src/quick/items/qquicktextedit_p_p.h
@@ -122,7 +122,7 @@ public:
Qt::LayoutDirection textDirection(const QString &text) const;
bool isLinkHoveredConnected();
- void setNativeCursorEnabled(bool enabled) { control->setCursorWidth(enabled ? 1 : 0); }
+ void setNativeCursorEnabled(bool) {}
void handleFocusEvent(QFocusEvent *event);
void addCurrentTextNodeToRoot(QSGTransformNode *, QQuickTextNode*, TextNodeIterator&, int startPos);
QQuickTextNode* createTextNode();
diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
index 33008a9d1b..99702236ee 100644
--- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
+++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
@@ -204,6 +204,8 @@ private slots:
void displayMargin();
void negativeDisplayMargin();
+ void jsArrayChange();
+
private:
QList<int> toIntList(const QVariantList &list);
void matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes);
@@ -6431,6 +6433,33 @@ void tst_QQuickGridView::negativeDisplayMargin()
delete window;
}
+void tst_QQuickGridView::jsArrayChange()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.4; GridView {}", QUrl());
+
+ QScopedPointer<QQuickGridView> view(qobject_cast<QQuickGridView *>(component.create()));
+ QVERIFY(!view.isNull());
+
+ QSignalSpy spy(view.data(), SIGNAL(modelChanged()));
+ QVERIFY(spy.isValid());
+
+ QJSValue array1 = engine.newArray(3);
+ QJSValue array2 = engine.newArray(3);
+ for (int i = 0; i < 3; ++i) {
+ array1.setProperty(i, i);
+ array2.setProperty(i, i);
+ }
+
+ view->setModel(QVariant::fromValue(array1));
+ QCOMPARE(spy.count(), 1);
+
+ // no change
+ view->setModel(QVariant::fromValue(array2));
+ QCOMPARE(spy.count(), 1);
+}
+
QTEST_MAIN(tst_QQuickGridView)
#include "tst_qquickgridview.moc"
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index 5122b6aa38..9e8a813d54 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -239,6 +239,8 @@ private slots:
void QTBUG_39492_data();
void QTBUG_39492();
+ void jsArrayChange();
+
private:
template <class T> void items(const QUrl &source);
template <class T> void changed(const QUrl &source);
@@ -7945,6 +7947,33 @@ void tst_QQuickListView::QTBUG_39492()
releaseView(window);
}
+void tst_QQuickListView::jsArrayChange()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.4; ListView {}", QUrl());
+
+ QScopedPointer<QQuickListView> view(qobject_cast<QQuickListView *>(component.create()));
+ QVERIFY(!view.isNull());
+
+ QSignalSpy spy(view.data(), SIGNAL(modelChanged()));
+ QVERIFY(spy.isValid());
+
+ QJSValue array1 = engine.newArray(3);
+ QJSValue array2 = engine.newArray(3);
+ for (int i = 0; i < 3; ++i) {
+ array1.setProperty(i, i);
+ array2.setProperty(i, i);
+ }
+
+ view->setModel(QVariant::fromValue(array1));
+ QCOMPARE(spy.count(), 1);
+
+ // no change
+ view->setModel(QVariant::fromValue(array2));
+ QCOMPARE(spy.count(), 1);
+}
+
QTEST_MAIN(tst_QQuickListView)
#include "tst_qquicklistview.moc"
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
index 0e9994899f..992b2347dd 100644
--- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -139,6 +139,7 @@ private slots:
void changePathDuringRefill();
void nestedinFlickable();
void flickableDelegate();
+ void jsArrayChange();
};
class TestObject : public QObject
@@ -2290,6 +2291,33 @@ void tst_QQuickPathView::flickableDelegate()
QCOMPARE(moveStartedSpy.count(), 0);
}
+void tst_QQuickPathView::jsArrayChange()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.4; PathView {}", QUrl());
+
+ QScopedPointer<QQuickPathView> view(qobject_cast<QQuickPathView *>(component.create()));
+ QVERIFY(!view.isNull());
+
+ QSignalSpy spy(view.data(), SIGNAL(modelChanged()));
+ QVERIFY(spy.isValid());
+
+ QJSValue array1 = engine.newArray(3);
+ QJSValue array2 = engine.newArray(3);
+ for (int i = 0; i < 3; ++i) {
+ array1.setProperty(i, i);
+ array2.setProperty(i, i);
+ }
+
+ view->setModel(QVariant::fromValue(array1));
+ QCOMPARE(spy.count(), 1);
+
+ // no change
+ view->setModel(QVariant::fromValue(array2));
+ QCOMPARE(spy.count(), 1);
+}
+
QTEST_MAIN(tst_QQuickPathView)
#include "tst_qquickpathview.moc"
diff --git a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
index 1396dd4783..258eaee981 100644
--- a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
+++ b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
@@ -72,6 +72,7 @@ private slots:
void dynamicModelCrash();
void visualItemModelCrash();
void invalidContextCrash();
+ void jsArrayChange();
};
class TestObject : public QObject
@@ -779,6 +780,33 @@ void tst_QQuickRepeater::invalidContextCrash()
root.reset(0);
}
+void tst_QQuickRepeater::jsArrayChange()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.4; Repeater {}", QUrl());
+
+ QScopedPointer<QQuickRepeater> repeater(qobject_cast<QQuickRepeater *>(component.create()));
+ QVERIFY(!repeater.isNull());
+
+ QSignalSpy spy(repeater.data(), SIGNAL(modelChanged()));
+ QVERIFY(spy.isValid());
+
+ QJSValue array1 = engine.newArray(3);
+ QJSValue array2 = engine.newArray(3);
+ for (int i = 0; i < 3; ++i) {
+ array1.setProperty(i, i);
+ array2.setProperty(i, i);
+ }
+
+ repeater->setModel(QVariant::fromValue(array1));
+ QCOMPARE(spy.count(), 1);
+
+ // no change
+ repeater->setModel(QVariant::fromValue(array2));
+ QCOMPARE(spy.count(), 1);
+}
+
QTEST_MAIN(tst_QQuickRepeater)
#include "tst_qquickrepeater.moc"
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index 4829b478e9..4f10b4ce82 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -171,6 +171,7 @@ private slots:
void preeditCursorRectangle();
void inputMethodComposing();
+ void cursorRectangleSize_data();
void cursorRectangleSize();
void getText_data();
@@ -3654,12 +3655,28 @@ void tst_qquicktextedit::inputMethodComposing()
QCOMPARE(spy.count(), 8);
}
+void tst_qquicktextedit::cursorRectangleSize_data()
+{
+ QTest::addColumn<bool>("useCursorDelegate");
+
+ QTest::newRow("default cursor") << false;
+ QTest::newRow("custom cursor delegate") << true;
+}
+
void tst_qquicktextedit::cursorRectangleSize()
{
+ QFETCH(bool, useCursorDelegate);
+
QQuickView *window = new QQuickView(testFileUrl("positionAt.qml"));
QVERIFY(window->rootObject() != 0);
QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit *>(window->rootObject());
+ QQmlComponent cursorDelegate(window->engine());
+ if (useCursorDelegate) {
+ cursorDelegate.setData("import QtQuick 2.0\nRectangle { width:10; height:10; }", QUrl());
+ textEdit->setCursorDelegate(&cursorDelegate);
+ }
+
// make sure cursor rectangle is not at (0,0)
textEdit->setX(10);
textEdit->setY(10);
@@ -3677,6 +3694,10 @@ void tst_qquicktextedit::cursorRectangleSize()
QRectF cursorRectFromItem = textEdit->cursorRectangle();
QRectF cursorRectFromPositionToRectangle = textEdit->positionToRectangle(textEdit->cursorPosition());
+ QVERIFY(cursorRectFromItem.isValid());
+ QVERIFY(cursorRectFromQuery.isValid());
+ QVERIFY(cursorRectFromPositionToRectangle.isValid());
+
// item and input query cursor rectangles match
QCOMPARE(cursorRectFromItem, cursorRectFromQuery);
diff --git a/tests/auto/quick/touchmouse/data/twosiblingitems.qml b/tests/auto/quick/touchmouse/data/twosiblingitems.qml
new file mode 100644
index 0000000000..2bf67b1917
--- /dev/null
+++ b/tests/auto/quick/touchmouse/data/twosiblingitems.qml
@@ -0,0 +1,24 @@
+import QtQuick 2.0
+import Qt.test 1.0
+
+Rectangle {
+ id: root
+ width: 320
+ height: 480
+ color: "green"
+
+ EventItem {
+ id: leftItem
+ objectName: "leftItem"
+ width: root.width / 2
+ height: root.height
+ }
+
+ EventItem {
+ objectName: "rightItem"
+ anchors.left: leftItem.right
+ width: root.width / 2
+ height: root.height
+ }
+}
+
diff --git a/tests/auto/quick/touchmouse/tst_touchmouse.cpp b/tests/auto/quick/touchmouse/tst_touchmouse.cpp
index ab1d214369..8c6e3ffc3e 100644
--- a/tests/auto/quick/touchmouse/tst_touchmouse.cpp
+++ b/tests/auto/quick/touchmouse/tst_touchmouse.cpp
@@ -101,10 +101,13 @@ public:
eventList.append(Event(event->type(), event->pos(), event->globalPos()));
event->setAccepted(acceptMouse);
}
+
+ void mouseUngrabEvent()
+ {
+ eventList.append(Event(QEvent::UngrabMouse, QPoint(0,0), QPoint(0,0)));
+ }
+
bool event(QEvent *event) {
- if (event->type() == QEvent::UngrabMouse) {
- eventList.append(Event(event->type(), QPoint(0,0), QPoint(0,0)));
- }
return QQuickItem::event(event);
}
@@ -156,6 +159,8 @@ private slots:
void tapOnDismissiveTopMouseAreaClicksBottomOne();
+ void touchGrabCausesMouseUngrab();
+
protected:
bool eventFilter(QObject *, QEvent *event)
{
@@ -274,9 +279,10 @@ void tst_TouchMouse::simpleTouchEvent()
QCOMPARE(eventItem1->eventList.at(3).type, QEvent::MouseMove);
QTest::touchEvent(window, device).release(0, p1, window);
QQuickTouchUtils::flush(window);
- QCOMPARE(eventItem1->eventList.size(), 6);
+ QCOMPARE(eventItem1->eventList.size(), 7);
QCOMPARE(eventItem1->eventList.at(4).type, QEvent::TouchEnd);
QCOMPARE(eventItem1->eventList.at(5).type, QEvent::MouseButtonRelease);
+ QCOMPARE(eventItem1->eventList.at(6).type, QEvent::UngrabMouse);
eventItem1->eventList.clear();
// wait to avoid getting a double click event
@@ -289,16 +295,17 @@ void tst_TouchMouse::simpleTouchEvent()
p1 = QPoint(20, 20);
QTest::touchEvent(window, device).press(0, p1, window);
QQuickTouchUtils::flush(window);
- QCOMPARE(eventItem1->eventList.size(), 2);
+ QCOMPARE(eventItem1->eventList.size(), 3);
QCOMPARE(eventItem1->eventList.at(0).type, QEvent::TouchBegin);
QCOMPARE(eventItem1->eventList.at(1).type, QEvent::MouseButtonPress);
+ QCOMPARE(eventItem1->eventList.at(2).type, QEvent::UngrabMouse);
p1 += QPoint(10, 0);
QTest::touchEvent(window, device).move(0, p1, window);
QQuickTouchUtils::flush(window);
- QCOMPARE(eventItem1->eventList.size(), 2);
+ QCOMPARE(eventItem1->eventList.size(), 3);
QTest::touchEvent(window, device).release(0, p1, window);
QQuickTouchUtils::flush(window);
- QCOMPARE(eventItem1->eventList.size(), 2);
+ QCOMPARE(eventItem1->eventList.size(), 3);
eventItem1->eventList.clear();
// wait to avoid getting a double click event
@@ -529,9 +536,10 @@ void tst_TouchMouse::buttonOnFlickable()
QCOMPARE(eventItem1->eventList.at(1).type, QEvent::MouseButtonPress);
QTest::touchEvent(window, device).release(0, p1, window);
QQuickTouchUtils::flush(window);
- QCOMPARE(eventItem1->eventList.size(), 4);
+ QCOMPARE(eventItem1->eventList.size(), 5);
QCOMPARE(eventItem1->eventList.at(2).type, QEvent::TouchEnd);
QCOMPARE(eventItem1->eventList.at(3).type, QEvent::MouseButtonRelease);
+ QCOMPARE(eventItem1->eventList.at(4).type, QEvent::UngrabMouse);
eventItem1->eventList.clear();
// touch button
@@ -739,18 +747,20 @@ void tst_TouchMouse::buttonOnTouch()
QQuickTouchUtils::flush(window);
QTest::touchEvent(window, device).release(0, p1, window);
QQuickTouchUtils::flush(window);
- QCOMPARE(eventItem1->eventList.size(), 4);
+ QCOMPARE(eventItem1->eventList.size(), 5);
QCOMPARE(eventItem1->eventList.at(0).type, QEvent::TouchBegin);
QCOMPARE(eventItem1->eventList.at(1).type, QEvent::MouseButtonPress);
QCOMPARE(eventItem1->eventList.at(2).type, QEvent::TouchEnd);
QCOMPARE(eventItem1->eventList.at(3).type, QEvent::MouseButtonRelease);
+ QCOMPARE(eventItem1->eventList.at(4).type, QEvent::UngrabMouse);
eventItem1->eventList.clear();
// Normal mouse click
QTest::mouseClick(window, Qt::LeftButton, 0, p1);
- QCOMPARE(eventItem1->eventList.size(), 2);
+ QCOMPARE(eventItem1->eventList.size(), 3);
QCOMPARE(eventItem1->eventList.at(0).type, QEvent::MouseButtonPress);
QCOMPARE(eventItem1->eventList.at(1).type, QEvent::MouseButtonRelease);
+ QCOMPARE(eventItem1->eventList.at(2).type, QEvent::UngrabMouse);
eventItem1->eventList.clear();
// Pinch starting on the PinchArea should work
@@ -1169,6 +1179,59 @@ void tst_TouchMouse::tapOnDismissiveTopMouseAreaClicksBottomOne()
delete window;
}
+/*
+ If an item grabs a touch that is currently being used for mouse pointer emulation,
+ the current mouse grabber should lose the mouse as mouse events will no longer
+ be generated from that touch point.
+ */
+void tst_TouchMouse::touchGrabCausesMouseUngrab()
+{
+ QQuickView *window = createView();
+
+ window->setSource(testFileUrl("twosiblingitems.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+ window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(window));
+ QVERIFY(window->rootObject() != 0);
+
+ EventItem *leftItem = window->rootObject()->findChild<EventItem*>("leftItem");
+ QVERIFY(leftItem);
+
+ EventItem *rightItem = window->rootObject()->findChild<EventItem*>("rightItem");
+ QVERIFY(leftItem);
+
+ // Send a touch to the leftItem. But leftItem accepts only mouse events, thus
+ // a mouse event will be synthesized out of this touch and will get accepted by
+ // leftItem.
+ leftItem->acceptMouse = true;
+ leftItem->setAcceptedMouseButtons(Qt::LeftButton);
+ QPoint p1;
+ p1 = QPoint(leftItem->width() / 2, leftItem->height() / 2);
+ QTest::touchEvent(window, device).press(0, p1, window);
+ QQuickTouchUtils::flush(window);
+ QCOMPARE(leftItem->eventList.size(), 2);
+ QCOMPARE(leftItem->eventList.at(0).type, QEvent::TouchBegin);
+ QCOMPARE(leftItem->eventList.at(1).type, QEvent::MouseButtonPress);
+ QCOMPARE(window->mouseGrabberItem(), leftItem);
+ leftItem->eventList.clear();
+
+ rightItem->acceptTouch = true;
+ {
+ QVector<int> ids;
+ ids.append(0);
+ rightItem->grabTouchPoints(ids);
+ }
+
+ // leftItem should have lost the mouse as the touch point that was being used to emulate it
+ // has been grabbed by another item.
+ QCOMPARE(leftItem->eventList.size(), 1);
+ QCOMPARE(leftItem->eventList.at(0).type, QEvent::UngrabMouse);
+ QCOMPARE(window->mouseGrabberItem(), (QQuickItem*)0);
+
+ delete window;
+}
+
QTEST_MAIN(tst_TouchMouse)
#include "tst_touchmouse.moc"