diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2017-09-08 11:04:30 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2017-09-08 11:04:30 +0200 |
commit | bde8c3cd9583ed9f3bdfc36a8699f56db20a6928 (patch) | |
tree | 33246b027739aafd72f9f289876f69627537f2b3 /src/qml | |
parent | b63bc868875d7571bc332804f984824cff7c5b78 (diff) | |
parent | 685ad676a84bf48602a5da8f7171792686b94a73 (diff) |
Merge remote-tracking branch 'origin/dev' into wip/new-backend
Conflicts:
src/qml/compiler/qv4isel_moth.cpp
src/qml/compiler/qv4jsir.cpp
src/qml/jsruntime/qv4mathobject.cpp
Change-Id: I426f1f4f0a5302b5bcff021de11766a03fec7637
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/compiler/qv4compileddata.cpp | 15 | ||||
-rw-r--r-- | src/qml/compiler/qv4compileddata_p.h | 3 | ||||
-rw-r--r-- | src/qml/doc/src/cppintegration/data.qdoc | 2 | ||||
-rw-r--r-- | src/qml/doc/src/cppintegration/definetypes.qdoc | 3 | ||||
-rw-r--r-- | src/qml/doc/src/qmllanguageref/documents/topic.qdoc | 2 | ||||
-rw-r--r-- | src/qml/doc/src/qmllanguageref/typesystem/objecttypes.qdoc | 2 | ||||
-rw-r--r-- | src/qml/doc/src/statemachine.qdoc | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4mathobject.cpp | 16 | ||||
-rw-r--r-- | src/qml/qml/qqmlcontext.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlcontext_p.h | 5 | ||||
-rw-r--r-- | src/qml/qml/qqmlengine_p.h | 6 | ||||
-rw-r--r-- | src/qml/qml/qqmlincubator.cpp | 11 | ||||
-rw-r--r-- | src/qml/qml/qqmlobjectcreator.cpp | 9 | ||||
-rw-r--r-- | src/qml/qml/qqmlobjectcreator_p.h | 5 | ||||
-rw-r--r-- | src/qml/qml/qqmlproperty.cpp | 5 | ||||
-rw-r--r-- | src/qml/qml/qqmltypeloader.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlvmemetaobject.cpp | 3 | ||||
-rw-r--r-- | src/qml/types/qqmlbind.cpp | 4 |
18 files changed, 45 insertions, 52 deletions
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp index 58588e4ad5..890f4c47de 100644 --- a/src/qml/compiler/qv4compileddata.cpp +++ b/src/qml/compiler/qv4compileddata.cpp @@ -97,6 +97,7 @@ static QString cacheFilePath(const QUrl &url) CompilationUnit::CompilationUnit() : data(0) , engine(0) + , qmlEngine(0) , runtimeLookups(0) , runtimeRegularExpressions(0) , runtimeClasses(0) @@ -213,8 +214,8 @@ void CompilationUnit::unlink() if (isRegisteredWithEngine) { Q_ASSERT(data && quint32(propertyCaches.count()) > data->indexOfRootObject && propertyCaches.at(data->indexOfRootObject)); - if (engine) - QQmlEnginePrivate::get(engine)->unregisterInternalCompositeType(this); + if (qmlEngine) + qmlEngine->unregisterInternalCompositeType(this); QQmlMetaType::unregisterInternalCompositeType(this); isRegisteredWithEngine = false; } @@ -231,6 +232,7 @@ void CompilationUnit::unlink() resolvedTypes.clear(); engine = 0; + qmlEngine = 0; free(runtimeStrings); runtimeStrings = 0; delete [] runtimeLookups; @@ -260,9 +262,6 @@ void CompilationUnit::markObjects(QV4::MarkStack *markStack) void CompilationUnit::destroy() { - QQmlEngine *qmlEngine = 0; - if (engine && engine->v8Engine) - qmlEngine = engine->v8Engine->engine(); if (qmlEngine) QQmlEnginePrivate::deleteInEngineThread(qmlEngine, this); else @@ -285,12 +284,14 @@ IdentifierHash<int> CompilationUnit::namedObjectsPerComponent(int componentObjec return *it; } -void CompilationUnit::finalize(QQmlEnginePrivate *engine) +void CompilationUnit::finalizeCompositeType(QQmlEnginePrivate *qmlEngine) { + this->qmlEngine = qmlEngine; + // Add to type registry of composites if (propertyCaches.needsVMEMetaObject(data->indexOfRootObject)) { QQmlMetaType::registerInternalCompositeType(this); - engine->registerInternalCompositeType(this); + qmlEngine->registerInternalCompositeType(this); } else { const QV4::CompiledData::Object *obj = objectAt(data->indexOfRootObject); auto *typeRef = resolvedTypes.value(obj->inheritedTypeNameIndex); diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 79476dbe5e..e2cdc3d8fc 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -879,6 +879,7 @@ struct Q_QML_PRIVATE_EXPORT CompilationUnit : public CompilationUnitBase, public #ifndef V4_BOOTSTRAP ExecutionEngine *engine; + QQmlEnginePrivate *qmlEngine; // only used in QML environment for composite types, not in plain QJSEngine case. QString fileName() const { return data->stringAt(data->sourceFileIndex); } QUrl url() const { if (m_url.isNull) m_url = QUrl(fileName()); return m_url; } @@ -908,7 +909,7 @@ struct Q_QML_PRIVATE_EXPORT CompilationUnit : public CompilationUnitBase, public // pointers either to data->constants() or little-endian memory copy. const Value* constants; - void finalize(QQmlEnginePrivate *engine); + void finalizeCompositeType(QQmlEnginePrivate *qmlEngine); int totalBindingsCount; // Number of bindings used in this type int totalParserStatusCount; // Number of instantiated types that are QQmlParserStatus subclasses diff --git a/src/qml/doc/src/cppintegration/data.qdoc b/src/qml/doc/src/cppintegration/data.qdoc index c3d073872a..65559f640a 100644 --- a/src/qml/doc/src/cppintegration/data.qdoc +++ b/src/qml/doc/src/cppintegration/data.qdoc @@ -347,7 +347,7 @@ them with default constructed values, do not use the indexed delete operator ("delete sequence[i]") but instead use the \c {splice} function ("sequence.splice(startIndex, deleteCount)"). -\section2 Value types +\section2 Value Types Some value types in Qt such as QPoint are represented in JavaScript as objects that have the same properties and functions like in the C++ API. The same diff --git a/src/qml/doc/src/cppintegration/definetypes.qdoc b/src/qml/doc/src/cppintegration/definetypes.qdoc index 1ce00c6ad0..91f916c699 100644 --- a/src/qml/doc/src/cppintegration/definetypes.qdoc +++ b/src/qml/doc/src/cppintegration/definetypes.qdoc @@ -606,7 +606,6 @@ public: RandomNumberGenerator(QObject *parent) : QObject(parent), m_maxValue(100) { - qsrand(QDateTime::currentMSecsSinceEpoch() / 1000); QObject::connect(&m_timer, SIGNAL(timeout()), SLOT(updateProperty())); m_timer.start(500); } @@ -621,7 +620,7 @@ signals: private slots: void updateProperty() { - m_targetProperty.write(qrand() % m_maxValue); + m_targetProperty.write(QRandomGenerator::bounded(m_maxValue)); } private: diff --git a/src/qml/doc/src/qmllanguageref/documents/topic.qdoc b/src/qml/doc/src/qmllanguageref/documents/topic.qdoc index 840afa9a0e..bc104e9c8a 100644 --- a/src/qml/doc/src/qmllanguageref/documents/topic.qdoc +++ b/src/qml/doc/src/qmllanguageref/documents/topic.qdoc @@ -86,7 +86,7 @@ Please see the documentation about the \l{qtqml-syntax-basics.html} documentation about \l{qtqml-javascript-topic.html} {integrating QML and JavaScript} for in-depth information on that topic. -\section1 Defining Object Types through QML Documents +\section1 Defining Object Types Through QML Documents As described briefly in the previous section, a document implicitly defines a QML object type. One of the core principles of QML is the ability to define diff --git a/src/qml/doc/src/qmllanguageref/typesystem/objecttypes.qdoc b/src/qml/doc/src/qmllanguageref/typesystem/objecttypes.qdoc index b0aab1c73a..d1d28381b5 100644 --- a/src/qml/doc/src/qmllanguageref/typesystem/objecttypes.qdoc +++ b/src/qml/doc/src/qmllanguageref/typesystem/objecttypes.qdoc @@ -50,7 +50,7 @@ and registering the type with the QML engine, as discussed in \section1 Defining Object Types from QML -\section2 Defining Object Types through QML Documents +\section2 Defining Object Types Through QML Documents Plugin writers and application developers may provide types defined as QML documents. A QML document, when visible to the QML import system, defines a diff --git a/src/qml/doc/src/statemachine.qdoc b/src/qml/doc/src/statemachine.qdoc index 56a8746e1e..b0bfef4f69 100644 --- a/src/qml/doc/src/statemachine.qdoc +++ b/src/qml/doc/src/statemachine.qdoc @@ -61,7 +61,7 @@ \annotatedlist statemachine-qmltypes - \section1 Using both QtQuick and QtQml.StateMachine imports + \section1 Using Both QtQuick and QtQml.StateMachine Imports \warning If you're attempting to import both \l{QtQuick} and \e{QtQml.StateMachine} in one single QML file, make sure to import diff --git a/src/qml/jsruntime/qv4mathobject.cpp b/src/qml/jsruntime/qv4mathobject.cpp index 2c1fefe9f8..cdf5c3117c 100644 --- a/src/qml/jsruntime/qv4mathobject.cpp +++ b/src/qml/jsruntime/qv4mathobject.cpp @@ -42,6 +42,7 @@ #include <QtCore/qdatetime.h> #include <QtCore/qmath.h> +#include <QtCore/qrandom.h> #include <QtCore/private/qnumeric_p.h> #include <QtCore/qthreadstorage.h> @@ -273,20 +274,9 @@ ReturnedValue MathObject::method_pow(const BuiltinFunction *, CallData *callData RETURN_RESULT(Encode(qt_qnan())); } -Q_GLOBAL_STATIC(QThreadStorage<bool *>, seedCreatedStorage); - -ReturnedValue MathObject::method_random(const BuiltinFunction *b, CallData *) +ReturnedValue MathObject::method_random(const BuiltinFunction *, CallData *) { - if (!seedCreatedStorage()->hasLocalData()) { - int msecs = QTime(0,0,0).msecsTo(QTime::currentTime()); - Q_ASSERT(msecs >= 0); - qsrand(uint(uint(msecs) ^ reinterpret_cast<quintptr>(b))); - seedCreatedStorage()->setLocalData(new bool(true)); - } - // rand()/qrand() return a value where the upperbound is RAND_MAX inclusive. So, instead of - // dividing by RAND_MAX (which would return 0..RAND_MAX inclusive), we divide by RAND_MAX + 1. - qint64 upperLimit = qint64(RAND_MAX) + 1; - RETURN_RESULT(Encode(qrand() / double(upperLimit))); + RETURN_RESULT(Encode(QRandomGenerator::getReal())); } ReturnedValue MathObject::method_round(const BuiltinFunction *, CallData *callData) diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp index 1476c276f4..531d9ae457 100644 --- a/src/qml/qml/qqmlcontext.cpp +++ b/src/qml/qml/qqmlcontext.cpp @@ -523,7 +523,7 @@ QQmlContextData::QQmlContextData() QQmlContextData::QQmlContextData(QQmlContext *ctxt) : parent(0), engine(0), isInternal(false), ownedByParent(false), isJSContext(false), isPragmaLibraryContext(false), unresolvedNames(false), hasEmittedDestruction(false), isRootObjectInCreation(false), - publicContext(ctxt), activeVMEData(0), componentObjectIndex(-1), + publicContext(ctxt), incubator(0), componentObjectIndex(-1), contextObject(0), childContexts(0), nextChild(0), prevChild(0), expressions(0), contextObjects(0), contextGuards(0), idValues(0), idValueCount(0), linkedContext(0), componentAttached(0) diff --git a/src/qml/qml/qqmlcontext_p.h b/src/qml/qml/qqmlcontext_p.h index 4d2bb72352..a259fd62d8 100644 --- a/src/qml/qml/qqmlcontext_p.h +++ b/src/qml/qml/qqmlcontext_p.h @@ -78,6 +78,7 @@ class QQmlExpression; class QQmlExpressionPrivate; class QQmlJavaScriptExpression; class QQmlContextData; +class QQmlIncubatorPrivate; class QQmlContextPrivate : public QObjectPrivate { @@ -145,8 +146,8 @@ public: quint32 dummy:25; QQmlContext *publicContext; - // VME data that is constructing this context if any - void *activeVMEData; + // The incubator that is constructing this context if any + QQmlIncubatorPrivate *incubator; // Compilation unit for contexts that belong to a compiled type. QQmlRefPointer<QV4::CompiledData::CompilationUnit> typeCompilationUnit; diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h index da8ea24ea0..fd74a233a4 100644 --- a/src/qml/qml/qqmlengine_p.h +++ b/src/qml/qml/qqmlengine_p.h @@ -204,7 +204,7 @@ public: template<typename T> inline void deleteInEngineThread(T *); template<typename T> - inline static void deleteInEngineThread(QQmlEngine *, T *); + inline static void deleteInEngineThread(QQmlEnginePrivate *, T *); QString offlineStorageDatabaseDirectory() const; // These methods may be called from the loader thread @@ -359,10 +359,10 @@ Delete \a value in the \a engine thread. If the calling thread is the engine thread, \a value will be deleted immediately. */ template<typename T> -void QQmlEnginePrivate::deleteInEngineThread(QQmlEngine *engine, T *value) +void QQmlEnginePrivate::deleteInEngineThread(QQmlEnginePrivate *engine, T *value) { Q_ASSERT(engine); - QQmlEnginePrivate::get(engine)->deleteInEngineThread<T>(value); + engine->deleteInEngineThread<T>(value); } /*! diff --git a/src/qml/qml/qqmlincubator.cpp b/src/qml/qml/qqmlincubator.cpp index 54d0b240f5..6d0e4b915a 100644 --- a/src/qml/qml/qqmlincubator.cpp +++ b/src/qml/qml/qqmlincubator.cpp @@ -45,9 +45,6 @@ #include "qqmlmemoryprofiler_p.h" #include "qqmlobjectcreator_p.h" -// XXX TODO -// - check that the Component.onCompleted behavior is the same as 4.8 in the synchronous and -// async if nested cases void QQmlEnginePrivate::incubate(QQmlIncubator &i, QQmlContextData *forContext) { QExplicitlySharedDataPointer<QQmlIncubatorPrivate> p(i.d); @@ -64,8 +61,8 @@ void QQmlEnginePrivate::incubate(QQmlIncubator &i, QQmlContextData *forContext) QExplicitlySharedDataPointer<QQmlIncubatorPrivate> parentIncubator; QQmlContextData *cctxt = forContext; while (cctxt) { - if (cctxt->activeVMEData) { - parentIncubator = (QQmlIncubatorPrivate *)cctxt->activeVMEData; + if (cctxt->incubator) { + parentIncubator = cctxt->incubator; break; } cctxt = cctxt->parent; @@ -152,7 +149,7 @@ void QQmlIncubatorPrivate::clear() } enginePriv = 0; if (!rootContext.isNull()) { - rootContext->activeVMEData = 0; + rootContext->incubator = 0; rootContext = 0; } @@ -388,7 +385,7 @@ void QQmlIncubatorPrivate::cancel(QObject *object, QQmlContext *context) return; QQmlContextData *data = QQmlContextData::get(context); - QQmlIncubatorPrivate *p = (QQmlIncubatorPrivate *)data->activeVMEData; + QQmlIncubatorPrivate *p = data->incubator; if (!p) return; diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index cc9cc889d0..11d090a415 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -70,14 +70,15 @@ struct ActiveOCRestorer }; } -QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, QV4::CompiledData::CompilationUnit *compilationUnit, QQmlContextData *creationContext, void *activeVMEDataForRootContext) +QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, QV4::CompiledData::CompilationUnit *compilationUnit, QQmlContextData *creationContext, + QQmlIncubatorPrivate *incubator) : phase(Startup) , compilationUnit(compilationUnit) , resolvedTypes(compilationUnit->resolvedTypes) , propertyCaches(&compilationUnit->propertyCaches) , sharedState(new QQmlObjectCreatorSharedState) , topLevelCreator(true) - , activeVMEDataForRootContext(activeVMEDataForRootContext) + , incubator(incubator) { init(parentContext); @@ -104,7 +105,7 @@ QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, QV4::Compil , propertyCaches(&compilationUnit->propertyCaches) , sharedState(inheritedSharedState) , topLevelCreator(false) - , activeVMEDataForRootContext(0) + , incubator(0) { init(parentContext); } @@ -176,7 +177,7 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlI if (!sharedState->rootContext) { sharedState->rootContext = context; - sharedState->rootContext->activeVMEData = activeVMEDataForRootContext; + sharedState->rootContext->incubator = incubator; sharedState->rootContext->isRootObjectInCreation = true; } diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h index 45c14f0963..35bf96db4e 100644 --- a/src/qml/qml/qqmlobjectcreator_p.h +++ b/src/qml/qml/qqmlobjectcreator_p.h @@ -65,6 +65,7 @@ QT_BEGIN_NAMESPACE class QQmlAbstractBinding; struct QQmlTypeCompiler; class QQmlInstantiationInterrupt; +class QQmlIncubatorPrivate; struct QQmlObjectCreatorSharedState : public QSharedData { @@ -84,7 +85,7 @@ class QQmlObjectCreator { Q_DECLARE_TR_FUNCTIONS(QQmlObjectCreator) public: - QQmlObjectCreator(QQmlContextData *parentContext, QV4::CompiledData::CompilationUnit *compilationUnit, QQmlContextData *creationContext, void *activeVMEDataForRootContext = 0); + QQmlObjectCreator(QQmlContextData *parentContext, QV4::CompiledData::CompilationUnit *compilationUnit, QQmlContextData *creationContext, QQmlIncubatorPrivate *incubator = 0); ~QQmlObjectCreator(); QObject *create(int subComponentIndex = -1, QObject *parent = 0, QQmlInstantiationInterrupt *interrupt = 0); @@ -143,7 +144,7 @@ private: const QQmlPropertyCacheVector *propertyCaches; QExplicitlySharedDataPointer<QQmlObjectCreatorSharedState> sharedState; bool topLevelCreator; - void *activeVMEDataForRootContext; + QQmlIncubatorPrivate *incubator; QObject *_qobject; QObject *_scopeObject; diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index 21bbcadb1c..9a138dcf80 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -798,7 +798,7 @@ QQmlPropertyPrivate::binding(QObject *object, QQmlPropertyIndex index) const int coreIndex = index.coreIndex(); const int valueTypeIndex = index.valueTypeIndex(); - if (!data->hasBindingBit(coreIndex)) + if (coreIndex < 0 || !data->hasBindingBit(coreIndex)) return 0; QQmlAbstractBinding *binding = data->bindings; @@ -1546,6 +1546,9 @@ bool QQmlProperty::connectNotifySignal(QObject *dest, int method) const represent a regular Qt property or if it has no change notifier signal, or if the \a dest object does not have the specified \a slot. + + \note \a slot should be passed using the SLOT() macro so it is + correctly identified. */ bool QQmlProperty::connectNotifySignal(QObject *dest, const char *slot) const { diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 013ed48c70..38c14c2979 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -2296,7 +2296,7 @@ void QQmlTypeData::done() } } - m_compiledData->finalize(enginePrivate); + m_compiledData->finalizeCompositeType(enginePrivate); } { diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp index 2b54819ad0..bb70d88470 100644 --- a/src/qml/qml/qqmlvmemetaobject.cpp +++ b/src/qml/qml/qqmlvmemetaobject.cpp @@ -644,8 +644,7 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void * if (t == QV4::CompiledData::Property::Var) { // the context can be null if accessing var properties from cpp after re-parenting an item. QQmlEnginePrivate *ep = (ctxt == 0 || ctxt->engine == 0) ? 0 : QQmlEnginePrivate::get(ctxt->engine); - QV8Engine *v8e = (ep == 0) ? 0 : ep->v8engine(); - if (v8e) { + if (ep) { if (c == QMetaObject::ReadProperty) { *reinterpret_cast<QVariant *>(a[0]) = readPropertyAsVariant(id); } else if (c == QMetaObject::WriteProperty) { diff --git a/src/qml/types/qqmlbind.cpp b/src/qml/types/qqmlbind.cpp index da644becc2..91c5a50877 100644 --- a/src/qml/types/qqmlbind.cpp +++ b/src/qml/types/qqmlbind.cpp @@ -102,7 +102,7 @@ void QQmlBindPrivate::validate(QObject *binding) const In QML, property bindings result in a dependency between the properties of different objects. - \section1 Binding to an inaccessible property + \section1 Binding to an Inaccessible Property Sometimes it is necessary to bind an object's property to that of another object that isn't directly instantiated by QML, such as a @@ -120,7 +120,7 @@ void QQmlBindPrivate::validate(QObject *binding) const When \c{text} changes, the C++ property \c{enteredText} will update automatically. - \section1 Conditional bindings + \section1 Conditional Bindings In some cases you may want to modify the value of a property when a certain condition is met but leave it unmodified otherwise. Often, it's not possible |