From 5f49b2b3bb30678a26341e1f45e0cfd6a6fd2c57 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 11 May 2017 17:19:14 +0200 Subject: QML Settings: fix JS array handling Before Qt 5.4, JS arrays were passed as QVariantLists. Since Qt 5.4, they are passed as QJSValues instead. Use QJSValue::toVariant() (the same way as QQuickItemView::setModel(QVariant) which was fixed in cf959b4b) to convert JS values to QSettings-compatible variants. Task-number: QTBUG-45316 Change-Id: Icc6f8ad09bfef089d9efcf5b90e3783bb3f73a9f Reviewed-by: Simon Hausmann --- src/imports/settings/qqmlsettings.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/imports') diff --git a/src/imports/settings/qqmlsettings.cpp b/src/imports/settings/qqmlsettings.cpp index cd6fcbc718..df67c04654 100644 --- a/src/imports/settings/qqmlsettings.cpp +++ b/src/imports/settings/qqmlsettings.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -241,6 +242,7 @@ public: void store(); void _q_propertyChanged(); + QVariant readProperty(const QMetaProperty &property) const; QQmlSettings *q_ptr; int timerId; @@ -295,7 +297,7 @@ void QQmlSettingsPrivate::load() for (int i = offset; i < count; ++i) { QMetaProperty property = mo->property(i); - const QVariant previousValue = property.read(q); + const QVariant previousValue = readProperty(property); const QVariant currentValue = instance()->value(property.name(), previousValue); if (!currentValue.isNull() && (!previousValue.isValid() @@ -340,9 +342,10 @@ void QQmlSettingsPrivate::_q_propertyChanged() const int count = mo->propertyCount(); for (int i = offset; i < count; ++i) { const QMetaProperty &property = mo->property(i); - changedProperties.insert(property.name(), property.read(q)); + const QVariant value = readProperty(property); + changedProperties.insert(property.name(), value); #ifdef SETTINGS_DEBUG - qDebug() << "QQmlSettings: cache" << property.name() << ":" << property.read(q); + qDebug() << "QQmlSettings: cache" << property.name() << ":" << value; #endif } if (timerId != 0) @@ -350,6 +353,15 @@ void QQmlSettingsPrivate::_q_propertyChanged() timerId = q->startTimer(settingsWriteDelay); } +QVariant QQmlSettingsPrivate::readProperty(const QMetaProperty &property) const +{ + Q_Q(const QQmlSettings); + QVariant var = property.read(q); + if (var.userType() == qMetaTypeId()) + var = var.value().toVariant(); + return var; +} + QQmlSettings::QQmlSettings(QObject *parent) : QObject(parent), d_ptr(new QQmlSettingsPrivate) { -- cgit v1.2.3 From 5bc38a50308665bdc185eb96dbcc9ba7948ab4e0 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 19 May 2017 12:39:52 +0200 Subject: Get rid of the old way of defining builtin functions The old calling convention used for builtin functions is very inefficient. It was still being used in a few places. Clean those up and convert them to the new and much more effiecient calling convention. Change-Id: I6b769c6185df7e9be1e80709330fc1ca868576c1 Reviewed-by: Robin Burchell --- src/imports/localstorage/plugin.cpp | 97 +++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 53 deletions(-) (limited to 'src/imports') diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index 40682dd6a8..a7d95cc295 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -73,8 +73,8 @@ QT_BEGIN_NAMESPACE QV4::ScopedString v(scope, scope.engine->newString(desc)); \ QV4::ScopedObject ex(scope, scope.engine->newErrorObject(v)); \ ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))).getPointer(), QV4::ScopedValue(scope, Primitive::fromInt32(error))); \ - ctx->engine()->throwError(ex); \ - return Encode::undefined(); \ + scope.engine->throwError(ex); \ + RETURN_UNDEFINED(); \ } #define V4THROW_SQL2(error, desc) { \ @@ -87,8 +87,8 @@ QT_BEGIN_NAMESPACE #define V4THROW_REFERENCE(string) { \ QV4::ScopedString v(scope, scope.engine->newString(string)); \ - ctx->engine()->throwReferenceError(v); \ - return Encode::undefined(); \ + scope.engine->throwReferenceError(v); \ + RETURN_UNDEFINED(); \ } @@ -164,20 +164,18 @@ DEFINE_OBJECT_VTABLE(QV4::QQmlSqlDatabaseWrapper); -static ReturnedValue qmlsqldatabase_version(CallContext *ctx) +static void qmlsqldatabase_version(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) { - QV4::Scope scope(ctx); - QV4::Scoped r(scope, ctx->thisObject().as()); + QV4::Scoped r(scope, callData->thisObject.as()); if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Database) V4THROW_REFERENCE("Not a SQLDatabase object"); - return Encode(scope.engine->newString(*r->d()->version)); + RETURN_RESULT(Encode(scope.engine->newString(*r->d()->version))); } -static ReturnedValue qmlsqldatabase_rows_length(CallContext *ctx) +static void qmlsqldatabase_rows_length(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) { - QV4::Scope scope(ctx); - QV4::Scoped r(scope, ctx->thisObject().as()); + QV4::Scoped r(scope, callData->thisObject.as()); if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows) V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); @@ -190,29 +188,27 @@ static ReturnedValue qmlsqldatabase_rows_length(CallContext *ctx) s = 0; } } - return Encode(s); + RETURN_RESULT(Encode(s)); } -static ReturnedValue qmlsqldatabase_rows_forwardOnly(CallContext *ctx) +static void qmlsqldatabase_rows_forwardOnly(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) { - QV4::Scope scope(ctx); - QV4::Scoped r(scope, ctx->thisObject().as()); + QV4::Scoped r(scope, callData->thisObject.as()); if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows) V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); - return Encode(r->d()->sqlQuery->isForwardOnly()); + RETURN_RESULT(Encode(r->d()->sqlQuery->isForwardOnly())); } -static ReturnedValue qmlsqldatabase_rows_setForwardOnly(CallContext *ctx) +static void qmlsqldatabase_rows_setForwardOnly(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) { - QV4::Scope scope(ctx); - QV4::Scoped r(scope, ctx->thisObject().as()); + QV4::Scoped r(scope, callData->thisObject.as()); if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows) V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); - if (ctx->argc() < 1) - return ctx->engine()->throwTypeError(); + if (callData->argc < 1) + RETURN_RESULT(scope.engine->throwTypeError()); - r->d()->sqlQuery->setForwardOnly(ctx->args()[0].toBoolean()); - return Encode::undefined(); + r->d()->sqlQuery->setForwardOnly(callData->args[0].toBoolean()); + RETURN_UNDEFINED(); } QQmlSqlDatabaseData::~QQmlSqlDatabaseData() @@ -253,14 +249,13 @@ ReturnedValue QQmlSqlDatabaseWrapper::getIndexed(const Managed *m, uint index, b return qmlsqldatabase_rows_index(r, r->engine(), index, hasProperty); } -static ReturnedValue qmlsqldatabase_rows_item(CallContext *ctx) +static void qmlsqldatabase_rows_item(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) { - QV4::Scope scope(ctx); - QV4::Scoped r(scope, ctx->thisObject().as()); + QV4::Scoped r(scope, callData->thisObject.as()); if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows) V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); - return qmlsqldatabase_rows_index(r, scope.engine, ctx->argc() ? ctx->args()[0].toUInt32() : 0); + RETURN_RESULT(qmlsqldatabase_rows_index(r, scope.engine, callData->argc ? callData->args[0].toUInt32() : 0)); } static QVariant toSqlVariant(QV4::ExecutionEngine *engine, const QV4::ScopedValue &value) @@ -272,10 +267,9 @@ static QVariant toSqlVariant(QV4::ExecutionEngine *engine, const QV4::ScopedValu return engine->toVariant(value, /*typehint*/-1); } -static ReturnedValue qmlsqldatabase_executeSql(CallContext *ctx) +static void qmlsqldatabase_executeSql(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) { - QV4::Scope scope(ctx); - QV4::Scoped r(scope, ctx->thisObject().as()); + QV4::Scoped r(scope, callData->thisObject.as()); if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Query) V4THROW_REFERENCE("Not a SQLDatabase::Query object"); @@ -284,7 +278,7 @@ static ReturnedValue qmlsqldatabase_executeSql(CallContext *ctx) QSqlDatabase db = *r->d()->database; - QString sql = ctx->argc() ? ctx->args()[0].toQString() : QString(); + QString sql = callData->argc ? callData->args[0].toQString() : QString(); if (r->d()->readonly && !sql.startsWith(QLatin1String("SELECT"),Qt::CaseInsensitive)) { V4THROW_SQL(SQLEXCEPTION_SYNTAX_ERR, QQmlEngine::tr("Read-only Transaction")); @@ -296,8 +290,8 @@ static ReturnedValue qmlsqldatabase_executeSql(CallContext *ctx) ScopedValue result(scope, Primitive::undefinedValue()); if (query.prepare(sql)) { - if (ctx->argc() > 1) { - ScopedValue values(scope, ctx->args()[1]); + if (callData->argc > 1) { + ScopedValue values(scope, callData->args[1]); if (values->as()) { ScopedArrayObject array(scope, values); quint32 size = array->getLength(); @@ -351,7 +345,7 @@ static ReturnedValue qmlsqldatabase_executeSql(CallContext *ctx) if (err) V4THROW_SQL(SQLEXCEPTION_DATABASE_ERR,query.lastError().text()); - return result->asReturnedValue(); + RETURN_RESULT(result->asReturnedValue()); } struct TransactionRollback { @@ -383,21 +377,19 @@ struct TransactionRollback { }; -static ReturnedValue qmlsqldatabase_changeVersion(CallContext *ctx) +static void qmlsqldatabase_changeVersion(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) { - if (ctx->argc() < 2) - return Encode::undefined(); - - Scope scope(ctx); + if (callData->argc < 2) + RETURN_UNDEFINED(); - Scoped r(scope, ctx->thisObject()); + Scoped r(scope, callData->thisObject); if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Database) V4THROW_REFERENCE("Not a SQLDatabase object"); QSqlDatabase db = *r->d()->database; - QString from_version = ctx->args()[0].toQString(); - QString to_version = ctx->args()[1].toQString(); - ScopedFunctionObject callback(scope, ctx->argument(2)); + QString from_version = callData->args[0].toQString(); + QString to_version = callData->args[1].toQString(); + ScopedFunctionObject callback(scope, callData->argc > 2 ? callData->args[2] : Primitive::undefinedValue()); if (from_version != *r->d()->version) V4THROW_SQL(SQLEXCEPTION_VERSION_ERR, QQmlEngine::tr("Version mismatch: expected %1, found %2").arg(from_version).arg(*r->d()->version)); @@ -438,17 +430,16 @@ static ReturnedValue qmlsqldatabase_changeVersion(CallContext *ctx) #endif } - return Encode::undefined(); + RETURN_UNDEFINED(); } -static ReturnedValue qmlsqldatabase_transaction_shared(CallContext *ctx, bool readOnly) +static void qmlsqldatabase_transaction_shared(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData, bool readOnly) { - QV4::Scope scope(ctx); - QV4::Scoped r(scope, ctx->thisObject().as()); + QV4::Scoped r(scope, callData->thisObject.as()); if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Database) V4THROW_REFERENCE("Not a SQLDatabase object"); - const FunctionObject *callback = ctx->argc() ? ctx->args()[0].as() : 0; + const FunctionObject *callback = callData->argc ? callData->args[0].as() : 0; if (!callback) V4THROW_SQL(SQLEXCEPTION_UNKNOWN_ERR, QQmlEngine::tr("transaction: missing callback")); @@ -475,17 +466,17 @@ static ReturnedValue qmlsqldatabase_transaction_shared(CallContext *ctx, bool re db.rollback(); } - return Encode::undefined(); + RETURN_UNDEFINED(); } -static ReturnedValue qmlsqldatabase_transaction(CallContext *ctx) +static void qmlsqldatabase_transaction(const QV4::BuiltinFunction *f, QV4::Scope &scope, QV4::CallData *callData) { - return qmlsqldatabase_transaction_shared(ctx, false); + qmlsqldatabase_transaction_shared(f, scope, callData, false); } -static ReturnedValue qmlsqldatabase_read_transaction(CallContext *ctx) +static void qmlsqldatabase_read_transaction(const QV4::BuiltinFunction *f, QV4::Scope &scope, QV4::CallData *callData) { - return qmlsqldatabase_transaction_shared(ctx, true); + qmlsqldatabase_transaction_shared(f, scope, callData, true); } QQmlSqlDatabaseData::QQmlSqlDatabaseData(ExecutionEngine *v4) -- cgit v1.2.3 From 16105b1b0cf9dc3849d9ff03503fa8bed1b8da40 Mon Sep 17 00:00:00 2001 From: Marco Benelli Date: Fri, 19 May 2017 11:27:48 +0200 Subject: Update qmltypes Small update of qmltypes. Change-Id: I5408f0ae50a70ca1c1cc0c0deaa8ddf6458c88c1 Reviewed-by: Thomas Hartmann Reviewed-by: Erik Verbruggen --- src/imports/builtins/builtins.qmltypes | 3 ++- src/imports/qtquick2/plugins.qmltypes | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src/imports') diff --git a/src/imports/builtins/builtins.qmltypes b/src/imports/builtins/builtins.qmltypes index ac95a8837b..c2f8f5b521 100644 --- a/src/imports/builtins/builtins.qmltypes +++ b/src/imports/builtins/builtins.qmltypes @@ -426,7 +426,8 @@ Module { "WA_X11DoNotAcceptFocus": 126, "WA_MacNoShadow": 127, "WA_AlwaysStackOnTop": 128, - "WA_AttributeCount": 129 + "WA_TabletTracking": 129, + "WA_AttributeCount": 130 } } Enum { diff --git a/src/imports/qtquick2/plugins.qmltypes b/src/imports/qtquick2/plugins.qmltypes index a9534b5ccc..834b4bfac2 100644 --- a/src/imports/qtquick2/plugins.qmltypes +++ b/src/imports/qtquick2/plugins.qmltypes @@ -1414,7 +1414,7 @@ Module { Property { name: "source"; type: "QObject"; isPointer: true } Property { name: "target"; type: "QObject"; isReadonly: true; isPointer: true } Property { name: "hotSpot"; type: "QPointF" } - Property { name: "imageSource"; revision: 8; type: "QUrl" } + Property { name: "imageSource"; type: "QUrl" } Property { name: "keys"; type: "QStringList" } Property { name: "mimeData"; type: "QVariantMap" } Property { name: "supportedActions"; type: "Qt::DropActions" } -- cgit v1.2.3