From 38bac80aea1c2bd58acb10000e9a3daa65bba503 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 21 Aug 2019 10:03:31 +0200 Subject: Document that QQmlPropertyMap's meta object is not threadsafe It is generated and modified at runtime, so applications have to synchronize access explicitly. Fixes: QTBUG-70915 Change-Id: Ie6f29eef8532e2fa4ebf8dad1678cd2acbacf659 Reviewed-by: Ulf Hermann Reviewed-by: Volker Hilsheimer --- src/qml/util/qqmlpropertymap.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/qml') diff --git a/src/qml/util/qqmlpropertymap.cpp b/src/qml/util/qqmlpropertymap.cpp index 3f78ca6b69..82f048d9d9 100644 --- a/src/qml/util/qqmlpropertymap.cpp +++ b/src/qml/util/qqmlpropertymap.cpp @@ -180,6 +180,10 @@ int QQmlPropertyMapMetaObject::createProperty(const char *name, const char *valu \note When deriving a class from QQmlPropertyMap, use the \l {QQmlPropertyMap::QQmlPropertyMap(DerivedType *derived, QObject *parent)} {protected two-argument constructor} which ensures that the class is correctly registered with the Qt \l {Meta-Object System}. + + \note The QMetaObject of a QQmlPropertyMap is dynamically generated and modified. + Operations on that meta object are not thread safe, so applications need to take + care to explicitly synchronize access to the meta object. */ /*! -- cgit v1.2.3 From 4b944cb61fb3ceee2f1b743823e4a83b686bafd6 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 26 Aug 2019 11:48:48 +0200 Subject: Fix loading of ES modules when using CONFIG += qtquickcompiler Added the missing lookup for cached .mjs files in ExecutionEngine::compileModule. This allows using .mjs files in WorkerScript {} elements in conjunction with the Qt Quick Compiler and also fixes the use when using QJSEngine::importModule. [ChangeLog][QtQml] Fix loading of EcmaScript modules when using the Qt Quick Compiler. Fixes: QTBUG-77761 Change-Id: I58130b0468f4920b2f6c49b98a2f51d5ae3a0491 Reviewed-by: Ulf Hermann Reviewed-by: Fabian Kosmale --- src/qml/jsruntime/qv4engine.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/qml') diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index b6000dbcca..f9747207db 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -1743,6 +1743,13 @@ ReturnedValue ExecutionEngine::global() QQmlRefPointer ExecutionEngine::compileModule(const QUrl &url) { + QQmlMetaType::CachedUnitLookupError cacheError = QQmlMetaType::CachedUnitLookupError::NoError; + if (const QV4::CompiledData::Unit *cachedUnit = QQmlMetaType::findCachedCompilationUnit(url, &cacheError)) { + QQmlRefPointer jsUnit; + jsUnit.adopt(new QV4::CompiledData::CompilationUnit(cachedUnit, url.fileName(), url.toString())); + return jsUnit; + } + QFile f(QQmlFile::urlToLocalFileOrQrc(url)); if (!f.open(QIODevice::ReadOnly)) { throwError(QStringLiteral("Could not open module %1 for reading").arg(url.toString())); -- cgit v1.2.3 From 1dc3f4c24583e14dee3c5fa650a8ac239b953458 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Thu, 18 Jul 2019 15:18:31 +0200 Subject: Doc: Fix documentation warnings for qtdeclarative After recent changes to QDoc, it now correctly warns about missing documentation for QML method parameters - fix all of these and also do some minor language editing. Remove duplicated entries for - \qmlmodule Qt.labs.qmlmodels - \group qtjavascript as they were causing issues. Change-Id: I55cd670cc8a0cc6427cdb7945dbd7c28ea94f796 Reviewed-by: Mitch Curtis --- .../doc/src/cppintegration/extending-tutorial.qdoc | 3 +- src/qml/doc/src/javascript/qtjavascript.qdoc | 7 - src/qml/doc/src/javascript/string.qdoc | 4 +- src/qml/jsapi/qjsengine.cpp | 4 +- src/qml/qml/ftw/qintrusivelist.cpp | 4 + src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 198 ++++++++++++--------- src/qml/types/qqmldelegatecomponent.cpp | 13 -- src/qml/types/qqmldelegatemodel.cpp | 4 +- src/qml/types/qqmlobjectmodel.cpp | 8 +- 9 files changed, 128 insertions(+), 117 deletions(-) (limited to 'src/qml') diff --git a/src/qml/doc/src/cppintegration/extending-tutorial.qdoc b/src/qml/doc/src/cppintegration/extending-tutorial.qdoc index 26556644d6..43987354ae 100644 --- a/src/qml/doc/src/cppintegration/extending-tutorial.qdoc +++ b/src/qml/doc/src/cppintegration/extending-tutorial.qdoc @@ -407,8 +407,7 @@ located at the same level as the application that uses our new import module. This way, the QML engine will find our module as the default search path for QML imports includes the directory of the application executable. On \macos, the plugin binary is copied to \c Contents/PlugIns in the the application bundle; -this path is set in \l {tutorials/extending-qml/chapter6-plugins/app.pro} -{chapter6-plugins/app.pro}: +this path is set in \c {chapter6-plugins/app.pro}: \quotefromfile tutorials/extending-qml/chapter6-plugins/app.pro \skipto osx diff --git a/src/qml/doc/src/javascript/qtjavascript.qdoc b/src/qml/doc/src/javascript/qtjavascript.qdoc index ad93d9d9ac..aa4dce6a37 100644 --- a/src/qml/doc/src/javascript/qtjavascript.qdoc +++ b/src/qml/doc/src/javascript/qtjavascript.qdoc @@ -25,13 +25,6 @@ ** ****************************************************************************/ -/*! - \group qtjavascript - \title Scripting Classes and Overviews - - \brief Classes for embedding JavaScript in Qt/C++ applications. -*/ - /*! \page qtjavascript.html \title Making Applications Scriptable diff --git a/src/qml/doc/src/javascript/string.qdoc b/src/qml/doc/src/javascript/string.qdoc index f896af3378..47922ff17a 100644 --- a/src/qml/doc/src/javascript/string.qdoc +++ b/src/qml/doc/src/javascript/string.qdoc @@ -39,8 +39,8 @@ /*! \qmlmethod string String::arg(value) - Returns a copy of this string with the lowest numbered place marker replaced by value, - i.e., %1, %2, ..., %99. The following example prints "There are 20 items" + Returns a copy of this string with the lowest numbered place marker replaced by \a value, + i.e., %1, %2, ..., %99. The following example prints "There are 20 items": \code var message = "There are %1 items" diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp index aab72f8b2d..c41738c811 100644 --- a/src/qml/jsapi/qjsengine.cpp +++ b/src/qml/jsapi/qjsengine.cpp @@ -585,7 +585,9 @@ QJSValue QJSEngine::newObject() /*! \since 5.12 - Creates a JavaScript object of class Error. + + Creates a JavaScript object of class Error, with \a message as the error + message. The prototype of the created object will be \a errorType. diff --git a/src/qml/qml/ftw/qintrusivelist.cpp b/src/qml/qml/ftw/qintrusivelist.cpp index eb337a4de0..2ebaffb375 100644 --- a/src/qml/qml/ftw/qintrusivelist.cpp +++ b/src/qml/qml/ftw/qintrusivelist.cpp @@ -150,6 +150,10 @@ Returns an STL-style iterator pointing to the imaginary item after the last item Remove the current object from the list, and return an iterator to the next element. */ +/*! + \class QIntrusiveListNode + \internal +*/ /*! \fn QIntrusiveListNode::QIntrusiveListNode() diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 64dc581a56..4422195e3d 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -229,8 +229,10 @@ OwnPropertyKeyIterator *QtObject::virtualOwnPropertyKeys(const Object *m, Value } /*! -\qmlmethod bool Qt::isQtObject(object) -Returns true if \c object is a valid reference to a Qt or QML object, otherwise false. + \qmlmethod bool Qt::isQtObject(object) + + Returns \c true if \a object is a valid reference to a Qt or QML object, + \c false otherwise. */ ReturnedValue QtObject::method_isQtObject(const FunctionObject *, const Value *, const Value *argv, int argc) { @@ -241,10 +243,10 @@ ReturnedValue QtObject::method_isQtObject(const FunctionObject *, const Value *, } /*! -\qmlmethod color Qt::rgba(real red, real green, real blue, real alpha) + \qmlmethod color Qt::rgba(real red, real green, real blue, real alpha) -Returns a color with the specified \c red, \c green, \c blue and \c alpha components. -All components should be in the range 0-1 inclusive. + Returns a color with the specified \a red, \a green, \a blue, and \a alpha + components. All components should be in the range 0-1 (inclusive). */ ReturnedValue QtObject::method_rgba(const FunctionObject *f, const Value *, const Value *argv, int argc) { @@ -270,10 +272,10 @@ ReturnedValue QtObject::method_rgba(const FunctionObject *f, const Value *, cons } /*! -\qmlmethod color Qt::hsla(real hue, real saturation, real lightness, real alpha) + \qmlmethod color Qt::hsla(real hue, real saturation, real lightness, real alpha) -Returns a color with the specified \c hue, \c saturation, \c lightness and \c alpha components. -All components should be in the range 0-1 inclusive. + Returns a color with the specified \a hue, \a saturation, \a lightness, and \a alpha + components. All components should be in the range 0-1 (inclusive). */ ReturnedValue QtObject::method_hsla(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -300,12 +302,12 @@ ReturnedValue QtObject::method_hsla(const FunctionObject *b, const Value *, cons } /*! -\qmlmethod color Qt::hsva(real hue, real saturation, real value, real alpha) + \since 5.5 + \qmlmethod color Qt::hsva(real hue, real saturation, real value, real alpha) -Returns a color with the specified \c hue, \c saturation, \c value and \c alpha components. -All components should be in the range 0-1 inclusive. + Returns a color with the specified \a hue, \a saturation, \a value and \a alpha + components. All components should be in the range 0-1 (inclusive). -\since 5.5 */ ReturnedValue QtObject::method_hsva(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -328,12 +330,12 @@ ReturnedValue QtObject::method_hsva(const FunctionObject *b, const Value *, cons } /*! -\qmlmethod color Qt::colorEqual(color lhs, string rhs) + \qmlmethod color Qt::colorEqual(color lhs, string rhs) -Returns true if both \c lhs and \c rhs yield equal color values. Both arguments -may be either color values or string values. If a string value is supplied it -must be convertible to a color, as described for the \l{colorbasictypedocs}{color} -basic type. + Returns \c true if both \a lhs and \a rhs yield equal color values. Both + arguments may be either color values or string values. If a string value + is supplied it must be convertible to a color, as described for the + \l{colorbasictypedocs}{color} basic type. */ ReturnedValue QtObject::method_colorEqual(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -368,11 +370,9 @@ ReturnedValue QtObject::method_colorEqual(const FunctionObject *b, const Value * } /*! -\qmlmethod rect Qt::rect(int x, int y, int width, int height) - -Returns a \c rect with the top-left corner at \c x, \c y and the specified \c width and \c height. + \qmlmethod rect Qt::rect(int x, int y, int width, int height) -The returned object has \c x, \c y, \c width and \c height attributes with the given values. + Returns a rect with the top-left corner at \a x, \a y and the specified \a width and \a height. */ ReturnedValue QtObject::method_rect(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -389,8 +389,9 @@ ReturnedValue QtObject::method_rect(const FunctionObject *b, const Value *, cons } /*! -\qmlmethod point Qt::point(int x, int y) -Returns a Point with the specified \c x and \c y coordinates. + \qmlmethod point Qt::point(int x, int y) + + Returns a point with the specified \a x and \a y coordinates. */ ReturnedValue QtObject::method_point(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -405,8 +406,9 @@ ReturnedValue QtObject::method_point(const FunctionObject *b, const Value *, con } /*! -\qmlmethod Qt::size(int width, int height) -Returns a Size with the specified \c width and \c height. + \qmlmethod size Qt::size(int width, int height) + + Returns a size with the specified \a width and \a height. */ ReturnedValue QtObject::method_size(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -421,12 +423,13 @@ ReturnedValue QtObject::method_size(const FunctionObject *b, const Value *, cons } /*! -\qmlmethod Qt::font(object fontSpecifier) -Returns a Font with the properties specified in the \c fontSpecifier object -or the nearest matching font. The \c fontSpecifier object should contain -key-value pairs where valid keys are the \l{fontbasictypedocs}{font} type's -subproperty names, and the values are valid values for each subproperty. -Invalid keys will be ignored. + \qmlmethod font Qt::font(object fontSpecifier) + + Returns a font with the properties specified in the \a fontSpecifier object + or the nearest matching font. The \a fontSpecifier object should contain + key-value pairs where valid keys are the \l{fontbasictypedocs}{font} type's + subproperty names, and the values are valid values for each subproperty. + Invalid keys will be ignored. */ ReturnedValue QtObject::method_font(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -445,8 +448,9 @@ ReturnedValue QtObject::method_font(const FunctionObject *b, const Value *, cons /*! -\qmlmethod Qt::vector2d(real x, real y) -Returns a Vector2D with the specified \c x and \c y. + \qmlmethod vector2d Qt::vector2d(real x, real y) + + Returns a vector2d with the specified \a x and \a y values. */ ReturnedValue QtObject::method_vector2d(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -463,8 +467,9 @@ ReturnedValue QtObject::method_vector2d(const FunctionObject *b, const Value *, } /*! -\qmlmethod Qt::vector3d(real x, real y, real z) -Returns a Vector3D with the specified \c x, \c y and \c z. + \qmlmethod vector3d Qt::vector3d(real x, real y, real z) + + Returns a vector3d with the specified \a x, \a y, and \a z values. */ ReturnedValue QtObject::method_vector3d(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -482,8 +487,9 @@ ReturnedValue QtObject::method_vector3d(const FunctionObject *b, const Value *, } /*! -\qmlmethod Qt::vector4d(real x, real y, real z, real w) -Returns a Vector4D with the specified \c x, \c y, \c z and \c w. + \qmlmethod vector4d Qt::vector4d(real x, real y, real z, real w) + + Returns a vector4d with the specified \a x, \a y, \a z, and \a w values. */ ReturnedValue QtObject::method_vector4d(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -502,8 +508,9 @@ ReturnedValue QtObject::method_vector4d(const FunctionObject *b, const Value *, } /*! -\qmlmethod Qt::quaternion(real scalar, real x, real y, real z) -Returns a Quaternion with the specified \c scalar, \c x, \c y, and \c z. + \qmlmethod quaternion Qt::quaternion(real scalar, real x, real y, real z) + + Returns a quaternion with the specified \a scalar, \a x, \a y, and \a z values. */ ReturnedValue QtObject::method_quaternion(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -522,13 +529,25 @@ ReturnedValue QtObject::method_quaternion(const FunctionObject *b, const Value * } /*! -\qmlmethod Qt::matrix4x4(real m11, real m12, real m13, real m14, real m21, real m22, real m23, real m24, real m31, real m32, real m33, real m34, real m41, real m42, real m43, real m44) -Returns a Matrix4x4 with the specified values. -Alternatively, the function may be called with a single argument -where that argument is a JavaScript array which contains the sixteen -matrix values. -Finally, the function may be called with no arguments and the resulting -matrix will be the identity matrix. + \qmlmethod matrix4x4 Qt::matrix4x4(real m11, real m12, real m13, real m14, real m21, real m22, real m23, real m24, real m31, real m32, real m33, real m34, real m41, real m42, real m43, real m44) + + Returns a matrix4x4 with the specified values. + + The arguments correspond to their positions in the matrix: + + \table + \row \li \a m11 \li \a m12 \li \a m13 \li \a m14 + \row \li \a m21 \li \a m22 \li \a m23 \li \a m24 + \row \li \a m31 \li \a m32 \li \a m33 \li \a m34 + \row \li \a m41 \li \a m42 \li \a m43 \li \a m44 + \endtable + + Alternatively, the function may be called with a single argument + where that argument is a JavaScript array which contains the sixteen + matrix values. + + Finally, the function may be called with no arguments and the resulting + matrix will be the identity matrix. */ ReturnedValue QtObject::method_matrix4x4(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -572,18 +591,19 @@ ReturnedValue QtObject::method_matrix4x4(const FunctionObject *b, const Value *, } /*! -\qmlmethod color Qt::lighter(color baseColor, real factor) -Returns a color lighter than \c baseColor by the \c factor provided. + \qmlmethod color Qt::lighter(color baseColor, real factor) + + Returns a color lighter than \a baseColor by the \a factor provided. -If the factor is greater than 1.0, this functions returns a lighter color. -Setting factor to 1.5 returns a color that is 50% brighter. If the factor is less than 1.0, -the return color is darker, but we recommend using the Qt.darker() function for this purpose. -If the factor is 0 or negative, the return value is unspecified. + If the factor is greater than 1.0, this functions returns a lighter color. + Setting factor to 1.5 returns a color that is 50% brighter. If the factor is less than 1.0, + the return color is darker, but we recommend using the Qt.darker() function for this purpose. + If the factor is 0 or negative, the return value is unspecified. -The function converts the current RGB color to HSV, multiplies the value (V) component -by factor and converts the color back to RGB. + The function converts the current RGB color to HSV, multiplies the value (V) component + by factor and converts the color back to RGB. -If \c factor is not supplied, returns a color 50% lighter than \c baseColor (factor 1.5). + If \a factor is not supplied, returns a color that is 50% lighter than \a baseColor (factor 1.5). */ ReturnedValue QtObject::method_lighter(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -610,19 +630,20 @@ ReturnedValue QtObject::method_lighter(const FunctionObject *b, const Value *, c } /*! -\qmlmethod color Qt::darker(color baseColor, real factor) -Returns a color darker than \c baseColor by the \c factor provided. + \qmlmethod color Qt::darker(color baseColor, real factor) -If the factor is greater than 1.0, this function returns a darker color. -Setting factor to 3.0 returns a color that has one-third the brightness. -If the factor is less than 1.0, the return color is lighter, but we recommend using -the Qt.lighter() function for this purpose. If the factor is 0 or negative, the return -value is unspecified. + Returns a color darker than \a baseColor by the \a factor provided. -The function converts the current RGB color to HSV, divides the value (V) component -by factor and converts the color back to RGB. + If the factor is greater than 1.0, this function returns a darker color. + Setting factor to 3.0 returns a color that has one-third the brightness. + If the factor is less than 1.0, the return color is lighter, but we recommend using + the Qt.lighter() function for this purpose. If the factor is 0 or negative, the return + value is unspecified. -If \c factor is not supplied, returns a color 50% darker than \c baseColor (factor 2.0). + The function converts the current RGB color to HSV, divides the value (V) component + by factor and converts the color back to RGB. + + If \a factor is not supplied, returns a color that is 50% darker than \a baseColor (factor 2.0). */ ReturnedValue QtObject::method_darker(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -650,7 +671,8 @@ ReturnedValue QtObject::method_darker(const FunctionObject *b, const Value *, co /*! \qmlmethod color Qt::tint(color baseColor, color tintColor) - This function allows tinting one color with another. + + This function allows tinting one color (\a baseColor) with another (\a tintColor). The tint color should usually be mostly transparent, or you will not be able to see the underlying color. The below example provides a slight red @@ -670,7 +692,8 @@ ReturnedValue QtObject::method_darker(const FunctionObject *b, const Value *, co \endqml \image declarative-rect_tint.png - Tint is most useful when a subtle change is intended to be conveyed due to some event; you can then use tinting to more effectively tune the visible color. + Tint is most useful when a subtle change is intended to be conveyed due to some event; + you can then use tinting to more effectively tune the visible color. */ ReturnedValue QtObject::method_tint(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -708,8 +731,8 @@ ReturnedValue QtObject::method_tint(const FunctionObject *b, const Value *, cons /*! \qmlmethod string Qt::formatDate(datetime date, variant format) -Returns a string representation of \c date, optionally formatted according -to \c format. +Returns a string representation of \a date, optionally formatted according +to \a format. The \a date parameter may be a JavaScript \c Date object, a \l{date}{date} property, a QDate, or QDateTime value. The \a format parameter may be any of @@ -752,8 +775,8 @@ ReturnedValue QtObject::method_formatDate(const FunctionObject *b, const Value * /*! \qmlmethod string Qt::formatTime(datetime time, variant format) -Returns a string representation of \c time, optionally formatted according to -\c format. +Returns a string representation of \a time, optionally formatted according to +\a format. The \a time parameter may be a JavaScript \c Date object, a QTime, or QDateTime value. The \a format parameter may be any of the possible format values as @@ -801,10 +824,10 @@ ReturnedValue QtObject::method_formatTime(const FunctionObject *b, const Value * /*! \qmlmethod string Qt::formatDateTime(datetime dateTime, variant format) -Returns a string representation of \c datetime, optionally formatted according to -\c format. +Returns a string representation of \a dateTime, optionally formatted according to +\a format. -The \a date parameter may be a JavaScript \c Date object, a \l{date}{date} +The \a dateTime parameter may be a JavaScript \c Date object, a \l{date}{date} property, a QDate, QTime, or QDateTime value. If \a format is not provided, \a dateTime is formatted using @@ -921,8 +944,8 @@ ReturnedValue QtObject::method_formatDateTime(const FunctionObject *b, const Val /*! \qmlmethod bool Qt::openUrlExternally(url target) - Attempts to open the specified \c target url in an external application, based on the user's - desktop preferences. Returns true if it succeeds, and false otherwise. + Attempts to open the specified \a target url in an external application, based on the user's + desktop preferences. Returns \c true if it succeeds, \c false otherwise. \warning A return value of \c true indicates that the application has successfully requested the operating system to open the URL in an external application. The external application may @@ -942,6 +965,7 @@ ReturnedValue QtObject::method_openUrlExternally(const FunctionObject *b, const /*! \qmlmethod url Qt::resolvedUrl(url url) + Returns \a url resolved relative to the URL of the caller. */ ReturnedValue QtObject::method_resolvedUrl(const FunctionObject *b, const Value *, const Value *argv, int argc) @@ -967,6 +991,7 @@ ReturnedValue QtObject::method_resolvedUrl(const FunctionObject *b, const Value /*! \qmlmethod list Qt::fontFamilies() + Returns a list of the font families available to the application. */ ReturnedValue QtObject::method_fontFamilies(const FunctionObject *b, const Value *, const Value *, int argc) @@ -980,7 +1005,7 @@ ReturnedValue QtObject::method_fontFamilies(const FunctionObject *b, const Value /*! \qmlmethod string Qt::md5(data) -Returns a hex string of the md5 hash of \c data. +Returns a hex string of the md5 hash of \a data. */ ReturnedValue QtObject::method_md5(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -995,7 +1020,7 @@ ReturnedValue QtObject::method_md5(const FunctionObject *b, const Value *, const /*! \qmlmethod string Qt::btoa(data) -Binary to ASCII - this function returns a base64 encoding of \c data. +Binary to ASCII - this function returns a base64 encoding of \a data. */ ReturnedValue QtObject::method_btoa(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -1043,9 +1068,9 @@ ReturnedValue QtObject::method_quit(const FunctionObject *b, const Value *, cons This function causes the QQmlEngine::exit(int) signal to be emitted. Within the \l {Prototyping with qmlscene}, this causes the launcher application to exit - the specified return code. To exit from the event loop with a specified return code when this - method is called, a C++ application can connect the QQmlEngine::exit(int) signal - to the QCoreApplication::exit(int) slot. + the specified return code (\a retCode). To exit from the event loop with a specified + return code when this method is called, a C++ application can connect the + QQmlEngine::exit(int) signal to the QCoreApplication::exit(int) slot. \sa quit() */ @@ -1318,13 +1343,13 @@ ReturnedValue QtObject::method_createComponent(const FunctionObject *b, const Va \qmlmethod Qt::locale(name) Returns a JS object representing the locale with the specified - name, which has the format "language[_territory][.codeset][@modifier]" + \a name, which has the format "language[_territory][.codeset][@modifier]" or "C", where: \list - \li language is a lowercase, two-letter, ISO 639 language code, - \li territory is an uppercase, two-letter, ISO 3166 country code, - \li and codeset and modifier are ignored. + \li \c language is a lowercase, two-letter, ISO 639 language code, + \li \c territory is an uppercase, two-letter, ISO 3166 country code, and + \li \c codeset and \c modifier are ignored. \endlist If the string violates the locale format, or language is not a @@ -1372,7 +1397,8 @@ DEFINE_OBJECT_VTABLE(QQmlBindingFunction); /*! \qmlmethod Qt::binding(function) - Returns a JavaScript object representing a \l{Property Binding}{property binding}. + Returns a JavaScript object representing a \l{Property Binding}{property binding}, + with a \a function that evaluates the binding. There are two main use-cases for the function: firstly, to apply a property binding imperatively from JavaScript code: diff --git a/src/qml/types/qqmldelegatecomponent.cpp b/src/qml/types/qqmldelegatecomponent.cpp index d6c7ba6bdd..676a524872 100644 --- a/src/qml/types/qqmldelegatecomponent.cpp +++ b/src/qml/types/qqmldelegatecomponent.cpp @@ -58,19 +58,6 @@ QVariant QQmlAbstractDelegateComponent::value(QQmlAdaptorModel *adaptorModel, in return adaptorModel->value(adaptorModel->indexAt(row, column), role); } -/*! - \qmlmodule Qt.labs.qmlmodels 1.0 - \title Qt Labs QML Models - QML Types - \ingroup qmlmodules - \brief The Qt Labs QML Models module provides various model-related types for use with views. - - To use this module, import the module with the following line: - - \qml - import Qt.labs.qmlmodels 1.0 - \endqml -*/ - /*! \qmltype DelegateChoice \instantiates QQmlDelegateChoice diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index af328fbe2a..f58bab7c09 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -540,10 +540,10 @@ void QQmlDelegateModel::setRootIndex(const QVariant &root) \qmlmethod QModelIndex QtQml.Models::DelegateModel::modelIndex(int index) QAbstractItemModel provides a hierarchical tree of data, whereas - QML only operates on list data. This function assists in using + QML only operates on list data. This function assists in using tree models in QML. - Returns a QModelIndex for the specified index. + Returns a QModelIndex for the specified \a index. This value can be assigned to rootIndex. \sa rootIndex diff --git a/src/qml/types/qqmlobjectmodel.cpp b/src/qml/types/qqmlobjectmodel.cpp index 2f4d427430..525920c6e0 100644 --- a/src/qml/types/qqmlobjectmodel.cpp +++ b/src/qml/types/qqmlobjectmodel.cpp @@ -328,7 +328,7 @@ QObject *QQmlObjectModel::get(int index) const \qmlmethod QtQml.Models::ObjectModel::append(object item) \since 5.6 - Appends a new item to the end of the model. + Appends a new \a item to the end of the model. \code objectModel.append(objectComponent.createObject()) @@ -346,7 +346,7 @@ void QQmlObjectModel::append(QObject *object) \qmlmethod QtQml.Models::ObjectModel::insert(int index, object item) \since 5.6 - Inserts a new item to the model at position \a index. + Inserts a new \a item to the model at position \a index. \code objectModel.insert(2, objectComponent.createObject()) @@ -371,7 +371,7 @@ void QQmlObjectModel::insert(int index, QObject *object) \qmlmethod QtQml.Models::ObjectModel::move(int from, int to, int n = 1) \since 5.6 - Moves \a n items \a from one position \a to another. + Moves \e n items \a from one position \a to another. The from and to ranges must exist; for example, to move the first 3 items to the end of the model: @@ -398,7 +398,7 @@ void QQmlObjectModel::move(int from, int to, int n) \qmlmethod QtQml.Models::ObjectModel::remove(int index, int n = 1) \since 5.6 - Removes the items at \a index from the model. + Removes \e n items at \a index from the model. \sa clear() */ -- cgit v1.2.3 From eeb00570679c447f4701a92cd2e836f098724979 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 2 Sep 2019 15:30:17 +0200 Subject: Visit lists iteratively when parsing QML Change-Id: I243d12b75a07ac04560b444c326bff77d0dc642c Fixes: QTBUG-74087 Reviewed-by: Fabian Kosmale Reviewed-by: Simon Hausmann (cherry picked from commit 426f3035a3753800ce340a83bdf8db13922f4cae) --- src/qml/parser/qqmljsast.cpp | 73 +++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 35 deletions(-) (limited to 'src/qml') diff --git a/src/qml/parser/qqmljsast.cpp b/src/qml/parser/qqmljsast.cpp index 54a1200493..bd8cc38adf 100644 --- a/src/qml/parser/qqmljsast.cpp +++ b/src/qml/parser/qqmljsast.cpp @@ -238,12 +238,11 @@ void StringLiteral::accept0(Visitor *visitor) void TemplateLiteral::accept0(Visitor *visitor) { - if (visitor->visit(this)) { - if (next) - accept(next, visitor); + bool accepted = true; + for (TemplateLiteral *it = this; it && accepted; it = it->next) { + accepted = visitor->visit(it); + visitor->endVisit(it); } - - visitor->endVisit(this); } void NumericLiteral::accept0(Visitor *visitor) @@ -1013,13 +1012,13 @@ QStringList FormalParameterList::boundNames() const void FormalParameterList::accept0(Visitor *visitor) { - if (visitor->visit(this)) { - accept(element, visitor); - if (next) - accept(next, visitor); + bool accepted = true; + for (FormalParameterList *it = this; it && accepted; it = it->next) { + accepted = visitor->visit(it); + if (accepted) + accept(it->element, visitor); + visitor->endVisit(it); } - - visitor->endVisit(this); } FormalParameterList *FormalParameterList::finish(QQmlJS::MemoryPool *pool) @@ -1290,12 +1289,14 @@ void UiPragma::accept0(Visitor *visitor) void UiHeaderItemList::accept0(Visitor *visitor) { - if (visitor->visit(this)) { - accept(headerItem, visitor); - accept(next, visitor); - } + bool accepted = true; + for (UiHeaderItemList *it = this; it && accepted; it = it->next) { + accepted = visitor->visit(it); + if (accepted) + accept(it->headerItem, visitor); - visitor->endVisit(this); + visitor->endVisit(it); + } } @@ -1359,14 +1360,15 @@ void PatternElement::boundNames(QStringList *names) void PatternElementList::accept0(Visitor *visitor) { - if (visitor->visit(this)) { - accept(elision, visitor); - accept(element, visitor); - if (next) - accept(next, visitor); + bool accepted = true; + for (PatternElementList *it = this; it && accepted; it = it->next) { + accepted = visitor->visit(it); + if (accepted) { + accept(it->elision, visitor); + accept(it->element, visitor); + } + visitor->endVisit(it); } - - visitor->endVisit(this); } void PatternElementList::boundNames(QStringList *names) @@ -1395,13 +1397,13 @@ void PatternProperty::boundNames(QStringList *names) void PatternPropertyList::accept0(Visitor *visitor) { - if (visitor->visit(this)) { - accept(property, visitor); - if (next) - accept(next, visitor); + bool accepted = true; + for (PatternPropertyList *it = this; it && accepted; it = it->next) { + accepted = visitor->visit(it); + if (accepted) + accept(it->property, visitor); + visitor->endVisit(it); } - - visitor->endVisit(this); } void PatternPropertyList::boundNames(QStringList *names) @@ -1446,13 +1448,14 @@ void ClassDeclaration::accept0(Visitor *visitor) void ClassElementList::accept0(Visitor *visitor) { - if (visitor->visit(this)) { - accept(property, visitor); - if (next) - accept(next, visitor); - } + bool accepted = true; + for (ClassElementList *it = this; it && accepted; it = it->next) { + accepted = visitor->visit(it); + if (accepted) + accept(it->property, visitor); - visitor->endVisit(this); + visitor->endVisit(it); + } } ClassElementList *ClassElementList::finish() -- cgit v1.2.3 From db3dd029d7cd911712102efd5ea71868494f9f6f Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 13 Jun 2019 12:29:02 +0200 Subject: Fix various accumulator-saving problems We need to keep the accumulator alive across function calls. This requires: 1, Saving the accumulator on the stack if the function might allocate, to protect it from the garbage collector. However, we don't need to do that if the result of the function is to be saved in the accumulator and the function itself doesn't use the accumulator as argument. In this case the previous value becomes unaccessible and we might as well GC it. 2, In the JIT, restoring the accumulator from the stack after the function call if we want to ignore the return value. 3, Therefore, also saving the accumulator on the stack before calling in case of 2. We assume that we don't need to keep the accumulator alive across the jump to the exception handler. Saving the accumulator more often than necessary is detrimental for performance. To make sure the assumption holds, explicitly load the accumulator with undefined _before_ jumping to any exception handler. Change-Id: I78cbc42847b8885a0659b23f3b81655b7f1a0bc4 Reviewed-by: Simon Hausmann --- src/qml/jit/qv4assemblercommon_p.h | 2 +- src/qml/jit/qv4baselineassembler.cpp | 7 ++++++- src/qml/jit/qv4baselineassembler_p.h | 1 + src/qml/jit/qv4baselinejit.cpp | 16 +++++++++++++++- src/qml/jsruntime/qv4vme_moth.cpp | 6 ++++-- 5 files changed, 27 insertions(+), 5 deletions(-) (limited to 'src/qml') diff --git a/src/qml/jit/qv4assemblercommon_p.h b/src/qml/jit/qv4assemblercommon_p.h index 729d0fc53d..dcf39ab636 100644 --- a/src/qml/jit/qv4assemblercommon_p.h +++ b/src/qml/jit/qv4assemblercommon_p.h @@ -621,9 +621,9 @@ public: loadPtr(exceptionHandlerAddress(), ScratchRegister); Jump exitFunction = branchPtr(Equal, ScratchRegister, TrustedImmPtr(0)); + loadUndefined(); jump(ScratchRegister); exitFunction.link(this); - loadUndefined(); if (functionExit.isSet()) jump(functionExit); diff --git a/src/qml/jit/qv4baselineassembler.cpp b/src/qml/jit/qv4baselineassembler.cpp index b13f646360..73e396890e 100644 --- a/src/qml/jit/qv4baselineassembler.cpp +++ b/src/qml/jit/qv4baselineassembler.cpp @@ -1469,6 +1469,12 @@ void BaselineAssembler::saveAccumulatorInFrame() offsetof(CallData, accumulator))); } +void BaselineAssembler::loadAccumulatorFromFrame() +{ + pasm()->loadAccumulator(PlatformAssembler::Address(PlatformAssembler::JSStackFrameRegister, + offsetof(CallData, accumulator))); +} + static ReturnedValue TheJitIs__Tail_Calling__ToTheRuntimeSoTheJitFrameIsMissing(CppStackFrame *frame, ExecutionEngine *engine) { return Runtime::method_tailCall(frame, engine); @@ -1594,7 +1600,6 @@ void BaselineAssembler::deadTemporalZoneCheck(int offsetForSavedIP, int variable { auto valueIsAliveJump = pasm()->jumpNotEmpty(); storeInstructionPointer(offsetForSavedIP); - saveAccumulatorInFrame(); prepareCallWithArgCount(2); passInt32AsArg(variableName, 1); passEngineAsArg(0); diff --git a/src/qml/jit/qv4baselineassembler_p.h b/src/qml/jit/qv4baselineassembler_p.h index 0aa508ae71..f5ae826c55 100644 --- a/src/qml/jit/qv4baselineassembler_p.h +++ b/src/qml/jit/qv4baselineassembler_p.h @@ -152,6 +152,7 @@ public: void passInt32AsArg(int value, int arg); void callRuntime(const char *functionName, const void *funcPtr, CallResultDestination dest); void saveAccumulatorInFrame(); + void loadAccumulatorFromFrame(); void jsTailCall(int func, int thisObject, int argc, int argv); // exception/context stuff diff --git a/src/qml/jit/qv4baselinejit.cpp b/src/qml/jit/qv4baselinejit.cpp index 7bd51ba37e..51cd15099d 100644 --- a/src/qml/jit/qv4baselinejit.cpp +++ b/src/qml/jit/qv4baselinejit.cpp @@ -75,6 +75,7 @@ void BaselineJIT::generate() #define STORE_IP() as->storeInstructionPointer(nextInstructionOffset()) #define STORE_ACC() as->saveAccumulatorInFrame() +#define LOAD_ACC() as->loadAccumulatorFromFrame() #define BASELINEJIT_GENERATE_RUNTIME_CALL(function, destination) \ as->GENERATE_RUNTIME_CALL(function, destination) #define BASELINEJIT_GENERATE_TAIL_CALL(function) \ @@ -233,6 +234,7 @@ void BaselineJIT::generate_StoreNameSloppy(int name) as->passEngineAsArg(0); BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_storeNameSloppy, CallResultDestination::Ignore); as->checkException(); + LOAD_ACC(); } void BaselineJIT::generate_StoreNameStrict(int name) @@ -245,6 +247,7 @@ void BaselineJIT::generate_StoreNameStrict(int name) as->passEngineAsArg(0); BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_storeNameStrict, CallResultDestination::Ignore); as->checkException(); + LOAD_ACC(); } void BaselineJIT::generate_LoadElement(int base) @@ -270,6 +273,7 @@ void BaselineJIT::generate_StoreElement(int base, int index) as->passEngineAsArg(0); BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_storeElement, CallResultDestination::Ignore); as->checkException(); + LOAD_ACC(); } void BaselineJIT::generate_LoadProperty(int name) @@ -308,6 +312,7 @@ void BaselineJIT::generate_StoreProperty(int name, int base) as->passEngineAsArg(0); BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_storeProperty, CallResultDestination::Ignore); as->checkException(); + LOAD_ACC(); } void BaselineJIT::generate_SetLookup(int index, int base) @@ -327,7 +332,6 @@ void BaselineJIT::generate_SetLookup(int index, int base) void BaselineJIT::generate_LoadSuperProperty(int property) { STORE_IP(); - STORE_ACC(); as->prepareCallWithArgCount(2); as->passJSSlotAsArg(property, 1); as->passEngineAsArg(0); @@ -345,6 +349,7 @@ void BaselineJIT::generate_StoreSuperProperty(int property) as->passEngineAsArg(0); BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_storeSuperProperty, CallResultDestination::Ignore); as->checkException(); + LOAD_ACC(); } void BaselineJIT::generate_Yield() @@ -589,6 +594,7 @@ void BaselineJIT::generate_PushBlockContext(int index) as->passInt32AsArg(index, 1); as->passJSSlotAsArg(0, 0); BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::pushBlockContext, CallResultDestination::Ignore); + as->loadAccumulatorFromFrame(); } void BaselineJIT::generate_CloneBlockContext() @@ -597,6 +603,7 @@ void BaselineJIT::generate_CloneBlockContext() as->prepareCallWithArgCount(1); as->passJSSlotAsArg(CallData::Context, 0); BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::cloneBlockContext, CallResultDestination::Ignore); + as->loadAccumulatorFromFrame(); } void BaselineJIT::generate_PushScriptContext(int index) @@ -607,6 +614,7 @@ void BaselineJIT::generate_PushScriptContext(int index) as->passEngineAsArg(1); as->passJSSlotAsArg(0, 0); BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::pushScriptContext, CallResultDestination::Ignore); + as->loadAccumulatorFromFrame(); } void BaselineJIT::generate_PopScriptContext() @@ -616,6 +624,7 @@ void BaselineJIT::generate_PopScriptContext() as->passEngineAsArg(1); as->passJSSlotAsArg(0, 0); BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::popScriptContext, CallResultDestination::Ignore); + as->loadAccumulatorFromFrame(); } void BaselineJIT::generate_PopContext() { as->popContext(); } @@ -716,11 +725,13 @@ void BaselineJIT::generate_TypeofValue() void BaselineJIT::generate_DeclareVar(int varName, int isDeletable) { + STORE_ACC(); as->prepareCallWithArgCount(3); as->passInt32AsArg(varName, 2); as->passInt32AsArg(isDeletable, 1); as->passEngineAsArg(0); BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_declareVar, CallResultDestination::Ignore); + LOAD_ACC(); } void BaselineJIT::generate_DefineArray(int argc, int args) @@ -778,11 +789,13 @@ void BaselineJIT::generate_CreateRestParameter(int argIndex) void BaselineJIT::generate_ConvertThisToObject() { + STORE_ACC(); as->prepareCallWithArgCount(2); as->passJSSlotAsArg(CallData::This, 1); as->passEngineAsArg(0); BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::convertThisToObject, CallResultDestination::Ignore); as->checkException(); + LOAD_ACC(); } void BaselineJIT::generate_LoadSuperConstructor() @@ -909,6 +922,7 @@ void BaselineJIT::generate_ThrowOnNullOrUndefined() as->passEngineAsArg(0); BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::throwOnNullOrUndefined, CallResultDestination::Ignore); as->checkException(); + LOAD_ACC(); } void BaselineJIT::generate_GetTemplateObject(int index) diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index c69bb67061..47ad22f4f7 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -640,7 +640,6 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine, MOTH_BEGIN_INSTR(LoadSuperProperty) STORE_IP(); - STORE_ACC(); acc = Runtime::method_loadSuperProperty(engine, STACK_VALUE(property)); CHECK_EXCEPTION; MOTH_END_INSTR(LoadSuperProperty) @@ -787,12 +786,14 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine, MOTH_BEGIN_INSTR(Construct) STORE_IP(); + STORE_ACC(); acc = Runtime::method_construct(engine, STACK_VALUE(func), ACC, stack + argv, argc); CHECK_EXCEPTION; MOTH_END_INSTR(Construct) MOTH_BEGIN_INSTR(ConstructWithSpread) STORE_IP(); + STORE_ACC(); acc = Runtime::method_constructWithSpread(engine, STACK_VALUE(func), ACC, stack + argv, argc); CHECK_EXCEPTION; MOTH_END_INSTR(ConstructWithSpread) @@ -820,7 +821,6 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine, MOTH_BEGIN_INSTR(DeadTemporalZoneCheck) if (ACC.isEmpty()) { STORE_IP(); - STORE_ACC(); Runtime::method_throwReferenceError(engine, name); goto handleUnwind; } @@ -989,6 +989,7 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine, if (t->isNullOrUndefined()) { *t = engine->globalObject->asReturnedValue(); } else { + STORE_ACC(); *t = t->toObject(engine)->asReturnedValue(); CHECK_EXCEPTION; } @@ -1001,6 +1002,7 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine, MOTH_END_INSTR(LoadSuperConstructor) MOTH_BEGIN_INSTR(ToObject) + STORE_ACC(); acc = ACC.toObject(engine)->asReturnedValue(); CHECK_EXCEPTION; MOTH_END_INSTR(ToObject) -- cgit v1.2.3 From 5ca1d2e0b2912e578a32c5e11b4fd1d7a0ef28f3 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Wed, 11 Sep 2019 16:38:29 +0200 Subject: QQmlTypeLoader: Prevent trivial cycles The type loader already contained a cycle check, however it did not work for the attached example. We now do an additional test for A->B->A cycles, which fixes the bug. This is a valid strategy, as in that case the currently resolved type would immediately fullfill the depentency of the type waiting on it, which in turn resolves the only dependency of the current type. Fixes: QTBUG-78098 Change-Id: I8b550a1c240d3d0fbf158beb99a5daf992904cb0 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmldatablob_p.h | 2 ++ src/qml/qml/qqmltypedata.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src/qml') diff --git a/src/qml/qml/qqmldatablob_p.h b/src/qml/qml/qqmldatablob_p.h index da3bbe2c1f..0450e94c02 100644 --- a/src/qml/qml/qqmldatablob_p.h +++ b/src/qml/qml/qqmldatablob_p.h @@ -242,7 +242,9 @@ private: mutable QString m_finalUrlString; // List of QQmlDataBlob's that are waiting for me to complete. +protected: QList m_waitingOnMe; +private: // List of QQmlDataBlob's that I am waiting for to complete. QVector> m_waitingFor; diff --git a/src/qml/qml/qqmltypedata.cpp b/src/qml/qml/qqmltypedata.cpp index 8d75b57fc1..b9fbf40e96 100644 --- a/src/qml/qml/qqmltypedata.cpp +++ b/src/qml/qml/qqmltypedata.cpp @@ -678,7 +678,7 @@ void QQmlTypeData::resolveTypes() if (ref.type.isCompositeSingleton()) { ref.typeData = typeLoader()->getType(ref.type.sourceUrl()); - if (ref.typeData->status() == QQmlDataBlob::ResolvingDependencies) { + if (ref.typeData->status() == QQmlDataBlob::ResolvingDependencies || m_waitingOnMe.contains(ref.typeData.data())) { // TODO: give an error message? If so, we should record and show the path of the cycle. continue; } -- cgit v1.2.3 From 28eb0caec23e0c315056cb035535b8806ccb0f37 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 5 Sep 2019 16:41:11 +0200 Subject: Force creation of metaobjects for top level objects and components We want those to be different types, even if they don't add any properties, signals etc. Otherwise you can cross-assign objects of components defined in different files. Fully-dynamic types, such as QQmlPropertyMap are still an exception to this. We need to use the original meta object so that you can still dynamically add properties to any derived types. Therefore, all types derived from QQmlPropertyMap are in fact just aliases of each other. Also, types which aren't addressable from the outside don't get their own meta object. Types are addressable if they live in files and the file name starts with an uppercase character. Otherwise there is no way to refer to the component from anywhere else in QML. Fixes: QTBUG-76021 Change-Id: I96a01fdad13e50e4705520fec46f2b3373e0c365 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlpropertycachecreator_p.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/qml') diff --git a/src/qml/qml/qqmlpropertycachecreator_p.h b/src/qml/qml/qqmlpropertycachecreator_p.h index def4480198..94bf3cbdc3 100644 --- a/src/qml/qml/qqmlpropertycachecreator_p.h +++ b/src/qml/qml/qqmlpropertycachecreator_p.h @@ -152,9 +152,18 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator::buil template inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator::buildMetaObjectRecursively(int objectIndex, const QQmlBindingInstantiationContext &context) { + auto isAddressable = [](const QUrl &url) { + const QString fileName = url.fileName(); + return !fileName.isEmpty() && fileName.front().isUpper(); + }; + const CompiledObject *obj = objectContainer->objectAt(objectIndex); + bool needVMEMetaObject = obj->propertyCount() != 0 || obj->aliasCount() != 0 + || obj->signalCount() != 0 || obj->functionCount() != 0 || obj->enumCount() != 0 + || (((obj->flags & QV4::CompiledData::Object::IsComponent) + || (objectIndex == 0 && isAddressable(objectContainer->url()))) + && !objectContainer->resolvedType(obj->inheritedTypeNameIndex)->isFullyDynamicType); - bool needVMEMetaObject = obj->propertyCount() != 0 || obj->aliasCount() != 0 || obj->signalCount() != 0 || obj->functionCount() != 0 || obj->enumCount() != 0; if (!needVMEMetaObject) { auto binding = obj->bindingsBegin(); auto end = obj->bindingsEnd(); -- cgit v1.2.3 From 43a6970ce328109d9d367978fa09e838bbac8596 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Sat, 14 Sep 2019 14:54:24 +0200 Subject: doc: Add missing directories to qdocconf files These might not be complete yet, but they do fix the qdoc errors. Change-Id: I75b0f0f7709a371149a6f7c82adfff9fe88408ea Reviewed-by: Paul Wicking --- src/qml/doc/qtqml.qdocconf | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/qml') diff --git a/src/qml/doc/qtqml.qdocconf b/src/qml/doc/qtqml.qdocconf index cb9fb575b2..74d0a3b27c 100644 --- a/src/qml/doc/qtqml.qdocconf +++ b/src/qml/doc/qtqml.qdocconf @@ -37,11 +37,17 @@ tagfile = ../../../doc/qtqml/qtqml.tags depends += qtcore qtgui qtquick qtdoc qtlinguist qmake qtscript qtwidgets qtxmlpatterns qtquickcontrols headerdirs += .. \ - ../../imports/models + ../../imports/models \ + ../../qmlmodels \ + ../../qml \ + ../../qmlworkerscript sourcedirs += .. \ ../../imports/models \ - ../../imports/statemachine + ../../imports/statemachine \ + ../../qmlmodels \ + ../../qml \ + ../../qmlworkerscript exampledirs += ../../../examples/qml \ ../ \ -- cgit v1.2.3 From b7e5b0c25b7c02b40c2072f45a0a0feb8bd2a977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Mon, 16 Sep 2019 14:12:50 +0200 Subject: Fix qmlobject_{dis}connect macros to require semicolon at the end Just do the typical do { [..stuff..] } while(0) in the macros Fix the places that didn't have semicolons. This should eliminate some compiler warnings complaining about excessive semicolons Change-Id: I6b0e7a55badfd0f80c3cd0e9e1da42dc41945485 Reviewed-by: Shawn Rutledge --- src/qml/qml/qqmlglobal_p.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/qml') diff --git a/src/qml/qml/qqmlglobal_p.h b/src/qml/qml/qqmlglobal_p.h index 96891af416..3c540a6124 100644 --- a/src/qml/qml/qqmlglobal_p.h +++ b/src/qml/qml/qqmlglobal_p.h @@ -90,7 +90,7 @@ QT_BEGIN_NAMESPACE \endcode */ #define qmlobject_connect(Sender, SenderType, Signal, Receiver, ReceiverType, Method) \ -{ \ +do { \ SenderType *sender = (Sender); \ ReceiverType *receiver = (Receiver); \ const char *signal = (Signal); \ @@ -111,7 +111,7 @@ QT_BEGIN_NAMESPACE } \ Q_ASSERT(signalIdx != -1 && methodIdx != -1); \ QMetaObject::connect(sender, signalIdx, receiver, methodIdx, Qt::DirectConnection); \ -} +} while (0) /*! Disconnect \a Signal of \a Sender from \a Method of \a Receiver. \a Signal must be @@ -129,7 +129,7 @@ QT_BEGIN_NAMESPACE \endcode */ #define qmlobject_disconnect(Sender, SenderType, Signal, Receiver, ReceiverType, Method) \ -{ \ +do { \ SenderType *sender = (Sender); \ ReceiverType *receiver = (Receiver); \ const char *signal = (Signal); \ @@ -150,7 +150,7 @@ QT_BEGIN_NAMESPACE } \ Q_ASSERT(signalIdx != -1 && methodIdx != -1); \ QMetaObject::disconnect(sender, signalIdx, receiver, methodIdx); \ -} +} while (0) /*! This method is identical to qobject_cast() except that it does not require lazy -- cgit v1.2.3 From be478ea886b8b4867cd8832f4f848bcce96c4512 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 16 Sep 2019 11:51:22 +0200 Subject: Re-add documentation for Qt Qml Models It got lost when moving the classes. Change-Id: I7b3a9fec8fe9439c548da570e430d3b82613b816 Reviewed-by: Simon Hausmann --- .../doc/snippets/delegatemodel/delegatemodel.qml | 75 ------------ .../delegatemodel/delegatemodel_rootindex/main.cpp | 72 ----------- .../delegatemodel/delegatemodel_rootindex/view.qml | 76 ------------ .../snippets/delegatemodel/delegatemodelgroup.qml | 92 -------------- src/qml/doc/snippets/package/Delegate.qml | 88 -------------- src/qml/doc/snippets/package/view.qml | 103 ---------------- .../doc/snippets/qml/listmodel/listelements.qml | 87 ------------- .../snippets/qml/listmodel/listmodel-modify.qml | 106 ---------------- .../snippets/qml/listmodel/listmodel-nested.qml | 112 ----------------- .../snippets/qml/listmodel/listmodel-simple.qml | 89 -------------- src/qml/doc/snippets/qml/listmodel/listmodel.qml | 69 ----------- .../qml/tablemodel/fruit-example-complex.qml | 134 --------------------- .../tablemodel/fruit-example-delegatechooser.qml | 130 -------------------- .../tablemodel/fruit-example-simpledelegate.qml | 119 ------------------ 14 files changed, 1352 deletions(-) delete mode 100644 src/qml/doc/snippets/delegatemodel/delegatemodel.qml delete mode 100644 src/qml/doc/snippets/delegatemodel/delegatemodel_rootindex/main.cpp delete mode 100644 src/qml/doc/snippets/delegatemodel/delegatemodel_rootindex/view.qml delete mode 100644 src/qml/doc/snippets/delegatemodel/delegatemodelgroup.qml delete mode 100644 src/qml/doc/snippets/package/Delegate.qml delete mode 100644 src/qml/doc/snippets/package/view.qml delete mode 100644 src/qml/doc/snippets/qml/listmodel/listelements.qml delete mode 100644 src/qml/doc/snippets/qml/listmodel/listmodel-modify.qml delete mode 100644 src/qml/doc/snippets/qml/listmodel/listmodel-nested.qml delete mode 100644 src/qml/doc/snippets/qml/listmodel/listmodel-simple.qml delete mode 100644 src/qml/doc/snippets/qml/listmodel/listmodel.qml delete mode 100644 src/qml/doc/snippets/qml/tablemodel/fruit-example-complex.qml delete mode 100644 src/qml/doc/snippets/qml/tablemodel/fruit-example-delegatechooser.qml delete mode 100644 src/qml/doc/snippets/qml/tablemodel/fruit-example-simpledelegate.qml (limited to 'src/qml') diff --git a/src/qml/doc/snippets/delegatemodel/delegatemodel.qml b/src/qml/doc/snippets/delegatemodel/delegatemodel.qml deleted file mode 100644 index 1a7baa6b1e..0000000000 --- a/src/qml/doc/snippets/delegatemodel/delegatemodel.qml +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 -import QtQml.Models 2.2 - -Rectangle { - width: 200; height: 100 - - DelegateModel { - id: visualModel - model: ListModel { - ListElement { name: "Apple" } - ListElement { name: "Orange" } - } - delegate: Rectangle { - height: 25 - width: 100 - Text { text: "Name: " + name} - } - } - - ListView { - anchors.fill: parent - model: visualModel - } -} -//![0] diff --git a/src/qml/doc/snippets/delegatemodel/delegatemodel_rootindex/main.cpp b/src/qml/doc/snippets/delegatemodel/delegatemodel_rootindex/main.cpp deleted file mode 100644 index a56eb69616..0000000000 --- a/src/qml/doc/snippets/delegatemodel/delegatemodel_rootindex/main.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -#include -#include - -//![0] -int main(int argc, char ** argv) -{ - QApplication app(argc, argv); - - QQuickView view; - - QDirModel model; - view.rootContext()->setContextProperty("dirModel", &model); - - view.setSource(QUrl::fromLocalFile("view.qml")); - view.show(); - - return app.exec(); -} -//![0] - diff --git a/src/qml/doc/snippets/delegatemodel/delegatemodel_rootindex/view.qml b/src/qml/doc/snippets/delegatemodel/delegatemodel_rootindex/view.qml deleted file mode 100644 index 2e17eed8f0..0000000000 --- a/src/qml/doc/snippets/delegatemodel/delegatemodel_rootindex/view.qml +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 -import QtQml.Models 2.2 - -ListView { - id: view - width: 300 - height: 400 - - model: DelegateModel { - model: dirModel - - delegate: Rectangle { - width: 200; height: 25 - Text { text: filePath } - - MouseArea { - anchors.fill: parent - onClicked: { - if (model.hasModelChildren) - view.model.rootIndex = view.model.modelIndex(index) - } - } - } - } -} -//![0] diff --git a/src/qml/doc/snippets/delegatemodel/delegatemodelgroup.qml b/src/qml/doc/snippets/delegatemodel/delegatemodelgroup.qml deleted file mode 100644 index 8562deeeda..0000000000 --- a/src/qml/doc/snippets/delegatemodel/delegatemodelgroup.qml +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 -import QtQml.Models 2.2 - -Rectangle { - width: 200; height: 100 - - DelegateModel { - id: visualModel - model: ListModel { - ListElement { name: "Apple" } - ListElement { name: "Orange" } - } - - groups: [ - DelegateModelGroup { name: "selected" } - ] - - delegate: Rectangle { - id: item - height: 25 - width: 200 - Text { - text: { - var text = "Name: " + name - if (item.DelegateModel.inSelected) - text += " (" + item.DelegateModel.selectedIndex + ")" - return text; - } - } - MouseArea { - anchors.fill: parent - onClicked: item.DelegateModel.inSelected = !item.DelegateModel.inSelected - } - } - } - - ListView { - anchors.fill: parent - model: visualModel - } -} -//![0] diff --git a/src/qml/doc/snippets/package/Delegate.qml b/src/qml/doc/snippets/package/Delegate.qml deleted file mode 100644 index 7c73f35c3d..0000000000 --- a/src/qml/doc/snippets/package/Delegate.qml +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -//! [0] -Package { - Text { id: listDelegate; width: parent.width; height: 25; text: 'Empty'; Package.name: 'list' } - Text { id: gridDelegate; width: parent.width / 2; height: 50; text: 'Empty'; Package.name: 'grid' } - - Rectangle { - id: wrapper - width: parent.width; height: 25 - color: 'lightsteelblue' - - Text { text: display; anchors.centerIn: parent } - state: root.upTo > index ? 'inGrid' : 'inList' - states: [ - State { - name: 'inList' - ParentChange { target: wrapper; parent: listDelegate } - }, - State { - name: 'inGrid' - ParentChange { - target: wrapper; parent: gridDelegate - x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height - } - } - ] - - transitions: [ - Transition { - ParentAnimation { - NumberAnimation { properties: 'x,y,width,height'; duration: 300 } - } - } - ] - } -} -//! [0] diff --git a/src/qml/doc/snippets/package/view.qml b/src/qml/doc/snippets/package/view.qml deleted file mode 100644 index 311cc3be8e..0000000000 --- a/src/qml/doc/snippets/package/view.qml +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQml.Models 2.1 - -Rectangle { - id: root - color: "white" - width: 320 - height: 480 - property int upTo: 0 - SequentialAnimation on upTo { - loops: -1 - NumberAnimation { to: 8; duration: 3500 } - NumberAnimation { to: 0; duration: 3500 } - } - - ListModel { - id: myModel - ListElement { display: "One" } - ListElement { display: "Two" } - ListElement { display: "Three" } - ListElement { display: "Four" } - ListElement { display: "Five" } - ListElement { display: "Six" } - ListElement { display: "Seven" } - ListElement { display: "Eight" } - } - //![0] - DelegateModel { - id: visualModel - delegate: Delegate {} - model: myModel - } - - ListView { - id: lv - height: parent.height/2 - width: parent.width - - model: visualModel.parts.list - } - GridView { - y: parent.height/2 - height: parent.height/2 - width: parent.width - cellWidth: width / 2 - cellHeight: 50 - model: visualModel.parts.grid - } - //![0] - Text { - anchors.bottom: parent.bottom - } -} diff --git a/src/qml/doc/snippets/qml/listmodel/listelements.qml b/src/qml/doc/snippets/qml/listmodel/listelements.qml deleted file mode 100644 index 12146c1420..0000000000 --- a/src/qml/doc/snippets/qml/listmodel/listelements.qml +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -Item { - width: 200; height: 250 - - //! [model] - ListModel { - id: fruitModel - - ListElement { - name: "Apple" - cost: 2.45 - } - ListElement { - name: "Orange" - cost: 3.25 - } - ListElement { - name: "Banana" - cost: 1.95 - } - } - //! [model] - - //! [view] - ListView { - anchors.fill: parent - model: fruitModel - delegate: Row { - Text { text: "Fruit: " + name } - Text { text: "Cost: $" + cost } - } - } - //! [view] -} -//! [document] diff --git a/src/qml/doc/snippets/qml/listmodel/listmodel-modify.qml b/src/qml/doc/snippets/qml/listmodel/listmodel-modify.qml deleted file mode 100644 index f293eff8ec..0000000000 --- a/src/qml/doc/snippets/qml/listmodel/listmodel-modify.qml +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Rectangle { - width: 200; height: 200 - -ListModel { - id: fruitModel - - ListElement { - name: "Apple" - cost: 2.45 - attributes: [ - ListElement { description: "Core" }, - ListElement { description: "Deciduous" } - ] - } - ListElement { - name: "Orange" - cost: 3.25 - attributes: [ - ListElement { description: "Citrus" } - ] - } - ListElement { - name: "Banana" - cost: 1.95 - attributes: [ - ListElement { description: "Tropical" }, - ListElement { description: "Seedless" } - ] - } -} - -//![delegate] - Component { - id: fruitDelegate - Item { - width: 200; height: 50 - Text { text: name } - Text { text: '$' + cost; anchors.right: parent.right } - - // Double the price when clicked. - MouseArea { - anchors.fill: parent - onClicked: fruitModel.setProperty(index, "cost", cost * 2) - } - } - } -//![delegate] - -ListView { - width: 200; height: 200 - model: fruitModel - delegate: fruitDelegate -} - -} diff --git a/src/qml/doc/snippets/qml/listmodel/listmodel-nested.qml b/src/qml/doc/snippets/qml/listmodel/listmodel-nested.qml deleted file mode 100644 index 8c193d6a5e..0000000000 --- a/src/qml/doc/snippets/qml/listmodel/listmodel-nested.qml +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Rectangle { - width: 200; height: 200 - - -//![model] -ListModel { - id: fruitModel - - ListElement { - name: "Apple" - cost: 2.45 - attributes: [ - ListElement { description: "Core" }, - ListElement { description: "Deciduous" } - ] - } - ListElement { - name: "Orange" - cost: 3.25 - attributes: [ - ListElement { description: "Citrus" } - ] - } - ListElement { - name: "Banana" - cost: 1.95 - attributes: [ - ListElement { description: "Tropical" }, - ListElement { description: "Seedless" } - ] - } -} -//![model] - -//![delegate] -Component { - id: fruitDelegate - Item { - width: 200; height: 50 - Text { id: nameField; text: name } - Text { text: '$' + cost; anchors.left: nameField.right } - Row { - anchors.top: nameField.bottom - spacing: 5 - Text { text: "Attributes:" } - Repeater { - model: attributes - Text { text: description } - } - } - } -} -//![delegate] - -ListView { - width: 200; height: 200 - model: fruitModel - delegate: fruitDelegate -} - -} diff --git a/src/qml/doc/snippets/qml/listmodel/listmodel-simple.qml b/src/qml/doc/snippets/qml/listmodel/listmodel-simple.qml deleted file mode 100644 index d07f868476..0000000000 --- a/src/qml/doc/snippets/qml/listmodel/listmodel-simple.qml +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Rectangle { - width: 200; height: 200 - - ListModel { - id: fruitModel -//![0] - ListElement { - name: "Apple" - cost: 2.45 - } - ListElement { - name: "Orange" - cost: 3.25 - } - ListElement { - name: "Banana" - cost: 1.95 - } -//![1] - } - - Component { - id: fruitDelegate - Row { - spacing: 10 - Text { text: name } - Text { text: '$' + cost } - } - } - - ListView { - anchors.fill: parent - model: fruitModel - delegate: fruitDelegate - } -} -//![1] diff --git a/src/qml/doc/snippets/qml/listmodel/listmodel.qml b/src/qml/doc/snippets/qml/listmodel/listmodel.qml deleted file mode 100644 index c2a69d6e8f..0000000000 --- a/src/qml/doc/snippets/qml/listmodel/listmodel.qml +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -ListModel { - id: fruitModel - - ListElement { - name: "Apple" - cost: 2.45 - } - ListElement { - name: "Orange" - cost: 3.25 - } - ListElement { - name: "Banana" - cost: 1.95 - } -} -//![0] diff --git a/src/qml/doc/snippets/qml/tablemodel/fruit-example-complex.qml b/src/qml/doc/snippets/qml/tablemodel/fruit-example-complex.qml deleted file mode 100644 index 104a2209d7..0000000000 --- a/src/qml/doc/snippets/qml/tablemodel/fruit-example-complex.qml +++ /dev/null @@ -1,134 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![file] -import QtQuick 2.12 -import QtQuick.Window 2.12 -import Qt.labs.qmlmodels 1.0 - -Window { - width: 400 - height: 400 - visible: true - - TableView { - anchors.fill: parent - columnSpacing: 1 - rowSpacing: 1 - boundsBehavior: Flickable.StopAtBounds - - model: TableModel { - TableModelColumn { - display: function(modelIndex) { return rows[modelIndex.row][0].checked } - setDisplay: function(modelIndex, cellData) { rows[modelIndex.row][0].checked = cellData } - } - TableModelColumn { - display: function(modelIndex) { return rows[modelIndex.row][1].amount } - setDisplay: function(modelIndex, cellData) { rows[modelIndex.row][1].amount = cellData } - } - TableModelColumn { - display: function(modelIndex) { return rows[modelIndex.row][2].fruitType } - setDisplay: function(modelIndex, cellData) { rows[modelIndex.row][2].fruitType = cellData } - } - TableModelColumn { - display: function(modelIndex) { return rows[modelIndex.row][3].fruitName } - setDisplay: function(modelIndex, cellData) { rows[modelIndex.row][3].fruitName = cellData } - } - TableModelColumn { - display: function(modelIndex) { return rows[modelIndex.row][4].fruitPrice } - setDisplay: function(modelIndex, cellData) { rows[modelIndex.row][4].fruitPrice = cellData } - } - - // Each row is one type of fruit that can be ordered -//![rows] - rows: [ - [ - // Each object (line) is one cell/column. - { checked: false, checkable: true }, - { amount: 1 }, - { fruitType: "Apple" }, - { fruitName: "Granny Smith" }, - { fruitPrice: 1.50 } - ], - [ - { checked: true, checkable: true }, - { amount: 4 }, - { fruitType: "Orange" }, - { fruitName: "Navel" }, - { fruitPrice: 2.50 } - ], - [ - { checked: false, checkable: false }, - { amount: 1 }, - { fruitType: "Banana" }, - { fruitName: "Cavendish" }, - { fruitPrice: 3.50 } - ] - ] -//![rows] - } -//![delegate] - delegate: TextInput { - text: model.display - padding: 12 - selectByMouse: true - - onAccepted: model.display = text - - Rectangle { - anchors.fill: parent - color: "#efefef" - z: -1 - } - } -//![delegate] - } -} -//![file] diff --git a/src/qml/doc/snippets/qml/tablemodel/fruit-example-delegatechooser.qml b/src/qml/doc/snippets/qml/tablemodel/fruit-example-delegatechooser.qml deleted file mode 100644 index d3f6176c70..0000000000 --- a/src/qml/doc/snippets/qml/tablemodel/fruit-example-delegatechooser.qml +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![file] -import QtQuick 2.12 -import QtQuick.Controls 2.5 -import Qt.labs.qmlmodels 1.0 - -ApplicationWindow { - width: 400 - height: 400 - visible: true - - TableView { - anchors.fill: parent - columnSpacing: 1 - rowSpacing: 1 - boundsBehavior: Flickable.StopAtBounds - - model: TableModel { - TableModelColumn { display: "checked" } - TableModelColumn { display: "amount" } - TableModelColumn { display: "fruitType" } - TableModelColumn { display: "fruitName" } - TableModelColumn { display: "fruitPrice" } - - // Each row is one type of fruit that can be ordered -//![rows] - rows: [ - { - // Each property is one cell/column. - checked: false, - amount: 1, - fruitType: "Apple", - fruitName: "Granny Smith", - fruitPrice: 1.50 - }, - { - checked: true, - amount: 4, - fruitType: "Orange", - fruitName: "Navel", - fruitPrice: 2.50 - }, - { - checked: false, - amount: 1, - fruitType: "Banana", - fruitName: "Cavendish", - fruitPrice: 3.50 - } - ] -//![rows] - } -//![delegate] - delegate: DelegateChooser { - DelegateChoice { - column: 0 - delegate: CheckBox { - checked: model.display - onToggled: model.display = checked - } - } - DelegateChoice { - column: 1 - delegate: SpinBox { - value: model.display - onValueModified: model.display = value - } - } - DelegateChoice { - delegate: TextField { - text: model.display - selectByMouse: true - implicitWidth: 140 - onAccepted: model.display = text - } - } - } -//![delegate] - } -} -//![file] diff --git a/src/qml/doc/snippets/qml/tablemodel/fruit-example-simpledelegate.qml b/src/qml/doc/snippets/qml/tablemodel/fruit-example-simpledelegate.qml deleted file mode 100644 index f51c1818c3..0000000000 --- a/src/qml/doc/snippets/qml/tablemodel/fruit-example-simpledelegate.qml +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![file] -import QtQuick 2.12 -import QtQuick.Window 2.12 -import Qt.labs.qmlmodels 1.0 - -Window { - width: 400 - height: 400 - visible: true - - TableView { - anchors.fill: parent - columnSpacing: 1 - rowSpacing: 1 - boundsBehavior: Flickable.StopAtBounds - - model: TableModel { - TableModelColumn { display: "checked" } - TableModelColumn { display: "amount" } - TableModelColumn { display: "fruitType" } - TableModelColumn { display: "fruitName" } - TableModelColumn { display: "fruitPrice" } - - // Each row is one type of fruit that can be ordered -//![rows] - rows: [ - { - // Each property is one cell/column. - checked: false, - amount: 1, - fruitType: "Apple", - fruitName: "Granny Smith", - fruitPrice: 1.50 - }, - { - checked: true, - amount: 4, - fruitType: "Orange", - fruitName: "Navel", - fruitPrice: 2.50 - }, - { - checked: false, - amount: 1, - fruitType: "Banana", - fruitName: "Cavendish", - fruitPrice: 3.50 - } - ] -//![rows] - } -//![delegate] - delegate: TextInput { - text: model.display - padding: 12 - selectByMouse: true - - onAccepted: model.display = text - - Rectangle { - anchors.fill: parent - color: "#efefef" - z: -1 - } - } -//![delegate] - } -} -//![file] -- cgit v1.2.3 From 1cef434ae29d21bd46adb26d84ff37eec596985c Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 17 Sep 2019 09:25:30 +0200 Subject: Fix deprecation macros in qqml.h Give a friendly message for qmlAttachedPropertiesObject(int ...) and disable plain qmlRegisterType() if QT_DEPRECATED_SINCE(5, 14). Change-Id: I9373f38fdddcb58ec1211b6cab492e1bc5370e52 Reviewed-by: Fabian Kosmale Reviewed-by: Albert Astals Cid Reviewed-by: Simon Hausmann --- src/qml/qml/qqml.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/qml') diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h index 6295345fa4..b2bf1f328f 100644 --- a/src/qml/qml/qqml.h +++ b/src/qml/qml/qqml.h @@ -133,11 +133,13 @@ int qmlRegisterAnonymousType(const char *uri, int versionMajor) return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type); } +#if QT_DEPRECATED_SINCE(5, 14) template QT_DEPRECATED_VERSION_X_5_14("Use qmlRegisterAnonymousType instead") int qmlRegisterType() { return qmlRegisterAnonymousType("", 1); } +#endif int Q_QML_EXPORT qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message); @@ -586,8 +588,10 @@ namespace QtQml { Q_QML_EXPORT QQmlContext *qmlContext(const QObject *); Q_QML_EXPORT QQmlEngine *qmlEngine(const QObject *); #if QT_DEPRECATED_SINCE(5, 14) - Q_QML_EXPORT QT_DEPRECATED QObject *qmlAttachedPropertiesObjectById(int, const QObject *, bool create = true); - Q_QML_EXPORT QT_DEPRECATED QObject *qmlAttachedPropertiesObject( + Q_QML_EXPORT QT_DEPRECATED_VERSION_X_5_14("Use qmlAttachedPropertiesObject(QObject *, QQmlAttachedPropertiesFunc, bool") + QObject *qmlAttachedPropertiesObjectById(int, const QObject *, bool create = true); + Q_QML_EXPORT QT_DEPRECATED_VERSION_X_5_14("Use qmlAttachedPropertiesObject(QObject *, QQmlAttachedPropertiesFunc, bool") + QObject *qmlAttachedPropertiesObject( int *, const QObject *, const QMetaObject *, bool create); #endif Q_QML_EXPORT QQmlAttachedPropertiesFunc qmlAttachedPropertiesFunction(QObject *, -- cgit v1.2.3 From b9ba1ed06f63053b6fe5426cc1cc726b6b85592f Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 17 Sep 2019 09:22:09 +0200 Subject: Fix documentation for qmlRegisterType and qmlRegisterAnonymousType Plain qmlRegisterType() is deprecated and qmlRegisterAnonymousType() was added in 5.14 as replacement. Also, qmlRegisterAnonymousType() does take an import URI and a major version. The point about non-anonymous type registration is that it also takes an element name. Change-Id: I51fb6f9c63dcf15dc1da10c25ea6c6d3b88fd31a Reviewed-by: Kavindra Palaraja --- src/qml/doc/src/qmlfunctions.qdoc | 40 +++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'src/qml') diff --git a/src/qml/doc/src/qmlfunctions.qdoc b/src/qml/doc/src/qmlfunctions.qdoc index c71d18418a..81aa263fa6 100644 --- a/src/qml/doc/src/qmlfunctions.qdoc +++ b/src/qml/doc/src/qmlfunctions.qdoc @@ -276,25 +276,14 @@ /*! \fn int qmlRegisterAnonymousType(const char *uri, int versionMajor) - This template function registers the C++ type in the QML system. Instances of this type cannot be created from the QML system. + This template function registers the C++ type in the QML system as an anonymous type. The + resulting QML type does not have a name. Therefore, instances of this type cannot be created from + the QML system. You can, however, access instances of the type when they are exposed as properties + of other types. - Use this function when the type will not be referenced by name. Use \a uri and \a versionMajor to indicate to which module the type belongs. - - \sa {Choosing the Correct Integration Method Between C++ and QML} -*/ - -/*! - \fn int qmlRegisterType() - \relates QQmlEngine - \overload - - This template function registers the C++ type in the QML - system. Instances of this type cannot be created from the QML - system. - - This function should be used when the type will not be referenced by name. - Specifically, it has to be used for C++ types that are used as the left-hand - side of a property binding. + Use this function when the type will not be referenced by name, specifically for C++ types that + are used on the left-hand side of a property binding. To indicate to which module the type belongs + use \a uri and \a versionMajor. For example, consider the following two classes: @@ -354,17 +343,28 @@ \code qmlRegisterType("App", 1, 0, "Foo"); - qmlRegisterType(); + qmlRegisterAnonymousType("App", 1); \endcode As the \c Foo type is instantiated in QML, it must be registered - with the version of \l qmlRegisterType() that takes an import URI. + with the version of \l qmlRegisterType() that takes an element name. Returns the QML type id. + \since 5.14 \sa {Choosing the Correct Integration Method Between C++ and QML} */ +/*! + \fn int qmlRegisterType() + \relates QQmlEngine + \overload + \deprecated + + Do not use this function. For anonymous type registrations, use \l qmlRegisterAnonymousType(), + and make sure to provide a URI and a major version. +*/ + /*! \fn int qmlRegisterInterface(const char *typeName) \relates QQmlEngine -- cgit v1.2.3 From 36be27265d61c76b25417a25e482030e30ff380f Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Fri, 20 Sep 2019 16:38:30 +0200 Subject: QMLJS: Fix exception handling in promises If an exception is thrown inside a promise's resolve or reject handler, the promise needs to resolve into a rejected state with the exceptions value. The value was previously not set. Fixes: QTBUG-78554 Change-Id: Ic22faa6ef1e519e4cae6732c69bb14f7053d13da Reviewed-by: Ulf Hermann Reviewed-by: Qt CI Bot --- src/qml/jsruntime/qv4promiseobject.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/qml') diff --git a/src/qml/jsruntime/qv4promiseobject.cpp b/src/qml/jsruntime/qv4promiseobject.cpp index 40a0dfaa57..851fee7bd8 100644 --- a/src/qml/jsruntime/qv4promiseobject.cpp +++ b/src/qml/jsruntime/qv4promiseobject.cpp @@ -163,6 +163,7 @@ void ReactionHandler::executeReaction(ReactionEvent *event) ScopedFunctionObject reaction(scope); if (scope.hasException()) { reaction = capability->d()->reject.as(); + result = scope.engine->catchException(); } else { reaction = capability->d()->resolve.as(); } -- cgit v1.2.3 From d3817f4b0b42b180b36c3c5afb22eb592a7e2a91 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 13 Sep 2019 13:53:21 +0200 Subject: doc: Fix several qdoc warnings This update repares several "Can't link to...," "No such parameter...," and "Undocumented parameter..." warnings. Change-Id: I3649cf35f766e5a87ca5df48301e8063a31d7904 Reviewed-by: Paul Wicking --- src/qml/doc/src/qmlfunctions.qdoc | 2 +- src/qml/qml/qqmlapplicationengine.cpp | 2 +- src/qml/qml/qqmlcomponent.cpp | 7 ++++--- src/qml/qml/qqmlinfo.cpp | 6 +++--- 4 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src/qml') diff --git a/src/qml/doc/src/qmlfunctions.qdoc b/src/qml/doc/src/qmlfunctions.qdoc index 81aa263fa6..b083012eab 100644 --- a/src/qml/doc/src/qmlfunctions.qdoc +++ b/src/qml/doc/src/qmlfunctions.qdoc @@ -458,7 +458,7 @@ */ /*! - \fn template QObject *qmlAttachedPropertiesObject(const QObject *attachee, bool create = true) + \fn template QObject *qmlAttachedPropertiesObject(const QObject *attachee, bool create) \relates QQmlEngine The form of this template function is: diff --git a/src/qml/qml/qqmlapplicationengine.cpp b/src/qml/qml/qqmlapplicationengine.cpp index d04a89b514..adb036e2d0 100644 --- a/src/qml/qml/qqmlapplicationengine.cpp +++ b/src/qml/qml/qqmlapplicationengine.cpp @@ -279,7 +279,7 @@ void QQmlApplicationEngine::load(const QString &filePath) } /*! - Sets the initial properties with which the QML component gets initialized after + Sets the \a initialProperties with which the QML component gets initialized after it gets loaded. diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index ed8c41a582..b26b90d2aa 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -813,8 +813,9 @@ QObject *QQmlComponent::create(QQmlContext *context) } /*! - Create an object instance of this component, and initialize its toplevel properties according to initalPropertyValues. - + Create an object instance of this component, and initialize its toplevel + properties with \a initialProperties. \a context specifies the context + where the object instance is to be created. \sa QQmlComponent::create \since 5.14 @@ -1104,7 +1105,7 @@ void QQmlComponent::create(QQmlIncubator &incubator, QQmlContext *context, } /*! - Set toplevel properties of the component. + Set toplevel \a properties of the \a component. This method provides advanced control over component instance creation. diff --git a/src/qml/qml/qqmlinfo.cpp b/src/qml/qml/qqmlinfo.cpp index 6322302422..2bfd2d5bb4 100644 --- a/src/qml/qml/qqmlinfo.cpp +++ b/src/qml/qml/qqmlinfo.cpp @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE /*! \fn QQmlInfo QtQml::qmlDebug(const QObject *object) - \relates QQmlEngine + \relates QtQml \since 5.9 Prints debug messages that include the file and line number for the @@ -91,7 +91,7 @@ QT_BEGIN_NAMESPACE /*! \fn QQmlInfo QtQml::qmlInfo(const QObject *object) - \relates QQmlEngine + \relates QtQml Prints informational messages that include the file and line number for the specified QML \a object. @@ -119,7 +119,7 @@ QT_BEGIN_NAMESPACE /*! \fn QQmlInfo QtQml::qmlWarning(const QObject *object) - \relates QQmlEngine + \relates QtQml \since 5.9 Prints warning messages that include the file and line number for the -- cgit v1.2.3 From d9e7e24c6635a6cafaff681981ff0579d5313418 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 25 Sep 2019 11:39:25 +0200 Subject: Don't leak resolved types of failed compilations If the compilation fails QQmlTypeCompiler::compile() returns nullptr. In that case, there is no ExecutableCompilationUnit to own the resolved types. Therefore, delete them. Change-Id: Ia8f4ef78438642cb064538c7266ca636ec7eb0c1 Reviewed-by: Fabian Kosmale Reviewed-by: Simon Hausmann --- src/qml/qml/qqmltypecompiler.cpp | 9 ++++----- src/qml/qml/qqmltypedata.cpp | 2 ++ 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/qml') diff --git a/src/qml/qml/qqmltypecompiler.cpp b/src/qml/qml/qqmltypecompiler.cpp index 9a6bd73326..bbeaf7be9a 100644 --- a/src/qml/qml/qqmltypecompiler.cpp +++ b/src/qml/qml/qqmltypecompiler.cpp @@ -158,6 +158,9 @@ QQmlRefPointer QQmlTypeCompiler::compile() QmlIR::QmlUnitGenerator qmlGenerator; qmlGenerator.generate(*document, dependencyHasher); + if (!errors.isEmpty()) + return nullptr; + QQmlRefPointer compilationUnit = QV4::ExecutableCompilationUnit::create(std::move( document->javaScriptCompilationUnit)); @@ -165,11 +168,7 @@ QQmlRefPointer QQmlTypeCompiler::compile() compilationUnit->resolvedTypes = *resolvedTypes; compilationUnit->propertyCaches = std::move(m_propertyCaches); Q_ASSERT(compilationUnit->propertyCaches.count() == static_cast(compilationUnit->objectCount())); - - if (errors.isEmpty()) - return compilationUnit; - else - return nullptr; + return compilationUnit; } void QQmlTypeCompiler::recordError(const QV4::CompiledData::Location &location, const QString &description) diff --git a/src/qml/qml/qqmltypedata.cpp b/src/qml/qml/qqmltypedata.cpp index b9fbf40e96..5e85d7f692 100644 --- a/src/qml/qml/qqmltypedata.cpp +++ b/src/qml/qml/qqmltypedata.cpp @@ -614,6 +614,8 @@ void QQmlTypeData::compile(const QQmlRefPointer &typeNameCach QQmlTypeCompiler compiler(enginePrivate, this, m_document.data(), typeNameCache, resolvedTypeCache, dependencyHasher); m_compiledData = compiler.compile(); if (!m_compiledData) { + qDeleteAll(*resolvedTypeCache); + resolvedTypeCache->clear(); setError(compiler.compilationErrors()); return; } -- cgit v1.2.3 From a44cb389d3e59baaf0e3e85c682a49df7b90fad4 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 25 Sep 2019 11:07:34 +0200 Subject: Don't leak references to QQmlTypePrivate Change-Id: I1cad0d8aa81b26a91e97a869f3c8539ae3cf1ad6 Reviewed-by: Simon Hausmann Reviewed-by: Fabian Kosmale --- src/qml/qml/qqmlmetatypedata.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/qml') diff --git a/src/qml/qml/qqmlmetatypedata.cpp b/src/qml/qml/qqmlmetatypedata.cpp index 5dc0083f54..41a7778da3 100644 --- a/src/qml/qml/qqmlmetatypedata.cpp +++ b/src/qml/qml/qqmlmetatypedata.cpp @@ -69,6 +69,7 @@ void QQmlMetaTypeData::registerType(QQmlTypePrivate *priv) if (!types.at(i).isValid()) { types[i] = QQmlType(priv); priv->index = i; + priv->release(); return; } } -- cgit v1.2.3 From 3f44e0fc5f1d55498ce7fb93a7841198a7583a08 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 24 Sep 2019 12:24:16 +0200 Subject: Convert QTime to V4 Date on a date with no DST in force Sadly the third centennary of Cassini's birth isn't such a good date after all, since round-tripping will ignore DST on the QDateTime leg but include it in V4's implementation of ES's ill-conceived spec for handling DST and time-zone transitions; and June 8th is in summer for much of the world. So use a date which (as far as I can tell) appears to have been DST-free everywhere; and after the start of 1970 so that, even if we find ourselves working with a zone in which it did have DST, we'll apply DST consistently during round-tripping. Fixes: QTBUG-78706 Change-Id: I25be2548e2c97eae2c4f6c5bbe661dea2f35aaba Reviewed-by: Ulf Hermann --- src/qml/jsruntime/qv4dateobject.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/qml') diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index bba88e5c9a..5616b1450b 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -729,14 +729,16 @@ void Heap::DateObject::init(const QTime &time) * time from it, which shall (via toQDateTime(), below) discard the date * part. We need a date for which time-zone data is likely to be sane (so * MakeDay(0, 0, 0) was a bad choice; 2 BC, December 31st is before - * time-zones were standardized), with no transition nearby in date. We - * ignore DST transitions before 1970, but even then zone transitions did - * happen. Some do happen at new year, others on DST transitions in spring - * and autumn; so pick the three hundredth anniversary of the birth of - * Giovanni Domenico Cassini (1625-06-08), whose work first let us - * synchronize clocks tolerably accurately at distant locations. + * time-zones were standardized), with no transition nearby in date. + * QDateTime ignores DST transitions before 1970, but even then zone + * transitions did happen; and DaylightSavingTA() will include DST, at odds + * with QDateTime. So pick a date since 1970 and prefer one when no zone + * was in DST. One such interval (according to the Olson database, at + * least) was 1971 March 15th to April 17th. Since converting a time to a + * date-time without specifying a date is foolish, let's use April Fools' + * day. */ - static const double d = MakeDay(1925, 5, 8); + static const double d = MakeDay(1971, 3, 1); double t = MakeTime(time.hour(), time.minute(), time.second(), time.msec()); date = TimeClip(UTC(MakeDate(d, t), internalClass->engine->localTZA)); } -- cgit v1.2.3 From 224f053eba157fb908f08909d8e2015d76b08295 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 30 Sep 2019 16:20:19 +0200 Subject: Use a QQmlRefPointer for QQmlScriptData::typeNameCache The cache can get overwritten. We want the reference to the old one to be dropped then. Fixes: QTBUG-78865 Change-Id: I8ebba4ae242c3bf8ae4db5cffc65b26bab265b8a Reviewed-by: Simon Hausmann Reviewed-by: Fabian Kosmale --- src/qml/qml/qqmlscriptblob.cpp | 4 ++-- src/qml/qml/qqmlscriptdata.cpp | 6 +----- src/qml/qml/qqmlscriptdata_p.h | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) (limited to 'src/qml') diff --git a/src/qml/qml/qqmlscriptblob.cpp b/src/qml/qml/qqmlscriptblob.cpp index 69b26894a8..6ac30d3ab5 100644 --- a/src/qml/qml/qqmlscriptblob.cpp +++ b/src/qml/qml/qqmlscriptblob.cpp @@ -177,7 +177,7 @@ void QQmlScriptBlob::done() } if (!m_isModule) { - m_scriptData->typeNameCache = new QQmlTypeNameCache(m_importCache); + m_scriptData->typeNameCache.adopt(new QQmlTypeNameCache(m_importCache)); QSet ns; @@ -195,7 +195,7 @@ void QQmlScriptBlob::done() m_scriptData->typeNameCache->add(script.qualifier, scriptIndex, script.nameSpace); } - m_importCache.populateCache(m_scriptData->typeNameCache); + m_importCache.populateCache(m_scriptData->typeNameCache.data()); } m_scripts.clear(); } diff --git a/src/qml/qml/qqmlscriptdata.cpp b/src/qml/qml/qqmlscriptdata.cpp index 0725f40d2a..ae268ca904 100644 --- a/src/qml/qml/qqmlscriptdata.cpp +++ b/src/qml/qml/qqmlscriptdata.cpp @@ -156,11 +156,7 @@ QV4::ReturnedValue QQmlScriptData::scriptValueForContext(QQmlContextData *parent void QQmlScriptData::clear() { - if (typeNameCache) { - typeNameCache->release(); - typeNameCache = nullptr; - } - + typeNameCache = nullptr; scripts.clear(); // An addref() was made when the QQmlCleanup was added to the engine. diff --git a/src/qml/qml/qqmlscriptdata_p.h b/src/qml/qml/qqmlscriptdata_p.h index 273ba3691f..80b65b699c 100644 --- a/src/qml/qml/qqmlscriptdata_p.h +++ b/src/qml/qml/qqmlscriptdata_p.h @@ -82,7 +82,7 @@ private: public: QUrl url; QString urlString; - QQmlTypeNameCache *typeNameCache; + QQmlRefPointer typeNameCache; QVector> scripts; QV4::ReturnedValue scriptValueForContext(QQmlContextData *parentCtxt); -- cgit v1.2.3 From fcae2d13e43eab1ea60092194667939f85269bde Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 30 Sep 2019 14:40:57 +0200 Subject: Fix property cache leaks Leaks happened when using unqualified context property lookups and when looking up properties of singletons. We need to release the caches when unlinking. Fixes: QTBUG-78859 Change-Id: I8b86bcf72f71a463fb259eb6ae6c46be62729d72 Reviewed-by: Simon Hausmann Reviewed-by: Ulf Hermann --- src/qml/jsruntime/qv4executablecompilationunit.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/qml') diff --git a/src/qml/jsruntime/qv4executablecompilationunit.cpp b/src/qml/jsruntime/qv4executablecompilationunit.cpp index 58cd581eae..79e2ec2a5d 100644 --- a/src/qml/jsruntime/qv4executablecompilationunit.cpp +++ b/src/qml/jsruntime/qv4executablecompilationunit.cpp @@ -52,6 +52,7 @@ #include #include #include +#include #include #include @@ -291,15 +292,18 @@ void ExecutableCompilationUnit::unlink() if (runtimeLookups) { for (uint i = 0; i < data->lookupTableSize; ++i) { QV4::Lookup &l = runtimeLookups[i]; - if (l.getter == QV4::QObjectWrapper::lookupGetter) { + if (l.getter == QV4::QObjectWrapper::lookupGetter + || l.getter == QQmlTypeWrapper::lookupSingletonProperty) { if (QQmlPropertyCache *pc = l.qobjectLookup.propertyCache) pc->release(); - } else if (l.getter == QQmlValueTypeWrapper::lookupGetter) { + } else if (l.getter == QQmlValueTypeWrapper::lookupGetter + || l.getter == QQmlTypeWrapper::lookupSingletonProperty) { if (QQmlPropertyCache *pc = l.qgadgetLookup.propertyCache) pc->release(); } - if (l.qmlContextPropertyGetter == QQmlContextWrapper::lookupScopeObjectProperty) { + if (l.qmlContextPropertyGetter == QQmlContextWrapper::lookupScopeObjectProperty + || l.qmlContextPropertyGetter == QQmlContextWrapper::lookupContextObjectProperty) { if (QQmlPropertyCache *pc = l.qobjectLookup.propertyCache) pc->release(); } -- cgit v1.2.3 From 56926c6628978e349316066342e6d55369bbe373 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 30 Sep 2019 17:24:25 +0200 Subject: Delete type half-built type resolution caches on compile errors Otherwise they leak. Change-Id: I744f67e039ffb9cacbf16394bd5558ee72028177 Reviewed-by: Fabian Kosmale Reviewed-by: Simon Hausmann --- src/qml/qml/qqmltypedata.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/qml') diff --git a/src/qml/qml/qqmltypedata.cpp b/src/qml/qml/qqmltypedata.cpp index 5e85d7f692..99fe069685 100644 --- a/src/qml/qml/qqmltypedata.cpp +++ b/src/qml/qml/qqmltypedata.cpp @@ -305,6 +305,7 @@ void QQmlTypeData::done() QQmlJS::DiagnosticMessage error = buildTypeResolutionCaches(&typeNameCache, &resolvedTypeCache); if (error.isValid()) { setError(error); + qDeleteAll(resolvedTypeCache); return; } } -- cgit v1.2.3 From 670fdcc3f23493bc039a2676ce69892cc152dc6b Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Tue, 17 Sep 2019 10:48:10 +0300 Subject: Android: Load QML plugins directly from APK libs dir Also register qrc:/android_rcc_bundle/qml as the folder where declarative engine finds the other QML files (qmldir, *.qml, *.js, etc.). [ChangeLog][Android] load QML plugins directly from APK libs dir and use qrc:/android_rcc_bundle/qml to search for QML files. Change-Id: I9552121411d21537befc41646cdd161ce0cec760 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/qml/qml/qqmlimport.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/qml') diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index 31a7004407..5feea9daa8 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -1751,6 +1751,16 @@ QQmlImportDatabase::QQmlImportDatabase(QQmlEngine *e) addImportPath(QStringLiteral("qrc:/qt-project.org/imports")); addImportPath(QCoreApplication::applicationDirPath()); +#if defined(Q_OS_ANDROID) + addImportPath(QStringLiteral("qrc:/android_rcc_bundle/qml")); + if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty("QT_BUNDLED_LIBS_PATH"))) { + const QString envImportPath = qEnvironmentVariable("QT_BUNDLED_LIBS_PATH"); + QLatin1Char pathSep(':'); + QStringList paths = envImportPath.split(pathSep, QString::SkipEmptyParts); + for (int ii = paths.count() - 1; ii >= 0; --ii) + addPluginPath(paths.at(ii)); + } +#endif } QQmlImportDatabase::~QQmlImportDatabase() @@ -1798,6 +1808,18 @@ QString QQmlImportDatabase::resolvePlugin(QQmlTypeLoader *typeLoader, if (!resolvedPath.endsWith(Slash)) resolvedPath += Slash; +#if defined(Q_OS_ANDROID) + if (qmldirPath.size() > 25 && qmldirPath.at(0) == QLatin1Char(':') && qmldirPath.at(1) == QLatin1Char('/') && + qmldirPath.startsWith(QStringLiteral(":/android_rcc_bundle/qml/"), Qt::CaseInsensitive)) { + QString pluginName = qmldirPath.mid(21) + Slash + baseName; + auto bundledPath = resolvedPath + QLatin1String("lib") + pluginName.replace(QLatin1Char('/'), QLatin1Char('_')); + for (const QString &suffix : suffixes) { + const QString absolutePath = typeLoader->absoluteFilePath(bundledPath + suffix); + if (!absolutePath.isEmpty()) + return absolutePath; + } + } +#endif resolvedPath += prefix + baseName; for (const QString &suffix : suffixes) { const QString absolutePath = typeLoader->absoluteFilePath(resolvedPath + suffix); -- cgit v1.2.3 From ee9319f63c2e9d307bcda41669aaed9934d013ad Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 2 Oct 2019 15:04:53 +0200 Subject: QQmlBind: Mark restoreMode as explicitly also when set to default value Change-Id: I8aa36cbba95a64498b34c689086e45c115ce542b Reviewed-by: Simon Hausmann --- src/qml/types/qqmlbind.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qml') diff --git a/src/qml/types/qqmlbind.cpp b/src/qml/types/qqmlbind.cpp index 861243987f..9d305cd24c 100644 --- a/src/qml/types/qqmlbind.cpp +++ b/src/qml/types/qqmlbind.cpp @@ -382,10 +382,10 @@ QQmlBind::RestorationMode QQmlBind::restoreMode() const void QQmlBind::setRestoreMode(RestorationMode newMode) { Q_D(QQmlBind); + d->restoreModeExplicit = true; if (newMode != restoreMode()) { d->restoreValue = (newMode & RestoreValue); d->restoreBinding = (newMode & RestoreBinding); - d->restoreModeExplicit = true; emit restoreModeChanged(); } } -- cgit v1.2.3