aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-04-27 08:47:35 +0200
committerLiang Qi <liang.qi@qt.io>2016-04-27 08:47:35 +0200
commitda374438be8f34f746f359aa39ae6c59fd1c4854 (patch)
tree2f3e2a2b93b39dfb825339c98580f23e824fad0e /src/qml
parent1be53f4e143d417d60cd1f9a292193dab59b5b20 (diff)
parent2e6f7f362e62c3285e7d395aca607502c8e8160e (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: src/quick/items/qquickimagebase.cpp src/imports/layouts/plugin.cpp Change-Id: I5f48474df4034a1347ec74795c85d369a55b6b21
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/doc/src/cppintegration/extending-tutorial.qdoc26
-rw-r--r--src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc2
-rw-r--r--src/qml/jsruntime/qv4arraydata.cpp8
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp2
-rw-r--r--src/qml/qml/qqmlimport.cpp4
-rw-r--r--src/qml/qml/qqmltypeloader.cpp20
-rw-r--r--src/qml/qml/qqmltypeloader_p.h2
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp4
8 files changed, 55 insertions, 13 deletions
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))));
}
}