diff options
Diffstat (limited to 'src/imports')
28 files changed, 170 insertions, 123 deletions
diff --git a/src/imports/folderlistmodel/plugin.cpp b/src/imports/folderlistmodel/plugin.cpp index ef719109bd..2b58a5677a 100644 --- a/src/imports/folderlistmodel/plugin.cpp +++ b/src/imports/folderlistmodel/plugin.cpp @@ -59,7 +59,7 @@ class QmlFolderListModelPlugin : public QQmlExtensionPlugin public: QmlFolderListModelPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.folderlistmodel")); qmlRegisterType<QQuickFolderListModel>(uri,1,0,"FolderListModel"); diff --git a/src/imports/handlers/plugin.cpp b/src/imports/handlers/plugin.cpp index bc1ae244d3..d26ef2b2d4 100644 --- a/src/imports/handlers/plugin.cpp +++ b/src/imports/handlers/plugin.cpp @@ -74,7 +74,7 @@ class QtQuickHandlersPlugin : public QQmlExtensionPlugin Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QtQuickHandlersPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.handlers")); Q_UNUSED(uri); diff --git a/src/imports/layouts/plugin.cpp b/src/imports/layouts/plugin.cpp index da5f264ab5..fc3938c5d8 100644 --- a/src/imports/layouts/plugin.cpp +++ b/src/imports/layouts/plugin.cpp @@ -61,7 +61,7 @@ public: { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.Layouts")); Q_UNUSED(uri); diff --git a/src/imports/layouts/qquicklayout.cpp b/src/imports/layouts/qquicklayout.cpp index df64b593d9..7d51ec3ca9 100644 --- a/src/imports/layouts/qquicklayout.cpp +++ b/src/imports/layouts/qquicklayout.cpp @@ -95,6 +95,8 @@ QQuickLayoutAttached::QQuickLayoutAttached(QObject *parent) m_maximumWidth(std::numeric_limits<qreal>::infinity()), m_maximumHeight(std::numeric_limits<qreal>::infinity()), m_defaultMargins(0), + m_fallbackWidth(-1), + m_fallbackHeight(-1), m_row(-1), m_column(-1), m_rowSpan(1), @@ -767,6 +769,12 @@ bool QQuickLayout::shouldIgnoreItem(QQuickItem *child, QQuickLayoutAttached *&in return ignoreItem; } +void QQuickLayout::checkAnchors(QQuickItem *item) const +{ + if (QQuickItemPrivate::get(item)->_anchors) + qmlWarning(item) << "Detected anchors on an item that is part of a layout. This is undefined behavior."; +} + void QQuickLayout::itemChange(ItemChange change, const ItemChangeData &value) { if (change == ItemChildAddedChange) { @@ -1049,39 +1057,32 @@ void QQuickLayout::effectiveSizeHints_helper(QQuickItem *item, QSizeF *cachedSiz prefHeight = qCeil(item->implicitHeight()); // If that fails, make an ultimate fallback to width/height - - if (!info && (prefWidth < 0 || prefHeight < 0)) - info = attachedLayoutObject(item); - - if (useFallbackToWidthOrHeight && info) { - /* This block is a bit hacky, but if we want to support using width/height - as preferred size hints in layouts, (which we think most people expect), - we only want to use the initial width. - This is because the width will change due to layout rearrangement, and the preferred - width should return the same value, regardless of the current width. - We therefore store the width in the implicitWidth attached property. - Since the layout listens to changes of implicitWidth, (it will - basically cause an invalidation of the layout), we have to disable that - notification while we set the implicit width (and height). - - Only use this fallback the first time the size hint is queried. Otherwise, we might - end up picking a width that is different than what was specified in the QML. + if (useFallbackToWidthOrHeight && !prefS.isValid()) { + /* If we want to support using width/height as preferred size hints in + layouts, (which we think most people expect), we only want to use the + initial width. + This is because the width will change due to layout rearrangement, + and the preferred width should return the same value, regardless of + the current width. + We therefore store this initial width in the attached layout object + and reuse it if needed rather than querying the width another time. + That means we need to ensure that an Layout attached object is available + by creating one if necessary. */ - if (prefWidth < 0 || prefHeight < 0) { - item->blockSignals(true); - if (prefWidth < 0) { - prefWidth = item->width(); - item->setImplicitWidth(prefWidth); - } - if (prefHeight < 0) { - prefHeight = item->height(); - item->setImplicitHeight(prefHeight); - } - item->blockSignals(false); - } - } + if (!info) + info = attachedLayoutObject(item); + auto updatePreferredSizes = [](qreal &cachedSize, qreal &attachedSize, qreal size) { + if (cachedSize < 0) { + if (attachedSize < 0) + attachedSize = size; + cachedSize = attachedSize; + } + }; + updatePreferredSizes(prefWidth, info->m_fallbackWidth, item->width()); + updatePreferredSizes(prefHeight, info->m_fallbackHeight, item->height()); + } // Normalize again after the implicit hints have been gathered expandSize(prefS, minS); diff --git a/src/imports/layouts/qquicklayout_p.h b/src/imports/layouts/qquicklayout_p.h index 113498eb2b..b31bffa290 100644 --- a/src/imports/layouts/qquicklayout_p.h +++ b/src/imports/layouts/qquicklayout_p.h @@ -75,7 +75,7 @@ public: static QQuickLayoutAttached *qmlAttachedProperties(QObject *object); - void componentComplete() Q_DECL_OVERRIDE; + void componentComplete() override; virtual QSizeF sizeHint(Qt::SizeHint whichSizeHint) const = 0; virtual void setAlignment(QQuickItem *item, Qt::Alignment align) = 0; virtual void invalidate(QQuickItem * childItem = 0); @@ -91,22 +91,23 @@ public: static void effectiveSizeHints_helper(QQuickItem *item, QSizeF *cachedSizeHints, QQuickLayoutAttached **info, bool useFallbackToWidthOrHeight); static QLayoutPolicy::Policy effectiveSizePolicy_helper(QQuickItem *item, Qt::Orientation orientation, QQuickLayoutAttached *info); bool shouldIgnoreItem(QQuickItem *child, QQuickLayoutAttached *&info, QSizeF *sizeHints) const; + void checkAnchors(QQuickItem *item) const; - void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE; - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; + void itemChange(ItemChange change, const ItemChangeData &value) override; + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; bool isReady() const; void deactivateRecur(); /* QQuickItemChangeListener */ - void itemSiblingOrderChanged(QQuickItem *item) Q_DECL_OVERRIDE; - void itemImplicitWidthChanged(QQuickItem *item) Q_DECL_OVERRIDE; - void itemImplicitHeightChanged(QQuickItem *item) Q_DECL_OVERRIDE; - void itemDestroyed(QQuickItem *item) Q_DECL_OVERRIDE; - void itemVisibilityChanged(QQuickItem *item) Q_DECL_OVERRIDE; + void itemSiblingOrderChanged(QQuickItem *item) override; + void itemImplicitWidthChanged(QQuickItem *item) override; + void itemImplicitHeightChanged(QQuickItem *item) override; + void itemDestroyed(QQuickItem *item) override; + void itemVisibilityChanged(QQuickItem *item) override; protected: - void updatePolish() Q_DECL_OVERRIDE; + void updatePolish() override; enum Orientation { Vertical = 0, @@ -294,6 +295,9 @@ private: qreal m_defaultMargins; QMarginsF m_margins; + qreal m_fallbackWidth; + qreal m_fallbackHeight; + // GridLayout specific properties int m_row; int m_column; diff --git a/src/imports/layouts/qquicklayoutstyleinfo_p.h b/src/imports/layouts/qquicklayoutstyleinfo_p.h index ce86c2a37d..79f4ce2962 100644 --- a/src/imports/layouts/qquicklayoutstyleinfo_p.h +++ b/src/imports/layouts/qquicklayoutstyleinfo_p.h @@ -49,9 +49,9 @@ class QQuickLayoutStyleInfo : public QAbstractLayoutStyleInfo public: QQuickLayoutStyleInfo(); - qreal spacing(Qt::Orientation orientation) const Q_DECL_OVERRIDE; - qreal windowMargin(Qt::Orientation orientation) const Q_DECL_OVERRIDE; - bool hasChangedCore() const Q_DECL_OVERRIDE; + qreal spacing(Qt::Orientation orientation) const override; + qreal windowMargin(Qt::Orientation orientation) const override; + bool hasChangedCore() const override; }; diff --git a/src/imports/layouts/qquicklinearlayout.cpp b/src/imports/layouts/qquicklinearlayout.cpp index 4410723f3d..db983e06ba 100644 --- a/src/imports/layouts/qquicklinearlayout.cpp +++ b/src/imports/layouts/qquicklinearlayout.cpp @@ -652,6 +652,7 @@ void QQuickGridLayout::insertLayoutItems() QSizeF sizeHints[Qt::NSizeHints]; const auto items = childItems(); for (QQuickItem *child : items) { + checkAnchors(child); QQuickLayoutAttached *info = 0; // Will skip all items with effective maximum width/height == 0 @@ -826,6 +827,7 @@ void QQuickLinearLayout::insertLayoutItems() const auto items = childItems(); for (QQuickItem *child : items) { Q_ASSERT(child); + checkAnchors(child); QQuickLayoutAttached *info = 0; // Will skip all items with effective maximum width/height == 0 diff --git a/src/imports/layouts/qquicklinearlayout_p.h b/src/imports/layouts/qquicklinearlayout_p.h index f796c8a855..6706ebf9fa 100644 --- a/src/imports/layouts/qquicklinearlayout_p.h +++ b/src/imports/layouts/qquicklinearlayout_p.h @@ -67,26 +67,26 @@ public: QQuickItem *parent = 0); ~QQuickGridLayoutBase(); - void componentComplete() Q_DECL_OVERRIDE; - void invalidate(QQuickItem *childItem = 0) Q_DECL_OVERRIDE; + void componentComplete() override; + void invalidate(QQuickItem *childItem = 0) override; Qt::Orientation orientation() const; void setOrientation(Qt::Orientation orientation); - QSizeF sizeHint(Qt::SizeHint whichSizeHint) const Q_DECL_OVERRIDE; + QSizeF sizeHint(Qt::SizeHint whichSizeHint) const override; Qt::LayoutDirection layoutDirection() const; void setLayoutDirection(Qt::LayoutDirection dir); Qt::LayoutDirection effectiveLayoutDirection() const; - void setAlignment(QQuickItem *item, Qt::Alignment align) Q_DECL_OVERRIDE; + void setAlignment(QQuickItem *item, Qt::Alignment align) override; /* QQuickItemChangeListener */ - void itemDestroyed(QQuickItem *item) Q_DECL_OVERRIDE; - void itemVisibilityChanged(QQuickItem *item) Q_DECL_OVERRIDE; + void itemDestroyed(QQuickItem *item) override; + void itemVisibilityChanged(QQuickItem *item) override; protected: - void updateLayoutItems() Q_DECL_OVERRIDE; - QQuickItem *itemAt(int index) const Q_DECL_OVERRIDE; - int itemCount() const Q_DECL_OVERRIDE; + void updateLayoutItems() override; + QQuickItem *itemAt(int index) const override; + int itemCount() const override; - void rearrange(const QSizeF &size) Q_DECL_OVERRIDE; + void rearrange(const QSizeF &size) override; virtual void insertLayoutItems() {} signals: @@ -109,7 +109,7 @@ public: , m_layoutDirection(Qt::LeftToRight) {} - void mirrorChange() Q_DECL_OVERRIDE + void mirrorChange() override { Q_Q(QQuickGridLayoutBase); q->invalidate(); diff --git a/src/imports/layouts/qquickstacklayout.cpp b/src/imports/layouts/qquickstacklayout.cpp index 9a7ec71473..cf70856e14 100644 --- a/src/imports/layouts/qquickstacklayout.cpp +++ b/src/imports/layouts/qquickstacklayout.cpp @@ -288,8 +288,11 @@ void QQuickStackLayout::updateLayoutItems() d->count = count; emit countChanged(); } - for (int i = 0; i < count; ++i) - itemAt(i)->setVisible(d->currentIndex == i); + for (int i = 0; i < count; ++i) { + QQuickItem *child = itemAt(i); + checkAnchors(child); + child->setVisible(d->currentIndex == i); + } invalidate(); } diff --git a/src/imports/layouts/qquickstacklayout_p.h b/src/imports/layouts/qquickstacklayout_p.h index 7b6400c3a3..8ba41720aa 100644 --- a/src/imports/layouts/qquickstacklayout_p.h +++ b/src/imports/layouts/qquickstacklayout_p.h @@ -56,16 +56,16 @@ public: int currentIndex() const; void setCurrentIndex(int index); - void componentComplete() Q_DECL_OVERRIDE; - QSizeF sizeHint(Qt::SizeHint whichSizeHint) const Q_DECL_OVERRIDE; - void setAlignment(QQuickItem *item, Qt::Alignment align) Q_DECL_OVERRIDE; - void invalidate(QQuickItem *childItem = 0) Q_DECL_OVERRIDE; - void updateLayoutItems() Q_DECL_OVERRIDE; - void rearrange(const QSizeF &) Q_DECL_OVERRIDE; + void componentComplete() override; + QSizeF sizeHint(Qt::SizeHint whichSizeHint) const override; + void setAlignment(QQuickItem *item, Qt::Alignment align) override; + void invalidate(QQuickItem *childItem = 0) override; + void updateLayoutItems() override; + void rearrange(const QSizeF &) override; // iterator - Q_INVOKABLE QQuickItem *itemAt(int index) const Q_DECL_OVERRIDE; - int itemCount() const Q_DECL_OVERRIDE; + Q_INVOKABLE QQuickItem *itemAt(int index) const override; + int itemCount() const override; int indexOf(QQuickItem *item) const; diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index 02cf125e48..9d78773fe1 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -58,6 +58,7 @@ #include <private/qv4functionobject_p.h> #include <private/qv4objectproto_p.h> #include <private/qv4scopedvalue_p.h> +#include <private/qv4jscall_p.h> #include <private/qv4objectiterator_p.h> static void initResources() @@ -164,8 +165,9 @@ DEFINE_OBJECT_VTABLE(QV4::QQmlSqlDatabaseWrapper); -static void qmlsqldatabase_version(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) +static ReturnedValue qmlsqldatabase_version(const QV4::BuiltinFunction *b, QV4::CallData *callData) { + Scope scope(b); QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, callData->thisObject.as<QQmlSqlDatabaseWrapper>()); if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Database) V4THROW_REFERENCE("Not a SQLDatabase object"); @@ -173,8 +175,9 @@ static void qmlsqldatabase_version(const QV4::BuiltinFunction *, QV4::Scope &sco RETURN_RESULT(Encode(scope.engine->newString(*r->d()->version))); } -static void qmlsqldatabase_rows_length(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) +static ReturnedValue qmlsqldatabase_rows_length(const QV4::BuiltinFunction *b, QV4::CallData *callData) { + Scope scope(b); QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, callData->thisObject.as<QQmlSqlDatabaseWrapper>()); if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows) V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); @@ -191,20 +194,22 @@ static void qmlsqldatabase_rows_length(const QV4::BuiltinFunction *, QV4::Scope RETURN_RESULT(Encode(s)); } -static void qmlsqldatabase_rows_forwardOnly(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) +static ReturnedValue qmlsqldatabase_rows_forwardOnly(const QV4::BuiltinFunction *b, QV4::CallData *callData) { + Scope scope(b); QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, callData->thisObject.as<QQmlSqlDatabaseWrapper>()); if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows) V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); RETURN_RESULT(Encode(r->d()->sqlQuery->isForwardOnly())); } -static void qmlsqldatabase_rows_setForwardOnly(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) +static ReturnedValue qmlsqldatabase_rows_setForwardOnly(const QV4::BuiltinFunction *b, QV4::CallData *callData) { + Scope scope(b); QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, callData->thisObject.as<QQmlSqlDatabaseWrapper>()); if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows) V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); - if (callData->argc < 1) + if (callData->argc() < 1) RETURN_RESULT(scope.engine->throwTypeError()); r->d()->sqlQuery->setForwardOnly(callData->args[0].toBoolean()); @@ -249,13 +254,14 @@ ReturnedValue QQmlSqlDatabaseWrapper::getIndexed(const Managed *m, uint index, b return qmlsqldatabase_rows_index(r, r->engine(), index, hasProperty); } -static void qmlsqldatabase_rows_item(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) +static ReturnedValue qmlsqldatabase_rows_item(const QV4::BuiltinFunction *b, QV4::CallData *callData) { + Scope scope(b); QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, callData->thisObject.as<QQmlSqlDatabaseWrapper>()); if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows) V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); - RETURN_RESULT(qmlsqldatabase_rows_index(r, scope.engine, callData->argc ? callData->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) @@ -267,8 +273,9 @@ static QVariant toSqlVariant(QV4::ExecutionEngine *engine, const QV4::ScopedValu return engine->toVariant(value, /*typehint*/-1); } -static void qmlsqldatabase_executeSql(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) +static ReturnedValue qmlsqldatabase_executeSql(const QV4::BuiltinFunction *b, QV4::CallData *callData) { + Scope scope(b); QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, callData->thisObject.as<QQmlSqlDatabaseWrapper>()); if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Query) V4THROW_REFERENCE("Not a SQLDatabase::Query object"); @@ -278,7 +285,7 @@ static void qmlsqldatabase_executeSql(const QV4::BuiltinFunction *, QV4::Scope & QSqlDatabase db = *r->d()->database; - QString sql = callData->argc ? callData->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")); @@ -290,7 +297,7 @@ static void qmlsqldatabase_executeSql(const QV4::BuiltinFunction *, QV4::Scope & ScopedValue result(scope, Primitive::undefinedValue()); if (query.prepare(sql)) { - if (callData->argc > 1) { + if (callData->argc() > 1) { ScopedValue values(scope, callData->args[1]); if (values->as<ArrayObject>()) { ScopedArrayObject array(scope, values); @@ -377,9 +384,10 @@ struct TransactionRollback { }; -static void qmlsqldatabase_changeVersion(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) +static ReturnedValue qmlsqldatabase_changeVersion(const QV4::BuiltinFunction *b, QV4::CallData *callData) { - if (callData->argc < 2) + Scope scope(b); + if (callData->argc() < 2) RETURN_UNDEFINED(); Scoped<QQmlSqlDatabaseWrapper> r(scope, callData->thisObject); @@ -389,7 +397,7 @@ static void qmlsqldatabase_changeVersion(const QV4::BuiltinFunction *, QV4::Scop QSqlDatabase db = *r->d()->database; 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()); + 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)); @@ -406,12 +414,12 @@ static void qmlsqldatabase_changeVersion(const QV4::BuiltinFunction *, QV4::Scop ok = false; db.transaction(); - ScopedCallData callData(scope, 1); - callData->thisObject = scope.engine->globalObject; - callData->args[0] = w; + JSCallData jsCall(scope, 1); + *jsCall->thisObject = scope.engine->globalObject; + jsCall->args[0] = w; TransactionRollback rollbackOnException(&db, &w->d()->inTransaction); - callback->call(scope, callData); + callback->call(jsCall); rollbackOnException.clear(); if (!db.commit()) { db.rollback(); @@ -433,13 +441,14 @@ static void qmlsqldatabase_changeVersion(const QV4::BuiltinFunction *, QV4::Scop RETURN_UNDEFINED(); } -static void qmlsqldatabase_transaction_shared(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData, bool readOnly) +static ReturnedValue qmlsqldatabase_transaction_shared(const QV4::BuiltinFunction *b, QV4::CallData *callData, bool readOnly) { + Scope scope(b); QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, callData->thisObject.as<QQmlSqlDatabaseWrapper>()); if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Database) V4THROW_REFERENCE("Not a SQLDatabase object"); - const FunctionObject *callback = callData->argc ? callData->args[0].as<FunctionObject>() : 0; + const FunctionObject *callback = callData->argc() ? callData->args[0].as<FunctionObject>() : 0; if (!callback) V4THROW_SQL(SQLEXCEPTION_UNKNOWN_ERR, QQmlEngine::tr("transaction: missing callback")); @@ -455,11 +464,11 @@ static void qmlsqldatabase_transaction_shared(const QV4::BuiltinFunction *, QV4: db.transaction(); if (callback) { - ScopedCallData callData(scope, 1); - callData->thisObject = scope.engine->globalObject; - callData->args[0] = w; + JSCallData jsCall(scope, 1); + *jsCall->thisObject = scope.engine->globalObject; + jsCall->args[0] = w; TransactionRollback rollbackOnException(&db, &w->d()->inTransaction); - callback->call(scope, callData); + callback->call(jsCall); rollbackOnException.clear(); if (!db.commit()) @@ -469,14 +478,14 @@ static void qmlsqldatabase_transaction_shared(const QV4::BuiltinFunction *, QV4: RETURN_UNDEFINED(); } -static void qmlsqldatabase_transaction(const QV4::BuiltinFunction *f, QV4::Scope &scope, QV4::CallData *callData) +static ReturnedValue qmlsqldatabase_transaction(const QV4::BuiltinFunction *f, QV4::CallData *callData) { - qmlsqldatabase_transaction_shared(f, scope, callData, false); + return qmlsqldatabase_transaction_shared(f, callData, false); } -static void qmlsqldatabase_read_transaction(const QV4::BuiltinFunction *f, QV4::Scope &scope, QV4::CallData *callData) +static ReturnedValue qmlsqldatabase_read_transaction(const QV4::BuiltinFunction *f, QV4::CallData *callData) { - qmlsqldatabase_transaction_shared(f, scope, callData, true); + return qmlsqldatabase_transaction_shared(f, callData, true); } QQmlSqlDatabaseData::QQmlSqlDatabaseData(ExecutionEngine *v4) @@ -754,10 +763,10 @@ void QQuickLocalStorage::openDatabaseSync(QQmlV4Function *args) *db->d()->version = version; if (created && dbcreationCallback) { - ScopedCallData callData(scope, 1); - callData->thisObject = scope.engine->globalObject; - callData->args[0] = db; - dbcreationCallback->call(scope, callData); + JSCallData jsCall(scope, 1); + *jsCall->thisObject = scope.engine->globalObject; + jsCall->args[0] = db; + dbcreationCallback->call(jsCall); } args->setReturnValue(db.asReturnedValue()); @@ -785,7 +794,7 @@ public: { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.LocalStorage")); qmlRegisterSingletonType<QQuickLocalStorage>(uri, 2, 0, "LocalStorage", module_api_factory); diff --git a/src/imports/models/plugin.cpp b/src/imports/models/plugin.cpp index dbb62cd25d..5933128713 100644 --- a/src/imports/models/plugin.cpp +++ b/src/imports/models/plugin.cpp @@ -78,7 +78,7 @@ class QtQmlModelsPlugin : public QQmlExtensionPlugin Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QtQmlModelsPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQml.Models")); Q_UNUSED(uri); diff --git a/src/imports/particles/plugin.cpp b/src/imports/particles/plugin.cpp index 28ce0f7796..f7a3472403 100644 --- a/src/imports/particles/plugin.cpp +++ b/src/imports/particles/plugin.cpp @@ -57,7 +57,7 @@ class QtQuick2ParticlesPlugin : public QQmlExtensionPlugin Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QtQuick2ParticlesPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.Particles")); Q_UNUSED(uri); diff --git a/src/imports/qtquick2/plugin.cpp b/src/imports/qtquick2/plugin.cpp index d16467a5bb..a5b2c8c67e 100644 --- a/src/imports/qtquick2/plugin.cpp +++ b/src/imports/qtquick2/plugin.cpp @@ -57,7 +57,7 @@ class QtQuick2Plugin : public QQmlExtensionPlugin Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QtQuick2Plugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick")); Q_UNUSED(uri); diff --git a/src/imports/settings/plugin.cpp b/src/imports/settings/plugin.cpp index c422296446..70d24c12cd 100644 --- a/src/imports/settings/plugin.cpp +++ b/src/imports/settings/plugin.cpp @@ -58,7 +58,7 @@ class QmlSettingsPlugin : public QQmlExtensionPlugin public: QmlSettingsPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QByteArray(uri) == QByteArray("Qt.labs.settings")); qmlRegisterType<QQmlSettings>(uri, 1, 0, "Settings"); diff --git a/src/imports/shapes/plugin.cpp b/src/imports/shapes/plugin.cpp index 545cfda0e4..e24826ee55 100644 --- a/src/imports/shapes/plugin.cpp +++ b/src/imports/shapes/plugin.cpp @@ -59,7 +59,7 @@ class QmlShapesPlugin : public QQmlExtensionPlugin public: QmlShapesPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QByteArray(uri) == QByteArray("QtQuick.Shapes")); qmlRegisterType<QQuickShape>(uri, 1, 0, "Shape"); diff --git a/src/imports/shapes/qquickshapenvprrenderer.cpp b/src/imports/shapes/qquickshapenvprrenderer.cpp index c0a918bda5..88f367fe70 100644 --- a/src/imports/shapes/qquickshapenvprrenderer.cpp +++ b/src/imports/shapes/qquickshapenvprrenderer.cpp @@ -43,6 +43,7 @@ #include <QOpenGLShaderProgram> #include <QOpenGLBuffer> #include <qmath.h> +#include <private/qpainterpath_p.h> #include <private/qquickpath_p_p.h> QT_BEGIN_NAMESPACE @@ -287,6 +288,30 @@ void QQuickShapeNvprRenderer::convertPath(const QQuickPath *path, ShapePathGuiDa if (d->path.str.isEmpty()) d->path.str = QString(QStringLiteral("M %1 %2 ")).arg(pos.x()).arg(pos.y()).toUtf8(); d->path.str.append(o->path().toUtf8()); + } else if (QQuickPathAngleArc *o = qobject_cast<QQuickPathAngleArc *>(e)) { + QRectF rect(o->centerX() - o->radiusX(), o->centerY() - o->radiusY(), o->radiusX() * 2, o->radiusY() * 2); + QPointF startPoint; + QPointF endPoint; + qt_find_ellipse_coords(rect, o->startAngle(), -o->sweepAngle(), &startPoint, &endPoint); + + // get to our starting position + if (o->moveToStart()) + d->path.cmd.append(GL_MOVE_TO_NV); + else + d->path.cmd.append(GL_LINE_TO_NV); // ### should we check if startPoint == pos? + d->path.coord.append(startPoint.x()); + d->path.coord.append(startPoint.y()); + + const bool sweepFlag = o->sweepAngle() > 0; // maps to CCW, not a typo + d->path.cmd.append(qAbs(o->sweepAngle()) > 180.0 + ? (sweepFlag ? GL_LARGE_CCW_ARC_TO_NV : GL_LARGE_CW_ARC_TO_NV) + : (sweepFlag ? GL_SMALL_CCW_ARC_TO_NV : GL_SMALL_CW_ARC_TO_NV)); + d->path.coord.append(o->radiusX()); + d->path.coord.append(o->radiusY()); + d->path.coord.append(0); // xAxisRotation + d->path.coord.append(endPoint.x()); + d->path.coord.append(endPoint.y()); + pos = endPoint; } else { qWarning() << "Shape/NVPR: unsupported Path element" << e; } diff --git a/src/imports/shapes/shapes.pro b/src/imports/shapes/shapes.pro index 99bad8ba6e..fee950a529 100644 --- a/src/imports/shapes/shapes.pro +++ b/src/imports/shapes/shapes.pro @@ -3,7 +3,7 @@ TARGET = qmlshapesplugin TARGETPATH = QtQuick/Shapes IMPORT_VERSION = 1.0 -QT = core gui qml quick quick-private +QT = core gui-private qml quick-private HEADERS += \ qquickshape_p.h \ diff --git a/src/imports/sharedimage/qsharedimageloader.cpp b/src/imports/sharedimage/qsharedimageloader.cpp index fb96a79187..ee862b6a77 100644 --- a/src/imports/sharedimage/qsharedimageloader.cpp +++ b/src/imports/sharedimage/qsharedimageloader.cpp @@ -117,7 +117,7 @@ void QSharedImageLoaderPrivate::storeImageToMem(void *data, const QImage &img) h->format = img.format(); uchar *p = static_cast<uchar *>(data) + sizeof(SharedImageHeader); - memcpy(p, img.constBits(), img.byteCount()); + memcpy(p, img.constBits(), img.sizeInBytes()); } @@ -174,8 +174,11 @@ QImage QSharedImageLoaderPrivate::load(const QString &path, QSharedImageLoader:: QImage img = q->loadFile(path, params); if (img.isNull()) return nil; - int size = sizeof(SharedImageHeader) + img.byteCount(); - if (shm->create(size)) { + size_t size = sizeof(SharedImageHeader) + img.sizeInBytes(); + if (size > std::numeric_limits<int>::max()) { + qCDebug(lcSharedImage) << "Image" << path << "to large to load"; + return nil; + } else if (shm->create(int(size))) { qCDebug(lcSharedImage) << "Created new shm segment of size" << size << "for image" << path; if (!shm->lock()) { qCDebug(lcSharedImage) << "Lock1 failed!?" << shm->errorString(); diff --git a/src/imports/sharedimage/qsharedimageloader_p.h b/src/imports/sharedimage/qsharedimageloader_p.h index 38e2bd4d54..4b0e989c29 100644 --- a/src/imports/sharedimage/qsharedimageloader_p.h +++ b/src/imports/sharedimage/qsharedimageloader_p.h @@ -58,10 +58,10 @@ class QSharedImageLoader : public QObject public: typedef QVector<QVariant> ImageParameters; - QSharedImageLoader(QObject *parent = Q_NULLPTR); + QSharedImageLoader(QObject *parent = nullptr); ~QSharedImageLoader(); - QImage load(const QString &path, ImageParameters *params = Q_NULLPTR); + QImage load(const QString &path, ImageParameters *params = nullptr); protected: virtual QImage loadFile(const QString &path, ImageParameters *params); diff --git a/src/imports/sharedimage/sharedimageprovider.cpp b/src/imports/sharedimage/sharedimageprovider.cpp index f33057936d..aad6ea3b78 100644 --- a/src/imports/sharedimage/sharedimageprovider.cpp +++ b/src/imports/sharedimage/sharedimageprovider.cpp @@ -60,7 +60,7 @@ public: NumImageParameters }; - QuickSharedImageLoader(QObject *parent = Q_NULLPTR) + QuickSharedImageLoader(QObject *parent = nullptr) : QSharedImageLoader(parent) { } diff --git a/src/imports/statemachine/plugin.cpp b/src/imports/statemachine/plugin.cpp index ae32f6446a..7308df8964 100644 --- a/src/imports/statemachine/plugin.cpp +++ b/src/imports/statemachine/plugin.cpp @@ -63,7 +63,7 @@ class QtQmlStateMachinePlugin : public QQmlExtensionPlugin public: QtQmlStateMachinePlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { qmlRegisterType<State>(uri, 1, 0, "State"); qmlRegisterType<StateMachine>(uri, 1, 0, "StateMachine"); diff --git a/src/imports/statemachine/signaltransition.cpp b/src/imports/statemachine/signaltransition.cpp index 0f88ec641b..aaf32f6d19 100644 --- a/src/imports/statemachine/signaltransition.cpp +++ b/src/imports/statemachine/signaltransition.cpp @@ -54,7 +54,7 @@ #include <private/qqmlboundsignal_p.h> SignalTransition::SignalTransition(QState *parent) - : QSignalTransition(this, SIGNAL(invokeYourself()), parent), m_complete(false), m_signalExpression(Q_NULLPTR) + : QSignalTransition(this, SIGNAL(invokeYourself()), parent), m_complete(false), m_signalExpression(nullptr) { connect(this, SIGNAL(signalChanged()), SIGNAL(qmlSignalChanged())); } diff --git a/src/imports/statemachine/signaltransition.h b/src/imports/statemachine/signaltransition.h index c6512e2b19..d7a3b7b618 100644 --- a/src/imports/statemachine/signaltransition.h +++ b/src/imports/statemachine/signaltransition.h @@ -59,13 +59,13 @@ class SignalTransition : public QSignalTransition, public QQmlParserStatus Q_PROPERTY(QQmlScriptString guard READ guard WRITE setGuard NOTIFY guardChanged) public: - explicit SignalTransition(QState *parent = Q_NULLPTR); + explicit SignalTransition(QState *parent = nullptr); QQmlScriptString guard() const; void setGuard(const QQmlScriptString &guard); - bool eventTest(QEvent *event) Q_DECL_OVERRIDE; - void onTransition(QEvent *event) Q_DECL_OVERRIDE; + bool eventTest(QEvent *event) override; + void onTransition(QEvent *event) override; const QJSValue &signal(); void setSignal(const QJSValue &signal); @@ -81,8 +81,8 @@ Q_SIGNALS: void qmlSignalChanged(); private: - void classBegin() Q_DECL_OVERRIDE { m_complete = false; } - void componentComplete() Q_DECL_OVERRIDE { m_complete = true; connectTriggered(); } + void classBegin() override { m_complete = false; } + void componentComplete() override { m_complete = true; connectTriggered(); } void connectTriggered(); friend class SignalTransitionParser; @@ -97,8 +97,8 @@ private: class SignalTransitionParser : public QQmlCustomParser { public: - void verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &props) Q_DECL_OVERRIDE; - void applyBindings(QObject *object, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) Q_DECL_OVERRIDE; + void verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &props) override; + void applyBindings(QObject *object, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override; }; QT_END_NAMESPACE diff --git a/src/imports/statemachine/timeouttransition.h b/src/imports/statemachine/timeouttransition.h index 0e5f5377e3..2fc850fc70 100644 --- a/src/imports/statemachine/timeouttransition.h +++ b/src/imports/statemachine/timeouttransition.h @@ -53,7 +53,7 @@ class TimeoutTransition : public QSignalTransition, public QQmlParserStatus Q_INTERFACES(QQmlParserStatus) public: - TimeoutTransition(QState *parent = Q_NULLPTR); + TimeoutTransition(QState *parent = nullptr); ~TimeoutTransition(); int timeout() const; diff --git a/src/imports/testlib/main.cpp b/src/imports/testlib/main.cpp index 0967cf80ab..00e9592557 100644 --- a/src/imports/testlib/main.cpp +++ b/src/imports/testlib/main.cpp @@ -151,7 +151,7 @@ class QTestQmlModule : public QQmlExtensionPlugin public: QTestQmlModule(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtTest")); qmlRegisterType<QuickTestResult, 0>(uri,1,0,"TestResult"); diff --git a/src/imports/window/plugin.cpp b/src/imports/window/plugin.cpp index 200f6f7b08..c4ea9a1d04 100644 --- a/src/imports/window/plugin.cpp +++ b/src/imports/window/plugin.cpp @@ -73,7 +73,7 @@ class QtQuick2WindowPlugin : public QQmlExtensionPlugin Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QtQuick2WindowPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.Window")); Q_UNUSED(uri); diff --git a/src/imports/xmllistmodel/plugin.cpp b/src/imports/xmllistmodel/plugin.cpp index af7625c96a..dc6a02918b 100644 --- a/src/imports/xmllistmodel/plugin.cpp +++ b/src/imports/xmllistmodel/plugin.cpp @@ -58,7 +58,7 @@ class QmlXmlListModelPlugin : public QQmlExtensionPlugin public: QmlXmlListModelPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.XmlListModel")); qmlRegisterType<QQuickXmlListModel>(uri,2,0,"XmlListModel"); |