diff options
83 files changed, 526 insertions, 181 deletions
diff --git a/examples/qml/qmlextensionplugins/plugin.cpp b/examples/qml/qmlextensionplugins/plugin.cpp index 56057b7f06..e04cfa57d8 100644 --- a/examples/qml/qmlextensionplugins/plugin.cpp +++ b/examples/qml/qmlextensionplugins/plugin.cpp @@ -141,7 +141,7 @@ MinuteTimer *TimeModel::timer=0; class QExampleQmlPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: void registerTypes(const char *uri) diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/app.pro b/examples/qml/tutorials/extending-qml/chapter6-plugins/app.pro index c55db00d27..4d0e807417 100644 --- a/examples/qml/tutorials/extending-qml/chapter6-plugins/app.pro +++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/app.pro @@ -1,10 +1,15 @@ TARGET = chapter6-plugins QT += qml quick -# Avoid going to debug/release subdirectory -# so that our application will see the -# import path for the Charts module. +# Ensure that the application will see the import path for the Charts module: +# * On Windows, do not build into a debug/release subdirectory. +# * On OS X, add the plugin files into the bundle. win32: DESTDIR = ./ +osx { + charts.files = $$OUT_PWD/Charts + charts.path = Contents/PlugIns + QMAKE_BUNDLE_DATA += charts +} SOURCES += main.cpp RESOURCES += app.qrc diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/chartsplugin.h b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/chartsplugin.h index 3c0f84fe34..2a9c2446bd 100644 --- a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/chartsplugin.h +++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/chartsplugin.h @@ -46,7 +46,7 @@ class ChartsPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: void registerTypes(const char *uri); diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/main.cpp b/examples/qml/tutorials/extending-qml/chapter6-plugins/main.cpp index b20ae35f92..d165513861 100644 --- a/examples/qml/tutorials/extending-qml/chapter6-plugins/main.cpp +++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2016 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. @@ -37,17 +37,21 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -//![0] #include <QtQuick/QQuickView> #include <QGuiApplication> +#include <QQmlEngine> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); +//![0] QQuickView view; +#ifdef Q_OS_OSX + view.engine()->addImportPath(app.applicationDirPath() + "/../PlugIns"); +#endif +//![0] view.setResizeMode(QQuickView::SizeRootObjectToView); view.setSource(QUrl("qrc:///app.qml")); view.show(); return app.exec(); } -//![0] diff --git a/examples/quick/customitems/painteditem/TextBalloonPlugin/plugin.h b/examples/quick/customitems/painteditem/TextBalloonPlugin/plugin.h index 3a2ddae871..d3a1f4ba91 100644 --- a/examples/quick/customitems/painteditem/TextBalloonPlugin/plugin.h +++ b/examples/quick/customitems/painteditem/TextBalloonPlugin/plugin.h @@ -55,7 +55,7 @@ class TextBalloonPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: void registerTypes(const char *uri) { diff --git a/examples/quick/imageprovider/imageprovider.cpp b/examples/quick/imageprovider/imageprovider.cpp index f402ce0ce8..1e4f53e736 100644 --- a/examples/quick/imageprovider/imageprovider.cpp +++ b/examples/quick/imageprovider/imageprovider.cpp @@ -87,7 +87,7 @@ public: class ImageProviderExtensionPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: void registerTypes(const char *uri) { @@ -103,7 +103,4 @@ public: }; -#define QQmlExtensionInterface_iid "org.qt-project.Qt.QQmlExtensionInterface" - - #include "imageprovider.moc" diff --git a/examples/quick/imageresponseprovider/imageresponseprovider.cpp b/examples/quick/imageresponseprovider/imageresponseprovider.cpp index bdec29114b..a888c823a6 100644 --- a/examples/quick/imageresponseprovider/imageresponseprovider.cpp +++ b/examples/quick/imageresponseprovider/imageresponseprovider.cpp @@ -102,7 +102,7 @@ private: class ImageProviderExtensionPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: void registerTypes(const char *uri) { @@ -117,7 +117,4 @@ public: }; - -#define QQmlExtensionInterface_iid "org.qt-project.Qt.QQmlExtensionInterface" - #include "imageresponseprovider.moc" diff --git a/src/3rdparty/masm/wtf/Compiler.h b/src/3rdparty/masm/wtf/Compiler.h index b886f37151..fc3b5c5c08 100644 --- a/src/3rdparty/masm/wtf/Compiler.h +++ b/src/3rdparty/masm/wtf/Compiler.h @@ -74,12 +74,15 @@ /* COMPILER(MSVC) - Microsoft Visual C++ */ /* COMPILER(MSVC7_OR_LOWER) - Microsoft Visual C++ 2003 or lower*/ /* COMPILER(MSVC9_OR_LOWER) - Microsoft Visual C++ 2008 or lower*/ +/* COMPILER(MSVC12_OR_LOWER) - Microsoft Visual C++ 2013 or lower*/ #if defined(_MSC_VER) #define WTF_COMPILER_MSVC 1 #if _MSC_VER < 1400 #define WTF_COMPILER_MSVC7_OR_LOWER 1 #elif _MSC_VER < 1600 #define WTF_COMPILER_MSVC9_OR_LOWER 1 +#elif _MSC_VER < 1800 +#define WTF_COMPILER_MSVC12_OR_LOWER 1 #endif /* Specific compiler features */ diff --git a/src/3rdparty/masm/wtf/MathExtras.h b/src/3rdparty/masm/wtf/MathExtras.h index 9a85291ae2..9ded0ab736 100644 --- a/src/3rdparty/masm/wtf/MathExtras.h +++ b/src/3rdparty/masm/wtf/MathExtras.h @@ -173,11 +173,15 @@ inline float log2f(float num) inline long long abs(long long num) { return _abs64(num); } #endif +#if COMPILER(MSVC12_OR_LOWER) + inline double nextafter(double x, double y) { return _nextafter(x, y); } inline float nextafterf(float x, float y) { return x > y ? x - FLT_EPSILON : x + FLT_EPSILON; } inline double copysign(double x, double y) { return _copysign(x, y); } +#endif // COMPILER(MSVC12_OR_LOWER) + // Work around a bug in Win, where atan2(+-infinity, +-infinity) yields NaN instead of specific values. inline double wtf_atan2(double x, double y) { @@ -211,6 +215,8 @@ inline double wtf_pow(double x, double y) { return y == 0 ? 1 : pow(x, y); } #define fmod(x, y) wtf_fmod(x, y) #define pow(x, y) wtf_pow(x, y) +#if COMPILER(MSVC12_OR_LOWER) + // MSVC's math functions do not bring lrint. inline long int lrint(double flt) { @@ -233,6 +239,7 @@ inline long int lrint(double flt) return static_cast<long int>(intgr); } +#endif // COMPILER(MSVC12_OR_LOWER) #endif // COMPILER(MSVC) inline double deg2rad(double d) { return d * piDouble / 180.0; } diff --git a/src/imports/folderlistmodel/plugin.cpp b/src/imports/folderlistmodel/plugin.cpp index c60538673b..69d8c41698 100644 --- a/src/imports/folderlistmodel/plugin.cpp +++ b/src/imports/folderlistmodel/plugin.cpp @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE class QmlFolderListModelPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QmlFolderListModelPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } diff --git a/src/imports/layouts/plugin.cpp b/src/imports/layouts/plugin.cpp index 248b12ac31..ca54030d13 100644 --- a/src/imports/layouts/plugin.cpp +++ b/src/imports/layouts/plugin.cpp @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE class QtQuickLayoutsPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QtQuickLayoutsPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index da1817d309..89ed60ec84 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -754,7 +754,7 @@ static QObject *module_api_factory(QQmlEngine *engine, QJSEngine *scriptEngine) class QQmlLocalStoragePlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QQmlLocalStoragePlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) diff --git a/src/imports/models/plugin.cpp b/src/imports/models/plugin.cpp index 9f96ace8fe..36a98e8871 100644 --- a/src/imports/models/plugin.cpp +++ b/src/imports/models/plugin.cpp @@ -75,7 +75,7 @@ QT_BEGIN_NAMESPACE class QtQmlModelsPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QtQmlModelsPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } virtual void registerTypes(const char *uri) diff --git a/src/imports/particles/plugin.cpp b/src/imports/particles/plugin.cpp index 0698f34020..a228bc812a 100644 --- a/src/imports/particles/plugin.cpp +++ b/src/imports/particles/plugin.cpp @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE class QtQuick2ParticlesPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QtQuick2ParticlesPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } virtual void registerTypes(const char *uri) diff --git a/src/imports/qtquick2/plugin.cpp b/src/imports/qtquick2/plugin.cpp index 315ad0ce58..4fb6907077 100644 --- a/src/imports/qtquick2/plugin.cpp +++ b/src/imports/qtquick2/plugin.cpp @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE class QtQuick2Plugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QtQuick2Plugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } virtual void registerTypes(const char *uri) diff --git a/src/imports/settings/plugin.cpp b/src/imports/settings/plugin.cpp index c97c2b066e..04e93fa49c 100644 --- a/src/imports/settings/plugin.cpp +++ b/src/imports/settings/plugin.cpp @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE class QmlSettingsPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QmlSettingsPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } diff --git a/src/imports/statemachine/plugin.cpp b/src/imports/statemachine/plugin.cpp index db79751b69..6d0549ed5d 100644 --- a/src/imports/statemachine/plugin.cpp +++ b/src/imports/statemachine/plugin.cpp @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE class QtQmlStateMachinePlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtQml.StateMachine/1.0") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QtQmlStateMachinePlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } diff --git a/src/imports/testlib/main.cpp b/src/imports/testlib/main.cpp index 26ce79c92b..4147f0207e 100644 --- a/src/imports/testlib/main.cpp +++ b/src/imports/testlib/main.cpp @@ -147,7 +147,7 @@ QT_BEGIN_NAMESPACE class QTestQmlModule : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QTestQmlModule(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } diff --git a/src/imports/window/plugin.cpp b/src/imports/window/plugin.cpp index a0a5724e34..1e528fcbba 100644 --- a/src/imports/window/plugin.cpp +++ b/src/imports/window/plugin.cpp @@ -70,7 +70,7 @@ QT_BEGIN_NAMESPACE class QtQuick2WindowPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QtQuick2WindowPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } virtual void registerTypes(const char *uri) diff --git a/src/imports/xmllistmodel/plugin.cpp b/src/imports/xmllistmodel/plugin.cpp index e983b494e1..341baae2a3 100644 --- a/src/imports/xmllistmodel/plugin.cpp +++ b/src/imports/xmllistmodel/plugin.cpp @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE class QmlXmlListModelPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QmlXmlListModelPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } diff --git a/src/particles/qquickcustomparticle.cpp b/src/particles/qquickcustomparticle.cpp index 32b2fd847e..3cb7f6c2bf 100644 --- a/src/particles/qquickcustomparticle.cpp +++ b/src/particles/qquickcustomparticle.cpp @@ -290,8 +290,6 @@ QQuickShaderEffectNode *QQuickCustomParticle::prepareNextFrame(QQuickShaderEffec builder.appendSourceFile(QStringLiteral(":/particles/shaders/customparticle.vert")); s.sourceCode[Key::VertexShader] = builder.source() + s.sourceCode[Key::VertexShader]; - s.className = metaObject()->className(); - material->setProgramSource(s); material->attributes = m_common.attributes; foreach (QQuickShaderEffectNode* node, m_nodes) diff --git a/src/qml/doc/src/cppintegration/extending-tutorial.qdoc b/src/qml/doc/src/cppintegration/extending-tutorial.qdoc index d862b50fcb..c0cfc3e1aa 100644 --- a/src/qml/doc/src/cppintegration/extending-tutorial.qdoc +++ b/src/qml/doc/src/cppintegration/extending-tutorial.qdoc @@ -386,12 +386,26 @@ directory. \quotefile tutorials/extending-qml/chapter6-plugins/import/import.pro -In this example, the \c Charts directory is 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. Alternatively, we could control what directories the \l {QML Import Path} -{QML import path} contains, useful if there are multiple QML applications using the -same QML imports. +When building this example on Windows or Linux, the \c Charts directory will be +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 OS X, 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}: + +\quotefromfile tutorials/extending-qml/chapter6-plugins/app.pro +\skipto osx +\printuntil } + +To account for this, we also need to add this location as a +\l {QML Import Path}{QML import path} in \c main.cpp: + +\snippet tutorials/extending-qml/chapter6-plugins/main.cpp 0 +\dots + +Defining custom import paths is useful also when there are multiple +applications using the same QML imports. The \c .pro file also contains additional magic to ensure that the \l {Module Definition qmldir Files}{module definition qmldir file} is always copied diff --git a/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc b/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc index 04d769e4dc..04d0d0ed2e 100644 --- a/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc +++ b/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc @@ -508,7 +508,7 @@ built-in \l {Rectangle::color} property: Any object that use this type and refer to its \c color property will be referring to the alias rather than the ordinary \l {Rectangle::color} property. -Internally, however, the red can correctly set its \c color +Internally, however, the rectangle can correctly set its \c color property and refer to the actual defined property rather than the alias. diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp index 728ee38e76..8f002c7b65 100644 --- a/src/qml/jsruntime/qv4arraydata.cpp +++ b/src/qml/jsruntime/qv4arraydata.cpp @@ -287,7 +287,13 @@ void SimpleArrayData::push_front(Object *o, const Value *values, uint n) Q_ASSERT(o->d()->arrayData->type == Heap::ArrayData::Simple); dd = o->d()->arrayData.cast<Heap::SimpleArrayData>(); } - dd->offset = (dd->offset - n) % dd->alloc; + if (n <= dd->offset) { + dd->offset -= n; // there is enough space left in front + } else { + // we need to wrap around, so: + dd->offset = dd->alloc - // start at the back, but subtract: + (n - dd->offset); // the number of items we can put in the free space at the start of the allocated array + } dd->len += n; for (uint i = 0; i < n; ++i) dd->data(i) = values[i].asReturnedValue(); diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 5fb44307a9..3be32c7920 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -1276,6 +1276,8 @@ static int MatchScore(const QV4::Value &actual, int conversionType) return 10; } else if (conversionType == QMetaType::QJsonObject) { return 5; + } else if (conversionType == qMetaTypeId<QJSValue>()) { + return 0; } else { return 10; } diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index 2a1717f190..514e7beef8 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -893,8 +893,8 @@ bool QQmlImportsPrivate::populatePluginPairVector(QVector<StaticPluginPair> &res // To avoid traversing all static plugins for all imports, we cut down // the list the first time called to only contain QML plugins: foreach (const QStaticPlugin &plugin, QPluginLoader::staticPlugins()) { - if (qobject_cast<QQmlExtensionPlugin *>(plugin.instance())) - plugins.append(plugin); + if (plugin.metaData().value(QStringLiteral("IID")).toString() == QLatin1String(QQmlExtensionInterface_iid)) + plugins.append(plugin); } } diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 7fed82f4a4..d164dc614f 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -1105,6 +1105,7 @@ void QQmlTypeLoader::loadThread(QQmlDataBlob *blob) } #define DATALOADER_MAXIMUM_REDIRECT_RECURSION 16 +#define TYPELOADER_MINIMUM_TRIM_THRESHOLD 64 void QQmlTypeLoader::networkReplyFinished(QNetworkReply *reply) { @@ -1581,7 +1582,8 @@ bool QQmlTypeLoader::QmldirContent::designerSupported() const Constructs a new type loader that uses the given \a engine. */ QQmlTypeLoader::QQmlTypeLoader(QQmlEngine *engine) - : m_engine(engine), m_thread(new QQmlTypeLoaderThread(this)) + : m_engine(engine), m_thread(new QQmlTypeLoaderThread(this)), + m_typeCacheTrimThreshold(TYPELOADER_MINIMUM_TRIM_THRESHOLD) { } @@ -1618,6 +1620,10 @@ QQmlTypeData *QQmlTypeLoader::getType(const QUrl &url, Mode mode) QQmlTypeData *typeData = m_typeCache.value(url); if (!typeData) { + // Trim before adding the new type, so that we don't immediately trim it away + if (m_typeCache.size() >= m_typeCacheTrimThreshold) + trimCache(); + typeData = new QQmlTypeData(url, this); // TODO: if (compiledData == 0), is it safe to omit this insertion? m_typeCache.insert(url, typeData); @@ -1922,12 +1928,22 @@ void QQmlTypeLoader::clearCache() qDeleteAll(m_importQmlDirCache); m_typeCache.clear(); + m_typeCacheTrimThreshold = TYPELOADER_MINIMUM_TRIM_THRESHOLD; m_scriptCache.clear(); m_qmldirCache.clear(); m_importDirCache.clear(); m_importQmlDirCache.clear(); } +void QQmlTypeLoader::updateTypeCacheTrimThreshold() +{ + int size = m_typeCache.size(); + if (size > m_typeCacheTrimThreshold) + m_typeCacheTrimThreshold = size * 2; + if (size < m_typeCacheTrimThreshold / 2) + m_typeCacheTrimThreshold = qMax(size * 2, TYPELOADER_MINIMUM_TRIM_THRESHOLD); +} + void QQmlTypeLoader::trimCache() { while (true) { @@ -1952,6 +1968,8 @@ void QQmlTypeLoader::trimCache() } } + updateTypeCacheTrimThreshold(); + // TODO: release any scripts which are no longer referenced by any types } diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h index 01d223bbce..51228eacc7 100644 --- a/src/qml/qml/qqmltypeloader_p.h +++ b/src/qml/qml/qqmltypeloader_p.h @@ -364,6 +364,7 @@ private: QQmlTypeLoaderThread *m_thread; NetworkReplies m_networkReplies; TypeCache m_typeCache; + int m_typeCacheTrimThreshold; ScriptCache m_scriptCache; QmldirCache m_qmldirCache; ImportDirCache m_importDirCache; @@ -371,6 +372,7 @@ private: template<typename Loader> void doLoad(const Loader &loader, QQmlDataBlob *blob, Mode mode); + void updateTypeCacheTrimThreshold(); friend struct PlainLoader; friend struct CachedLoader; diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 333b1903f5..ed478fa17f 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -95,9 +95,9 @@ Heap::QtObject::QtObject(QQmlEngine *qmlEngine) const QMetaObject *qtMetaObject = StaticQtMetaObject::get(); ScopedString str(scope); ScopedValue v(scope); - for (int ii = 0; ii < qtMetaObject->enumeratorCount(); ++ii) { + for (int ii = 0, eii = qtMetaObject->enumeratorCount(); ii < eii; ++ii) { QMetaEnum enumerator = qtMetaObject->enumerator(ii); - for (int jj = 0; jj < enumerator.keyCount(); ++jj) { + for (int jj = 0, ejj = enumerator.keyCount(); jj < ejj; ++jj) { o->put((str = scope.engine->newString(QString::fromUtf8(enumerator.key(jj)))), (v = QV4::Primitive::fromInt32(enumerator.value(jj)))); } } diff --git a/src/quick/designer/qqmldesignermetaobject.cpp b/src/quick/designer/qqmldesignermetaobject.cpp index 46808f978b..0bfa72e9d4 100644 --- a/src/quick/designer/qqmldesignermetaobject.cpp +++ b/src/quick/designer/qqmldesignermetaobject.cpp @@ -140,9 +140,13 @@ void QQmlDesignerMetaObject::init(QObject *object, QQmlEngine *engine) QObjectPrivate *op = QObjectPrivate::get(object); op->metaObject = this; - //create cache - cache = m_cache = QQmlEnginePrivate::get(engine)->cache(this); - cache->addref(); + m_cache = QQmlEnginePrivate::get(engine)->cache(this); + + if (m_cache != cache) { + m_cache->addref(); + cache->release(); + cache = m_cache; + } //If our parent is not a VMEMetaObject we just se the flag to false again if (constructedMetaData(metaData)) @@ -166,17 +170,16 @@ QQmlDesignerMetaObject::QQmlDesignerMetaObject(QObject *object, QQmlEngine *engi if (ddata && ddata->propertyCache) { cache->setParent(ddata->propertyCache); cache->invalidate(engine, this); + ddata->propertyCache->release(); ddata->propertyCache = m_cache; + m_cache->addref(); } } QQmlDesignerMetaObject::~QQmlDesignerMetaObject() { - if (cache->count() > 1) // qml is crashing because the property cache is not removed from the engine - cache->release(); - else - m_type->release(); + m_type->release(); nodeInstanceMetaObjectList.remove(this); } diff --git a/src/quick/items/qquickanchors.cpp b/src/quick/items/qquickanchors.cpp index 193be7c45b..df33a0cc5c 100644 --- a/src/quick/items/qquickanchors.cpp +++ b/src/quick/items/qquickanchors.cpp @@ -39,19 +39,48 @@ #include "qquickanchors_p_p.h" -#include "qquickitem.h" #include "qquickitem_p.h" #include <qqmlinfo.h> QT_BEGIN_NAMESPACE +static Q_ALWAYS_INLINE QQuickItem *readParentItem(QQuickItem *item) +{ + return QQuickItemPrivate::get(item)->parentItem; +} + +static Q_ALWAYS_INLINE qreal readX(QQuickItem *item) +{ + return QQuickItemPrivate::get(item)->x; +} + +static Q_ALWAYS_INLINE qreal readY(QQuickItem *item) +{ + return QQuickItemPrivate::get(item)->y; +} + +static Q_ALWAYS_INLINE qreal readWidth(QQuickItem *item) +{ + return QQuickItemPrivate::get(item)->width; +} + +static Q_ALWAYS_INLINE qreal readHeight(QQuickItem *item) +{ + return QQuickItemPrivate::get(item)->height; +} + +static Q_ALWAYS_INLINE qreal readBaselineOffset(QQuickItem *item) +{ + return QQuickItemPrivate::get(item)->baselineOffset; +} + //TODO: should we cache relationships, so we don't have to check each time (parent-child or sibling)? //TODO: support non-parent, non-sibling (need to find lowest common ancestor) static inline qreal hcenter(QQuickItem *item) { - qreal width = item->width(); + qreal width = readWidth(item); if (QQuickAnchors *anchors = QQuickItemPrivate::get(item)->_anchors) { if (!QQuickAnchorsPrivate::get(anchors)->centerAligned) return width / 2; @@ -65,7 +94,7 @@ static inline qreal hcenter(QQuickItem *item) static inline qreal vcenter(QQuickItem *item) { - qreal height = item->height(); + qreal height = readHeight(item); if (QQuickAnchors *anchors = QQuickItemPrivate::get(item)->_anchors) { if (!QQuickAnchorsPrivate::get(anchors)->centerAligned) return height / 2; @@ -84,25 +113,25 @@ static qreal position(QQuickItem *item, QQuickAnchorLine::AnchorLine anchorLine) qreal ret = 0.0; switch (anchorLine) { case QQuickAnchorLine::Left: - ret = item->x(); + ret = readX(item); break; case QQuickAnchorLine::Right: - ret = item->x() + item->width(); + ret = readX(item) + readWidth(item); break; case QQuickAnchorLine::Top: - ret = item->y(); + ret = readY(item); break; case QQuickAnchorLine::Bottom: - ret = item->y() + item->height(); + ret = readY(item) + readHeight(item); break; case QQuickAnchorLine::HCenter: - ret = item->x() + hcenter(item); + ret = readX(item) + hcenter(item); break; case QQuickAnchorLine::VCenter: - ret = item->y() + vcenter(item); + ret = readY(item) + vcenter(item); break; case QQuickAnchorLine::Baseline: - ret = item->y() + item->baselineOffset(); + ret = readY(item) + readBaselineOffset(item); break; default: break; @@ -112,7 +141,7 @@ static qreal position(QQuickItem *item, QQuickAnchorLine::AnchorLine anchorLine) } //position when origin is 0,0 -static qreal adjustedPosition(QQuickItem *item, QQuickAnchorLine::AnchorLine anchorLine) +static inline qreal adjustedPosition(QQuickItem *item, QQuickAnchorLine::AnchorLine anchorLine) { qreal ret = 0.0; switch (anchorLine) { @@ -120,13 +149,13 @@ static qreal adjustedPosition(QQuickItem *item, QQuickAnchorLine::AnchorLine anc ret = 0.0; break; case QQuickAnchorLine::Right: - ret = item->width(); + ret = readWidth(item); break; case QQuickAnchorLine::Top: ret = 0.0; break; case QQuickAnchorLine::Bottom: - ret = item->height(); + ret = readHeight(item); break; case QQuickAnchorLine::HCenter: ret = hcenter(item); @@ -135,7 +164,7 @@ static qreal adjustedPosition(QQuickItem *item, QQuickAnchorLine::AnchorLine anc ret = vcenter(item); break; case QQuickAnchorLine::Baseline: - ret = item->baselineOffset(); + ret = readBaselineOffset(item); break; default: break; @@ -175,12 +204,13 @@ void QQuickAnchorsPrivate::fillChanged() qreal horizontalMargin = q->mirrored() ? rightMargin : leftMargin; - if (fill == item->parentItem()) { //child-parent + if (fill == readParentItem(item)) { //child-parent setItemPos(QPointF(horizontalMargin, topMargin)); - } else if (fill->parentItem() == item->parentItem()) { //siblings - setItemPos(QPointF(fill->x()+horizontalMargin, fill->y()+topMargin)); + } else if (readParentItem(fill) == readParentItem(item)) { //siblings + setItemPos(QPointF(readX(fill)+horizontalMargin, readY(fill) + topMargin)); } - setItemSize(QSizeF(fill->width()-leftMargin-rightMargin, fill->height()-topMargin-bottomMargin)); + setItemSize(QSizeF(readWidth(fill) - leftMargin - rightMargin, + readHeight(fill) - topMargin - bottomMargin)); --updatingFill; } else { @@ -200,12 +230,12 @@ void QQuickAnchorsPrivate::centerInChanged() ++updatingCenterIn; qreal effectiveHCenterOffset = q->mirrored() ? -hCenterOffset : hCenterOffset; - if (centerIn == item->parentItem()) { - QPointF p(hcenter(item->parentItem()) - hcenter(item) + effectiveHCenterOffset, - vcenter(item->parentItem()) - vcenter(item) + vCenterOffset); + if (centerIn == readParentItem(item)) { + QPointF p(hcenter(readParentItem(item)) - hcenter(item) + effectiveHCenterOffset, + vcenter(readParentItem(item)) - vcenter(item) + vCenterOffset); setItemPos(p); - } else if (centerIn->parentItem() == item->parentItem()) { + } else if (readParentItem(centerIn) == readParentItem(item)) { QPointF p(centerIn->x() + hcenter(centerIn) - hcenter(item) + effectiveHCenterOffset, centerIn->y() + vcenter(centerIn) - vcenter(item) + vCenterOffset); setItemPos(p); @@ -264,7 +294,7 @@ int QQuickAnchorsPrivate::calculateDependency(QQuickItem *controlItem) return dependency; if (fill == controlItem) { - if (controlItem == item->parentItem()) + if (controlItem == readParentItem(item)) dependency |= QQuickItemPrivate::SizeChange; else //sibling dependency |= QQuickItemPrivate::GeometryChange; @@ -272,7 +302,7 @@ int QQuickAnchorsPrivate::calculateDependency(QQuickItem *controlItem) } if (centerIn == controlItem) { - if (controlItem == item->parentItem()) + if (controlItem == readParentItem(item)) dependency |= QQuickItemPrivate::SizeChange; else //sibling dependency |= QQuickItemPrivate::GeometryChange; @@ -282,7 +312,7 @@ int QQuickAnchorsPrivate::calculateDependency(QQuickItem *controlItem) if ((usedAnchors & QQuickAnchors::LeftAnchor && left.item == controlItem) || (usedAnchors & QQuickAnchors::RightAnchor && right.item == controlItem) || (usedAnchors & QQuickAnchors::HCenterAnchor && hCenter.item == controlItem)) { - if (controlItem == item->parentItem()) + if (controlItem == readParentItem(item)) dependency |= QQuickItemPrivate::WidthChange; else //sibling dependency |= QFlags<QQuickItemPrivate::GeometryChangeType>(QQuickItemPrivate::XChange | QQuickItemPrivate::WidthChange); @@ -292,7 +322,7 @@ int QQuickAnchorsPrivate::calculateDependency(QQuickItem *controlItem) (usedAnchors & QQuickAnchors::BottomAnchor && bottom.item == controlItem) || (usedAnchors & QQuickAnchors::VCenterAnchor && vCenter.item == controlItem) || (usedAnchors & QQuickAnchors::BaselineAnchor && baseline.item == controlItem)) { - if (controlItem == item->parentItem()) + if (controlItem == readParentItem(item)) dependency |= QQuickItemPrivate::HeightChange; else //sibling dependency |= QFlags<QQuickItemPrivate::GeometryChangeType>(QQuickItemPrivate::YChange | QQuickItemPrivate::HeightChange); @@ -448,22 +478,36 @@ void QQuickAnchorsPrivate::updateOnComplete() void QQuickAnchorsPrivate::update() { - fillChanged(); - centerInChanged(); - if (usedAnchors & QQuickAnchorLine::Horizontal_Mask) - updateHorizontalAnchors(); - if (usedAnchors & QQuickAnchorLine::Vertical_Mask) - updateVerticalAnchors(); + if (!isItemComplete()) + return; + + if (fill) { + fillChanged(); + } else if (centerIn) { + centerInChanged(); + } else { + if (usedAnchors & QQuickAnchorLine::Horizontal_Mask) + updateHorizontalAnchors(); + if (usedAnchors & QQuickAnchorLine::Vertical_Mask) + updateVerticalAnchors(); + } } void QQuickAnchorsPrivate::itemGeometryChanged(QQuickItem *, const QRectF &newG, const QRectF &oldG) { - fillChanged(); - centerInChanged(); - if ((usedAnchors & QQuickAnchorLine::Horizontal_Mask) && (newG.x() != oldG.x() || newG.width() != oldG.width())) - updateHorizontalAnchors(); - if ((usedAnchors & QQuickAnchorLine::Vertical_Mask) && (newG.y() != oldG.y() || newG.height() != oldG.height())) - updateVerticalAnchors(); + if (!isItemComplete()) + return; + + if (fill) { + fillChanged(); + } else if (centerIn) { + centerInChanged(); + } else { + if ((usedAnchors & QQuickAnchorLine::Horizontal_Mask) && (newG.x() != oldG.x() || newG.width() != oldG.width())) + updateHorizontalAnchors(); + if ((usedAnchors & QQuickAnchorLine::Vertical_Mask) && (newG.y() != oldG.y() || newG.height() != oldG.height())) + updateVerticalAnchors(); + } } QQuickItem *QQuickAnchors::fill() const @@ -485,7 +529,7 @@ void QQuickAnchors::setFill(QQuickItem *f) emit fillChanged(); return; } - if (f != d->item->parentItem() && f->parentItem() != d->item->parentItem()){ + if (f != readParentItem(d->item) && readParentItem(f) != readParentItem(d->item)){ qmlInfo(d->item) << tr("Cannot anchor to an item that isn't a parent or sibling."); return; } @@ -521,7 +565,7 @@ void QQuickAnchors::setCenterIn(QQuickItem* c) emit centerInChanged(); return; } - if (c != d->item->parentItem() && c->parentItem() != d->item->parentItem()){ + if (c != readParentItem(d->item) && readParentItem(c) != readParentItem(d->item)){ qmlInfo(d->item) << tr("Cannot anchor to an item that isn't a parent or sibling."); return; } @@ -545,10 +589,10 @@ bool QQuickAnchorsPrivate::calcStretch(const QQuickAnchorLine &edge1, QQuickAnchorLine::AnchorLine line, qreal &stretch) { - bool edge1IsParent = (edge1.item == item->parentItem()); - bool edge2IsParent = (edge2.item == item->parentItem()); - bool edge1IsSibling = (edge1.item->parentItem() == item->parentItem()); - bool edge2IsSibling = (edge2.item->parentItem() == item->parentItem()); + bool edge1IsParent = (edge1.item == readParentItem(item)); + bool edge2IsParent = (edge2.item == readParentItem(item)); + bool edge1IsSibling = (readParentItem(edge1.item) == readParentItem(item)); + bool edge2IsSibling = (readParentItem(edge2.item) == readParentItem(item)); bool invalid = false; if ((edge2IsParent && edge1IsParent) || (edge2IsSibling && edge1IsSibling)) { @@ -556,10 +600,10 @@ bool QQuickAnchorsPrivate::calcStretch(const QQuickAnchorLine &edge1, - (position(edge1.item, edge1.anchorLine) + offset1); } else if (edge2IsParent && edge1IsSibling) { stretch = (position(edge2.item, edge2.anchorLine) + offset2) - - (position(item->parentItem(), line) + - (position(readParentItem(item), line) + position(edge1.item, edge1.anchorLine) + offset1); } else if (edge2IsSibling && edge1IsParent) { - stretch = (position(item->parentItem(), line) + position(edge2.item, edge2.anchorLine) + offset2) + stretch = (position(readParentItem(item), line) + position(edge2.item, edge2.anchorLine) + offset2) - (position(edge1.item, edge1.anchorLine) + offset1); } else invalid = true; @@ -588,9 +632,9 @@ void QQuickAnchorsPrivate::updateVerticalAnchors() setItemHeight(height); //Handle top - if (top.item == item->parentItem()) { + if (top.item == readParentItem(item)) { setItemY(adjustedPosition(top.item, top.anchorLine) + topMargin); - } else if (top.item->parentItem() == item->parentItem()) { + } else if (readParentItem(top.item) == readParentItem(item)) { setItemY(position(top.item, top.anchorLine) + topMargin); } } else if (usedAnchors & QQuickAnchors::BottomAnchor) { @@ -604,27 +648,29 @@ void QQuickAnchorsPrivate::updateVerticalAnchors() } //Handle bottom - if (bottom.item == item->parentItem()) { - setItemY(adjustedPosition(bottom.item, bottom.anchorLine) - item->height() - bottomMargin); - } else if (bottom.item->parentItem() == item->parentItem()) { - setItemY(position(bottom.item, bottom.anchorLine) - item->height() - bottomMargin); + if (bottom.item == readParentItem(item)) { + setItemY(adjustedPosition(bottom.item, bottom.anchorLine) - readHeight(item) - bottomMargin); + } else if (readParentItem(bottom.item) == readParentItem(item)) { + setItemY(position(bottom.item, bottom.anchorLine) - readHeight(item) - bottomMargin); } } else if (usedAnchors & QQuickAnchors::VCenterAnchor) { //(stetching handled above) //Handle vCenter - if (vCenter.item == item->parentItem()) { + if (vCenter.item == readParentItem(item)) { setItemY(adjustedPosition(vCenter.item, vCenter.anchorLine) - vcenter(item) + vCenterOffset); - } else if (vCenter.item->parentItem() == item->parentItem()) { + } else if (readParentItem(vCenter.item) == readParentItem(item)) { setItemY(position(vCenter.item, vCenter.anchorLine) - vcenter(item) + vCenterOffset); } } else if (usedAnchors & QQuickAnchors::BaselineAnchor) { //Handle baseline - if (baseline.item == item->parentItem()) { - setItemY(adjustedPosition(baseline.item, baseline.anchorLine) - item->baselineOffset() + baselineOffset); - } else if (baseline.item->parentItem() == item->parentItem()) { - setItemY(position(baseline.item, baseline.anchorLine) - item->baselineOffset() + baselineOffset); + if (baseline.item == readParentItem(item)) { + setItemY(adjustedPosition(baseline.item, baseline.anchorLine) + - readBaselineOffset(item) + baselineOffset); + } else if (readParentItem(baseline.item) == readParentItem(item)) { + setItemY(position(baseline.item, baseline.anchorLine) + - readBaselineOffset(item) + baselineOffset); } } --updatingVerticalAnchor; @@ -693,9 +739,9 @@ void QQuickAnchorsPrivate::updateHorizontalAnchors() setItemWidth(width); //Handle left - if (effectiveLeft.item == item->parentItem()) { + if (effectiveLeft.item == readParentItem(item)) { setItemX(adjustedPosition(effectiveLeft.item, effectiveLeft.anchorLine) + effectiveLeftMargin); - } else if (effectiveLeft.item->parentItem() == item->parentItem()) { + } else if (readParentItem(effectiveLeft.item) == readParentItem(item)) { setItemX(position(effectiveLeft.item, effectiveLeft.anchorLine) + effectiveLeftMargin); } } else if (usedAnchors & effectiveRightAnchor) { @@ -709,16 +755,18 @@ void QQuickAnchorsPrivate::updateHorizontalAnchors() } //Handle right - if (effectiveRight.item == item->parentItem()) { - setItemX(adjustedPosition(effectiveRight.item, effectiveRight.anchorLine) - item->width() - effectiveRightMargin); - } else if (effectiveRight.item->parentItem() == item->parentItem()) { - setItemX(position(effectiveRight.item, effectiveRight.anchorLine) - item->width() - effectiveRightMargin); + if (effectiveRight.item == readParentItem(item)) { + setItemX(adjustedPosition(effectiveRight.item, effectiveRight.anchorLine) + - readWidth(item) - effectiveRightMargin); + } else if (readParentItem(effectiveRight.item) == readParentItem(item)) { + setItemX(position(effectiveRight.item, effectiveRight.anchorLine) + - readWidth(item) - effectiveRightMargin); } } else if (usedAnchors & QQuickAnchors::HCenterAnchor) { //Handle hCenter - if (effectiveHorizontalCenter.item == item->parentItem()) { + if (effectiveHorizontalCenter.item == readParentItem(item)) { setItemX(adjustedPosition(effectiveHorizontalCenter.item, effectiveHorizontalCenter.anchorLine) - hcenter(item) + effectiveHorizontalCenterOffset); - } else if (effectiveHorizontalCenter.item->parentItem() == item->parentItem()) { + } else if (readParentItem(effectiveHorizontalCenter.item) == readParentItem(item)) { setItemX(position(effectiveHorizontalCenter.item, effectiveHorizontalCenter.anchorLine) - hcenter(item) + effectiveHorizontalCenterOffset); } } @@ -1254,7 +1302,7 @@ bool QQuickAnchorsPrivate::checkHAnchorValid(QQuickAnchorLine anchor) const } else if (anchor.anchorLine & QQuickAnchorLine::Vertical_Mask) { qmlInfo(item) << QQuickAnchors::tr("Cannot anchor a horizontal edge to a vertical edge."); return false; - } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){ + } else if (anchor.item != readParentItem(item) && readParentItem(anchor.item) != readParentItem(item)){ qmlInfo(item) << QQuickAnchors::tr("Cannot anchor to an item that isn't a parent or sibling."); return false; } else if (anchor.item == item) { @@ -1291,7 +1339,7 @@ bool QQuickAnchorsPrivate::checkVAnchorValid(QQuickAnchorLine anchor) const } else if (anchor.anchorLine & QQuickAnchorLine::Horizontal_Mask) { qmlInfo(item) << QQuickAnchors::tr("Cannot anchor a vertical edge to a horizontal edge."); return false; - } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){ + } else if (anchor.item != readParentItem(item) && readParentItem(anchor.item) != readParentItem(item)){ qmlInfo(item) << QQuickAnchors::tr("Cannot anchor to an item that isn't a parent or sibling."); return false; } else if (anchor.item == item){ diff --git a/src/quick/items/qquickdrag.cpp b/src/quick/items/qquickdrag.cpp index 4aa54b71df..126737418a 100644 --- a/src/quick/items/qquickdrag.cpp +++ b/src/quick/items/qquickdrag.cpp @@ -311,7 +311,7 @@ void QQuickDragAttached::setActive(bool active) else if (d->dragType == QQuickDrag::Automatic) { // There are different semantics than start() since startDrag() // may be called after an internal drag is already started. - active = true; + d->active = true; emit activeChanged(); d->startDrag(d->supportedActions); } diff --git a/src/quick/items/qquickimagebase.cpp b/src/quick/items/qquickimagebase.cpp index 8117baa2fe..60e31631c0 100644 --- a/src/quick/items/qquickimagebase.cpp +++ b/src/quick/items/qquickimagebase.cpp @@ -225,7 +225,7 @@ void QQuickImageBase::load() // sourceSize is set. If sourceSize is not set then the provider default size // will be used, as usual. bool setDevicePixelRatio = false; - if (!d->sourcesize.isValid()) { + if (d->sourcesize.isValid()) { if (loadUrl.scheme() == QLatin1String("image")) { setDevicePixelRatio = true; } else { diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 6f8fc2e874..7a5f1a12e8 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -3111,7 +3111,6 @@ QQuickItemPrivate::QQuickItemPrivate() , flags(0) , widthValid(false) , heightValid(false) - , baselineOffsetValid(false) , componentComplete(true) , keepMouse(false) , keepTouch(false) @@ -3185,7 +3184,7 @@ void QQuickItemPrivate::init(QQuickItem *parent) registerAccessorProperties(); - baselineOffsetValid = false; + baselineOffset = 0.0; if (parent) { q->setParentItem(parent); @@ -4236,11 +4235,7 @@ QQuickAnchorLine QQuickItemPrivate::baseline() const qreal QQuickItem::baselineOffset() const { Q_D(const QQuickItem); - if (d->baselineOffsetValid) { - return d->baselineOffset; - } else { - return 0.0; - } + return d->baselineOffset; } void QQuickItem::setBaselineOffset(qreal offset) @@ -4250,7 +4245,6 @@ void QQuickItem::setBaselineOffset(qreal offset) return; d->baselineOffset = offset; - d->baselineOffsetValid = true; for (int ii = 0; ii < d->changeListeners.count(); ++ii) { const QQuickItemPrivate::ChangeListener &change = d->changeListeners.at(ii); @@ -6246,6 +6240,8 @@ QPointF QQuickItem::position() const void QQuickItem::setX(qreal v) { Q_D(QQuickItem); + if (qIsNaN(v)) + return; if (d->x == v) return; @@ -6261,6 +6257,8 @@ void QQuickItem::setX(qreal v) void QQuickItem::setY(qreal v) { Q_D(QQuickItem); + if (qIsNaN(v)) + return; if (d->y == v) return; diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h index 5a28b202fd..ad649e5b5f 100644 --- a/src/quick/items/qquickitem_p.h +++ b/src/quick/items/qquickitem_p.h @@ -402,7 +402,6 @@ public: quint32 flags:5; bool widthValid:1; bool heightValid:1; - bool baselineOffsetValid:1; bool componentComplete:1; bool keepMouse:1; bool keepTouch:1; @@ -411,8 +410,8 @@ public: bool antialiasing:1; bool focus:1; bool activeFocus:1; - // Bit 16 bool notifiedFocus:1; + // Bit 16 bool notifiedActiveFocus:1; bool filtersChildMouseEvents:1; bool explicitVisible:1; @@ -428,8 +427,8 @@ public: bool isAccessible:1; bool culled:1; bool hasCursor:1; - // Bit 32 bool hasCursorInChild:1; + // Bit 32 bool activeFocusOnTab:1; bool implicitAntialiasing:1; bool antialiasingValid:1; diff --git a/src/quick/items/qquickitemgrabresult.cpp b/src/quick/items/qquickitemgrabresult.cpp index 6822e4042c..d05ecc9076 100644 --- a/src/quick/items/qquickitemgrabresult.cpp +++ b/src/quick/items/qquickitemgrabresult.cpp @@ -58,6 +58,7 @@ class QQuickItemGrabResultPrivate : public QObjectPrivate public: QQuickItemGrabResultPrivate() : cacheEntry(0) + , qmlEngine(0) , texture(0) { } diff --git a/src/quick/items/qquickpainteditem.cpp b/src/quick/items/qquickpainteditem.cpp index 707214e8de..75919d0791 100644 --- a/src/quick/items/qquickpainteditem.cpp +++ b/src/quick/items/qquickpainteditem.cpp @@ -663,4 +663,11 @@ QSGTextureProvider *QQuickPaintedItem::textureProvider() const return d->textureProvider; } +void QQuickPaintedItem::itemChange(ItemChange change, const ItemChangeData &value) +{ + if (change == ItemDevicePixelRatioHasChanged) + update(); + QQuickItem::itemChange(change, value); +} + QT_END_NAMESPACE diff --git a/src/quick/items/qquickpainteditem.h b/src/quick/items/qquickpainteditem.h index f9e3c91a42..e8b471ac01 100644 --- a/src/quick/items/qquickpainteditem.h +++ b/src/quick/items/qquickpainteditem.h @@ -121,6 +121,7 @@ protected: QQuickPaintedItem(QQuickPaintedItemPrivate &dd, QQuickItem *parent = Q_NULLPTR); QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; void releaseResources() Q_DECL_OVERRIDE; + void itemChange(ItemChange, const ItemChangeData &) Q_DECL_OVERRIDE; private Q_SLOTS: void invalidateSceneGraph(); diff --git a/src/quick/items/qquickshadereffect.cpp b/src/quick/items/qquickshadereffect.cpp index 41b7ea3896..d5c0cc8180 100644 --- a/src/quick/items/qquickshadereffect.cpp +++ b/src/quick/items/qquickshadereffect.cpp @@ -1041,7 +1041,6 @@ QSGNode *QQuickShaderEffect::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDa builder.appendSourceFile(QStringLiteral(":/qt-project.org/items/shaders/shadereffect.vert")); s.sourceCode[Key::VertexShader] = builder.source(); } - s.className = metaObject()->className(); material->setProgramSource(s); material->attributes = m_common.attributes; diff --git a/src/quick/items/qquickshadereffectnode.cpp b/src/quick/items/qquickshadereffectnode.cpp index a06fe26a9c..246a713dca 100644 --- a/src/quick/items/qquickshadereffectnode.cpp +++ b/src/quick/items/qquickshadereffectnode.cpp @@ -333,8 +333,6 @@ const char *QQuickCustomMaterialShader::fragmentShader() const bool QQuickShaderEffectMaterialKey::operator == (const QQuickShaderEffectMaterialKey &other) const { - if (className != other.className) - return false; for (int shaderType = 0; shaderType < ShaderTypeCount; ++shaderType) { if (sourceCode[shaderType] != other.sourceCode[shaderType]) return false; @@ -349,7 +347,7 @@ bool QQuickShaderEffectMaterialKey::operator != (const QQuickShaderEffectMateria uint qHash(const QQuickShaderEffectMaterialKey &key) { - uint hash = qHash((const void *)key.className); + uint hash = 1; typedef QQuickShaderEffectMaterialKey Key; for (int shaderType = 0; shaderType < Key::ShaderTypeCount; ++shaderType) hash = hash * 31337 + qHash(key.sourceCode[shaderType]); diff --git a/src/quick/items/qquickshadereffectnode_p.h b/src/quick/items/qquickshadereffectnode_p.h index cc016d13a7..ff32f4e290 100644 --- a/src/quick/items/qquickshadereffectnode_p.h +++ b/src/quick/items/qquickshadereffectnode_p.h @@ -71,7 +71,6 @@ struct QQuickShaderEffectMaterialKey { }; QByteArray sourceCode[ShaderTypeCount]; - const char *className; bool operator == (const QQuickShaderEffectMaterialKey &other) const; bool operator != (const QQuickShaderEffectMaterialKey &other) const; diff --git a/src/quick/items/qquicktext_p.h b/src/quick/items/qquicktext_p.h index 0b35ad5f91..40dbd51f39 100644 --- a/src/quick/items/qquicktext_p.h +++ b/src/quick/items/qquicktext_p.h @@ -254,16 +254,16 @@ Q_SIGNALS: void fontChanged(const QFont &font); void colorChanged(); void linkColorChanged(); - void styleChanged(TextStyle style); + void styleChanged(QQuickText::TextStyle style); void styleColorChanged(); - void horizontalAlignmentChanged(HAlignment alignment); - void verticalAlignmentChanged(VAlignment alignment); + void horizontalAlignmentChanged(QQuickText::HAlignment alignment); + void verticalAlignmentChanged(QQuickText::VAlignment alignment); void wrapModeChanged(); void lineCountChanged(); void truncatedChanged(); void maximumLineCountChanged(); - void textFormatChanged(TextFormat textFormat); - void elideModeChanged(TextElideMode mode); + void textFormatChanged(QQuickText::TextFormat textFormat); + void elideModeChanged(QQuickText::TextElideMode mode); void contentSizeChanged(); void lineHeightChanged(qreal lineHeight); void lineHeightModeChanged(LineHeightMode mode); diff --git a/src/quick/items/qquicktextinput_p.h b/src/quick/items/qquicktextinput_p.h index 06ca1acb0d..211d9146fc 100644 --- a/src/quick/items/qquicktextinput_p.h +++ b/src/quick/items/qquicktextinput_p.h @@ -319,8 +319,8 @@ Q_SIGNALS: void selectionColorChanged(); void selectedTextColorChanged(); void fontChanged(const QFont &font); - void horizontalAlignmentChanged(HAlignment alignment); - void verticalAlignmentChanged(VAlignment alignment); + void horizontalAlignmentChanged(QQuickTextInput::HAlignment alignment); + void verticalAlignmentChanged(QQuickTextInput::VAlignment alignment); void wrapModeChanged(); void readOnlyChanged(bool isReadOnly); void cursorVisibleChanged(bool isCursorVisible); @@ -328,7 +328,7 @@ Q_SIGNALS: void maximumLengthChanged(int maximumLength); void validatorChanged(); void inputMaskChanged(const QString &inputMask); - void echoModeChanged(EchoMode echoMode); + void echoModeChanged(QQuickTextInput::EchoMode echoMode); void passwordCharacterChanged(); Q_REVISION(3) void passwordMaskDelayChanged(int delay); void displayTextChanged(); @@ -336,7 +336,7 @@ Q_SIGNALS: void activeFocusOnPressChanged(bool activeFocusOnPress); void autoScrollChanged(bool autoScroll); void selectByMouseChanged(bool selectByMouse); - void mouseSelectionModeChanged(SelectionMode mode); + void mouseSelectionModeChanged(QQuickTextInput::SelectionMode mode); void persistentSelectionChanged(); void canPasteChanged(); void canUndoChanged(); diff --git a/src/quick/scenegraph/util/qsgatlastexture.cpp b/src/quick/scenegraph/util/qsgatlastexture.cpp index 68dc813933..a93e7bbd30 100644 --- a/src/quick/scenegraph/util/qsgatlastexture.cpp +++ b/src/quick/scenegraph/util/qsgatlastexture.cpp @@ -127,6 +127,7 @@ Atlas::Atlas(const QSize &size) : m_allocator(size) , m_texture_id(0) , m_size(size) + , m_atlas_transient_image_threshold(0) , m_allocated(false) { @@ -176,6 +177,11 @@ Atlas::Atlas(const QSize &size) m_use_bgra_fallback = qEnvironmentVariableIsSet("QSG_ATLAS_USE_BGRA_FALLBACK"); m_debug_overlay = qEnvironmentVariableIsSet("QSG_ATLAS_OVERLAY"); + + // images smaller than this will retain their QImage. + // by default no images are retained (favoring memory) + // set to a very large value to retain all images (allowing quick removal from the atlas) + m_atlas_transient_image_threshold = qt_sg_envInt("QSG_ATLAS_TRANSIENT_IMAGE_THRESHOLD", 0); } Atlas::~Atlas() @@ -398,7 +404,10 @@ void Atlas::bind(QSGTexture::Filtering filtering) } else { upload(t); } - t->releaseImage(); + const QSize textureSize = t->textureSize(); + if (textureSize.width() > m_atlas_transient_image_threshold || + textureSize.height() > m_atlas_transient_image_threshold) + t->releaseImage(); qCDebug(QSG_LOG_TIME_TEXTURE).nospace() << "atlastexture uploaded in: " << qsg_renderer_timer.elapsed() << "ms (" << t->textureSize().width() << "x" diff --git a/src/quick/scenegraph/util/qsgatlastexture_p.h b/src/quick/scenegraph/util/qsgatlastexture_p.h index c6f1e72a4d..d6c0109c98 100644 --- a/src/quick/scenegraph/util/qsgatlastexture_p.h +++ b/src/quick/scenegraph/util/qsgatlastexture_p.h @@ -116,6 +116,8 @@ private: GLuint m_internalFormat; GLuint m_externalFormat; + int m_atlas_transient_image_threshold; + uint m_allocated : 1; uint m_use_bgra_fallback: 1; diff --git a/src/quick/util/qquickpath_p.h b/src/quick/util/qquickpath_p.h index d554e2156a..e2c99de44e 100644 --- a/src/quick/util/qquickpath_p.h +++ b/src/quick/util/qquickpath_p.h @@ -335,7 +335,7 @@ class Q_AUTOTEST_EXPORT QQuickPathPercent : public QQuickPathElement Q_OBJECT Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged) public: - QQuickPathPercent(QObject *parent=0) : QQuickPathElement(parent) {} + QQuickPathPercent(QObject *parent=0) : QQuickPathElement(parent), _value(0) {} qreal value() const; void setValue(qreal value); diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 253b050b15..8a8147ea6f 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -137,6 +137,7 @@ private slots: void functionDeclarationsInConditionals(); void arrayPop_QTBUG_35979(); + void array_unshift_QTBUG_52065(); void regexpLastMatch(); void indexedAccesses(); @@ -2994,6 +2995,20 @@ void tst_QJSEngine::arrayPop_QTBUG_35979() QCOMPARE(result.toString(), QString("1,3")); } +void tst_QJSEngine::array_unshift_QTBUG_52065() +{ + QJSEngine eng; + QJSValue result = eng.evaluate("[1, 2, 3, 4, 5, 6, 7, 8, 9]"); + QJSValue unshift = result.property(QStringLiteral("unshift")); + unshift.callWithInstance(result, QJSValueList() << QJSValue(0)); + + int len = result.property(QStringLiteral("length")).toInt(); + QCOMPARE(len, 10); + + for (int i = 0; i < len; ++i) + QCOMPARE(result.property(i).toInt(), i); +} + void tst_QJSEngine::regexpLastMatch() { QJSEngine eng; diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro index 5e798f3b48..28f04be5d7 100644 --- a/tests/auto/qml/qml.pro +++ b/tests/auto/qml/qml.pro @@ -69,7 +69,8 @@ qtHaveModule(widgets) { qjsvalue } -SUBDIRS += $$PUBLICTESTS +SUBDIRS += $$PUBLICTESTS \ + qqmlextensionplugin SUBDIRS += $$METATYPETESTS !winrt { # no QProcess on winrt !contains(QT_CONFIG, no-qml-debug): SUBDIRS += debugger diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h index e0d75e7baa..d4d051443f 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.h +++ b/tests/auto/qml/qqmlecmascript/testtypes.h @@ -790,6 +790,8 @@ public: Q_INVOKABLE void method_QObject(QObject *a) { invoke(13); m_actuals << qVariantFromValue(a); } Q_INVOKABLE void method_QScriptValue(QJSValue a) { invoke(14); m_actuals << qVariantFromValue(a); } Q_INVOKABLE void method_intQScriptValue(int a, QJSValue b) { invoke(15); m_actuals << a << qVariantFromValue(b); } + Q_INVOKABLE QJSValue method_intQJSValue(int a, QJSValue b) { invoke(29); m_actuals << a << qVariantFromValue(b); return b.call(); } + Q_INVOKABLE QJSValue method_intQJSValue(int a, int b) { m_actuals << a << b; return QJSValue();} // Should never be called. Q_INVOKABLE void method_overload(int a) { invoke(16); m_actuals << a; } Q_INVOKABLE void method_overload(int a, int b) { invoke(17); m_actuals << a << b; } diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 5ca760020c..9b17f70a91 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -2937,6 +2937,18 @@ void tst_qqmlecmascript::callQtInvokables() QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), -1); QCOMPARE(o->actuals().count(), 0); + + o->reset(); + QV4::ScopedValue ret(scope, EVALUATE("object.method_intQJSValue(123, function() { return \"Hello world!\";})")); + QCOMPARE(o->error(), false); + QCOMPARE(o->invoked(), 29); + QVERIFY(ret->isString()); + QCOMPARE(ret->toQStringNoThrow(), QString("Hello world!")); + QCOMPARE(o->actuals().count(), 2); + QCOMPARE(o->actuals().at(0), QVariant(123)); + QJSValue callback = qvariant_cast<QJSValue>(o->actuals().at(1)); + QVERIFY(!callback.isNull()); + QVERIFY(callback.isCallable()); } // QTBUG-13047 (check that you can pass registered object types as args) diff --git a/tests/auto/qml/qqmlextensionplugin/qqmlextensionplugin.pro b/tests/auto/qml/qqmlextensionplugin/qqmlextensionplugin.pro new file mode 100644 index 0000000000..af74707c4a --- /dev/null +++ b/tests/auto/qml/qqmlextensionplugin/qqmlextensionplugin.pro @@ -0,0 +1,5 @@ +CONFIG += testcase +TARGET = tst_qqmlextensionplugin +SOURCES += tst_qqmlextensionplugin.cpp +osx:CONFIG -= app_bundle +QT += qml testlib diff --git a/tests/auto/qml/qqmlextensionplugin/tst_qqmlextensionplugin.cpp b/tests/auto/qml/qqmlextensionplugin/tst_qqmlextensionplugin.cpp new file mode 100644 index 0000000000..ab5e958323 --- /dev/null +++ b/tests/auto/qml/qqmlextensionplugin/tst_qqmlextensionplugin.cpp @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore> +#include <QtTest> +#include <QtQml> + +#if defined(Q_OS_WIN) +# define SUFFIX QLatin1String(".dll") +# define DEBUG_SUFFIX QLatin1String("d.dll") + +#elif defined(Q_OS_DARWIN) +# define SUFFIX QLatin1String(".dylib") +# define DEBUG_SUFFIX QLatin1String("_debug.dylib") + +# else // Unix +# define SUFFIX QLatin1String(".so") +#endif + + +class tst_qqmlextensionplugin : public QObject +{ + Q_OBJECT + + bool isDuplicate(QString file, const QList<QString> & files) { +#ifndef DEBUG_SUFFIX + Q_UNUSED(file) + Q_UNUSED(files) + return false; +#else +# ifdef QT_DEBUG + return !file.endsWith(DEBUG_SUFFIX) && files.contains(file.replace(SUFFIX, DEBUG_SUFFIX)); +# else + return file.endsWith(DEBUG_SUFFIX) && files.contains(file.replace(DEBUG_SUFFIX, SUFFIX)); +# endif +#endif + } + +public: + tst_qqmlextensionplugin() {} + +private Q_SLOTS: + void iidCheck_data(); + void iidCheck(); +}; + + +void tst_qqmlextensionplugin::iidCheck_data() +{ + QList<QString> files; + for (QDirIterator it(QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath), QDirIterator::Subdirectories); it.hasNext(); ) { + QString file = it.next(); + if (file.endsWith(SUFFIX)) { + files << file; + } + } + + for (QMutableListIterator<QString> it(files); it.hasNext(); ) { + QString file = it.next(); + if (isDuplicate(file, files)) { + it.remove(); + } + } + + QTest::addColumn<QString>("filePath"); + foreach (const QString &file, files) { + QFileInfo fileInfo(file); + QTest::newRow(fileInfo.baseName().toLatin1().data()) << fileInfo.absoluteFilePath(); + } +} + + +void tst_qqmlextensionplugin::iidCheck() +{ + QFETCH(QString, filePath); + + QPluginLoader loader(filePath); + QVERIFY(loader.load()); + QVERIFY(loader.instance() != Q_NULLPTR); + + if (qobject_cast<QQmlExtensionPlugin *>(loader.instance())) { + QString iid = loader.metaData().value(QStringLiteral("IID")).toString(); + QCOMPARE(iid, QLatin1String(QQmlExtensionInterface_iid)); + } +} + + +QTEST_APPLESS_MAIN(tst_qqmlextensionplugin) +#include "tst_qqmlextensionplugin.moc" diff --git a/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/plugin.cpp index 82c3c926fd..fa9782f8c2 100644 --- a/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/plugin.cpp @@ -41,7 +41,7 @@ public: class MyPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: MyPlugin() {} diff --git a/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/plugin.cpp index bb2a344811..fe01507412 100644 --- a/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/invalidNamespaceModule/plugin.cpp @@ -41,7 +41,7 @@ public: class MyPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: MyPlugin() {} diff --git a/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/plugin.cpp index bb2a344811..fe01507412 100644 --- a/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/invalidStrictModule/plugin.cpp @@ -41,7 +41,7 @@ public: class MyPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: MyPlugin() {} diff --git a/tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.cpp b/tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.cpp index 4ca5eb5402..92d30351a7 100644 --- a/tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.cpp @@ -56,7 +56,7 @@ public: class MyPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: MyPlugin() {} diff --git a/tests/auto/qml/qqmlmoduleplugin/nonstrictModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/nonstrictModule/plugin.cpp index f48ab16b03..5fc05b91bd 100644 --- a/tests/auto/qml/qqmlmoduleplugin/nonstrictModule/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/nonstrictModule/plugin.cpp @@ -41,7 +41,7 @@ public: class MyPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: MyPlugin() {} diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp index 2dc771fad1..6cae5254bc 100644 --- a/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp @@ -53,7 +53,7 @@ private: class MyPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: MyPlugin() diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp index 4b25181a86..49a2a747a4 100644 --- a/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp @@ -53,7 +53,7 @@ private: class MyPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: MyPlugin() diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp index 7147769406..db51185de6 100644 --- a/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp @@ -52,7 +52,7 @@ private: class MyPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: MyPlugin() diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp index 8ae091bc0f..e780d4a7fd 100644 --- a/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp @@ -43,7 +43,7 @@ public: class MyMixedPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: MyMixedPlugin() diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp index 4be0ad4c66..470da6c35f 100644 --- a/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp @@ -43,7 +43,7 @@ public: class MyMixedPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: MyMixedPlugin() diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp index 2c1047450a..60a0a4a3e2 100644 --- a/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp @@ -33,7 +33,7 @@ class MyPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: void registerTypes(const char *uri) diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp index 4eb875be43..7669d65568 100644 --- a/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp @@ -52,7 +52,7 @@ private: class MyPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: MyPlugin() diff --git a/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/plugin.cpp index bace4644b3..92211ebf9d 100644 --- a/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/preemptedStrictModule/plugin.cpp @@ -41,7 +41,7 @@ public: class MyPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: MyPlugin() {} diff --git a/tests/auto/qml/qqmlmoduleplugin/preemptiveModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/preemptiveModule/plugin.cpp index a98398ac94..3df3e9cc81 100644 --- a/tests/auto/qml/qqmlmoduleplugin/preemptiveModule/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/preemptiveModule/plugin.cpp @@ -41,7 +41,7 @@ public: class MyPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: MyPlugin() {} diff --git a/tests/auto/qml/qqmlmoduleplugin/protectedModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/protectedModule/plugin.cpp index df85d4a327..afdeea80f4 100644 --- a/tests/auto/qml/qqmlmoduleplugin/protectedModule/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/protectedModule/plugin.cpp @@ -40,7 +40,7 @@ public: class MyPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: MyPlugin() {} diff --git a/tests/auto/qml/qqmlmoduleplugin/strictModule.2/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/strictModule.2/plugin.cpp index 1e86c0da49..4f5176ae62 100644 --- a/tests/auto/qml/qqmlmoduleplugin/strictModule.2/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/strictModule.2/plugin.cpp @@ -41,7 +41,7 @@ public: class MyPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: MyPlugin() {} diff --git a/tests/auto/qml/qqmlmoduleplugin/strictModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/strictModule/plugin.cpp index ad53ac95f3..eaa9aeb1d0 100644 --- a/tests/auto/qml/qqmlmoduleplugin/strictModule/plugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/strictModule/plugin.cpp @@ -41,7 +41,7 @@ public: class MyPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: MyPlugin() {} diff --git a/tests/auto/qml/qqmltypeloader/SlowImport/plugin.h b/tests/auto/qml/qqmltypeloader/SlowImport/plugin.h index d3a3b81832..34b3920a38 100644 --- a/tests/auto/qml/qqmltypeloader/SlowImport/plugin.h +++ b/tests/auto/qml/qqmltypeloader/SlowImport/plugin.h @@ -35,7 +35,7 @@ class SlowPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: void registerTypes(const char *uri); diff --git a/tests/auto/qml/qqmltypeloader/data/trim_cache.qml b/tests/auto/qml/qqmltypeloader/data/trim_cache.qml new file mode 100644 index 0000000000..74303977dd --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/trim_cache.qml @@ -0,0 +1,8 @@ +import QtQuick 2.2 +Rectangle +{ + objectName: "dings" + width: 100 + height: 100 + color: "blue" +} diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp index 24358897f7..ef1ea3a897 100644 --- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp +++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp @@ -30,6 +30,9 @@ #include <QtQml/qqmlengine.h> #include <QtQuick/qquickview.h> #include <QtQuick/qquickitem.h> +#include <QtQml/private/qqmlengine_p.h> +#include <QtQml/private/qqmltypeloader_p.h> +#include <QtQml/private/qqmlcompiler_p.h> #include "../../shared/util.h" class tst_QQMLTypeLoader : public QQmlDataTest @@ -39,6 +42,7 @@ class tst_QQMLTypeLoader : public QQmlDataTest private slots: void testLoadComplete(); void loadComponentSynchronously(); + void trimCache(); }; void tst_QQMLTypeLoader::testLoadComplete() @@ -68,6 +72,32 @@ void tst_QQMLTypeLoader::loadComponentSynchronously() QVERIFY(o); } +void tst_QQMLTypeLoader::trimCache() +{ + QQmlEngine engine; + QQmlTypeLoader &loader = QQmlEnginePrivate::get(&engine)->typeLoader; + for (int i = 0; i < 256; ++i) { + QUrl url = testFileUrl("trim_cache.qml"); + url.setQuery(QString::number(i)); + + QQmlTypeData *data = loader.getType(url); + if (i % 5 == 0) // keep references to some of them so that they aren't trimmed + data->compiledData()->addref(); + + data->release(); + } + + for (int i = 0; i < 256; ++i) { + QUrl url = testFileUrl("trim_cache.qml"); + url.setQuery(QString::number(i)); + if (i % 5 == 0) + QVERIFY(loader.isTypeLoaded(url)); + else if (i < 128) + QVERIFY(!loader.isTypeLoaded(url)); + // The cache is free to keep the others. + } +} + QTEST_MAIN(tst_QQMLTypeLoader) #include "tst_qqmltypeloader.moc" diff --git a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp index b0f0f886a0..61413a73c1 100644 --- a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp +++ b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp @@ -205,16 +205,12 @@ void tst_qquickanimatedimage::mirror_notRunning() int frame = anim->currentFrame(); bool playing = anim->isPlaying(); - bool paused = anim->isPlaying(); + bool paused = anim->isPaused(); anim->setProperty("mirror", true); screenshot = window.grabWindow(); screenshot.save("screen.png"); -#if defined(Q_OS_WIN) - // QTBUG-36717 - QSKIP("This test is failing in the CI system under mysterious circumstances"); -#endif QCOMPARE(screenshot, expected); // mirroring should not change the current frame or playing status diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index 0a79fe8de3..2df70d89ff 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -699,7 +699,7 @@ void tst_qquicktext::textFormat() QQuickText *text = qobject_cast<QQuickText *>(object.data()); QVERIFY(text); - QSignalSpy spy(text, SIGNAL(textFormatChanged(TextFormat))); + QSignalSpy spy(text, &QQuickText::textFormatChanged); QCOMPARE(text->textFormat(), QQuickText::AutoText); diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index 3b4e57b2a8..f19a5ea167 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -1347,7 +1347,7 @@ void tst_qquicktextinput::mouseSelectionMode_accessors() QQuickTextInput *input = qobject_cast<QQuickTextInput *>(object.data()); QVERIFY(input); - QSignalSpy spy(input, SIGNAL(mouseSelectionModeChanged(SelectionMode))); + QSignalSpy spy(input, &QQuickTextInput::mouseSelectionModeChanged); QCOMPARE(input->mouseSelectionMode(), QQuickTextInput::SelectCharacters); diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro index 13bd6d78e2..2e43702e7c 100644 --- a/tests/auto/quick/quick.pro +++ b/tests/auto/quick/quick.pro @@ -75,6 +75,7 @@ QUICKTESTS = \ qquickvisualdatamodel \ qquickview \ qquickcanvasitem \ + qquickdesignersupport \ qquickscreen \ touchmouse \ scenegraph diff --git a/tests/benchmarks/qml/creation/tst_creation.cpp b/tests/benchmarks/qml/creation/tst_creation.cpp index 224732913c..e126cdae7e 100644 --- a/tests/benchmarks/qml/creation/tst_creation.cpp +++ b/tests/benchmarks/qml/creation/tst_creation.cpp @@ -68,6 +68,8 @@ private slots: void itemtests_qml_data(); void itemtests_qml(); + void anchors_heightChange(); + private: QQmlEngine engine; }; @@ -373,6 +375,24 @@ void tst_creation::itemtests_qml() QBENCHMARK { delete component.create(); } } +void tst_creation::anchors_heightChange() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\nItem { Item { anchors.bottom: parent.bottom } }", QUrl()); + + QObject *obj = component.create(); + auto item = qobject_cast<QQuickItem *>(obj); + Q_ASSERT(item); + int height = 1; + + QBENCHMARK { + item->setHeight(height); + height += 1; + } + + delete obj; +} + QTEST_MAIN(tst_creation) #include "tst_creation.moc" diff --git a/tests/manual/highdpi/imageprovider.cpp b/tests/manual/highdpi/imageprovider.cpp index 1856a1ea9a..33a69cb87e 100644 --- a/tests/manual/highdpi/imageprovider.cpp +++ b/tests/manual/highdpi/imageprovider.cpp @@ -79,7 +79,7 @@ public: class ImageProviderExtensionPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: void registerTypes(const char *uri) { @@ -95,7 +95,4 @@ public: }; -#define QQmlExtensionInterface_iid "org.qt-project.Qt.QQmlExtensionInterface" - - #include "imageprovider.moc" diff --git a/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy_plugin.h b/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy_plugin.h index 739eae0f8a..86e80e6a08 100644 --- a/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy_plugin.h +++ b/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy_plugin.h @@ -34,7 +34,7 @@ class DummyPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: void registerTypes(const char *uri); diff --git a/tests/manual/qmlplugindump/tests/dumper/Imports/imports_plugin.h b/tests/manual/qmlplugindump/tests/dumper/Imports/imports_plugin.h index 7c136dea30..fd09584d47 100644 --- a/tests/manual/qmlplugindump/tests/dumper/Imports/imports_plugin.h +++ b/tests/manual/qmlplugindump/tests/dumper/Imports/imports_plugin.h @@ -34,7 +34,7 @@ class ImportsPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: void registerTypes(const char *uri); diff --git a/tests/manual/qmlplugindump/tests/dumper/Versions/versions_plugin.h b/tests/manual/qmlplugindump/tests/dumper/Versions/versions_plugin.h index 91e9ce4174..4ba68a8125 100644 --- a/tests/manual/qmlplugindump/tests/dumper/Versions/versions_plugin.h +++ b/tests/manual/qmlplugindump/tests/dumper/Versions/versions_plugin.h @@ -34,7 +34,7 @@ class VersionsPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: void registerTypes(const char *uri); diff --git a/tests/manual/qmltypememory/TestPlugin/plugin.cpp b/tests/manual/qmltypememory/TestPlugin/plugin.cpp index ddc5430b43..d6cbf05a55 100644 --- a/tests/manual/qmltypememory/TestPlugin/plugin.cpp +++ b/tests/manual/qmltypememory/TestPlugin/plugin.cpp @@ -50,7 +50,7 @@ class TestType : public QObject class TestPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: void registerTypes(const char *uri) diff --git a/tests/manual/scenegraph_lancelot/data/text/textedit_multiline_selected_linebreaks_and_linewraps2.qml b/tests/manual/scenegraph_lancelot/data/text/textedit_multiline_selected_linebreaks_and_linewraps2.qml new file mode 100644 index 0000000000..c16bc9cdf7 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/textedit_multiline_selected_linebreaks_and_linewraps2.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 + +Item { + width: 550 + height: 480 + + TextEdit { + id: textEdit + anchors.centerIn: parent + width: 550 + textFormat: TextEdit.RichText + text: "A<br /> + This is a long message to demenostrate a text selection issue. I need to type some more text here. This is line 3<br /> + This is a long message to demenostrate a text selection issue. I need to type some more text here. This is line 4" + wrapMode: TextEdit.Wrap + + Component.onCompleted: { + textEdit.selectAll() + } + } + +} |