From 742e869afe2dbba6aae6302d20ba9c82f3ed99c6 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 26 Oct 2017 11:56:43 +0200 Subject: Fix crash with dangling context object pointers This is a regression introduced by commit e22b624d9ab1f36021adb9cdbfa9b37054282bb8, where the object that owns the QML context would destroy the context upon destruction. Now the context may live longer and thus the context->contextObject pointer would become a dangling pointer. Task-number: QTBUG-63733 Change-Id: Idc660116752d312917a0a149110b92a042ccfb17 Reviewed-by: Lars Knoll Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlengine.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 5efebe28a2..d99bec4c52 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -891,6 +891,8 @@ void QQmlData::setQueuedForDeletion(QObject *object) if (ddata->ownContext) { Q_ASSERT(ddata->ownContext == ddata->context); ddata->context->emitDestruction(); + if (ddata->ownContext->contextObject == object) + ddata->ownContext->contextObject = nullptr; ddata->ownContext = 0; ddata->context = 0; } -- cgit v1.2.3 From 2e64e9e3d4bff0d93dd2671ef4aee72c566c55e1 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 1 Nov 2017 12:48:12 +0100 Subject: Prevent the QML engine from registering circular dependencies Change-Id: Ic4fd2bde745e7dfaf0909e8cc575441bb04cefa3 Task-number: QTBUG-64017 Reviewed-by: Lars Knoll Reviewed-by: Marco Martin Reviewed-by: Bhushan Shah --- src/qml/qml/qqmltypeloader.cpp | 10 +++++++++- src/qml/qml/qqmltypeloader_p.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 193acb04be..d9d7c19312 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -316,7 +316,8 @@ Returns true if the status is WaitingForDependencies. */ bool QQmlDataBlob::isWaiting() const { - return status() == WaitingForDependencies; + return status() == WaitingForDependencies || + status() == ResolvingDependencies; } /*! @@ -608,6 +609,7 @@ The default implementation does nothing. */ void QQmlDataBlob::allDependenciesDone() { + m_data.setStatus(QQmlDataBlob::ResolvingDependencies); } /*! @@ -2499,6 +2501,8 @@ void QQmlTypeData::continueLoadFromIR() void QQmlTypeData::allDependenciesDone() { + QQmlTypeLoader::Blob::allDependenciesDone(); + if (!m_typesResolved) { // Check that all imports were resolved QList errors; @@ -2618,6 +2622,10 @@ void QQmlTypeData::resolveTypes() if (ref.type.isCompositeSingleton()) { ref.typeData = typeLoader()->getType(ref.type.sourceUrl()); + if (ref.typeData->status() == QQmlDataBlob::ResolvingDependencies) { + // TODO: give an error message? If so, we should record and show the path of the cycle. + continue; + } addDependency(ref.typeData); ref.prefix = csRef.prefix; diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h index ef63e02b4f..22ac61968f 100644 --- a/src/qml/qml/qqmltypeloader_p.h +++ b/src/qml/qml/qqmltypeloader_p.h @@ -98,6 +98,7 @@ public: Null, // Prior to QQmlTypeLoader::load() Loading, // Prior to data being received and dataReceived() being called WaitingForDependencies, // While there are outstanding addDependency()s + ResolvingDependencies, // While resolving outstanding dependencies, to detect cycles Complete, // Finished Error // Error }; -- cgit v1.2.3 From 34992750d7d35086e26067fba14098f24caca4d3 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 6 Nov 2017 13:20:09 -0600 Subject: Check for duplication with url rather than uri We might have duplicated uris with different paths. This comparison is meant to check for multiple imports of the same path. Change-Id: I2d99728d32116453ae92a152337d2627c2653b79 Task-number: QTBUG-64237 Reviewed-by: Tim Jenssen --- src/qml/qml/qqmlimport.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index a85166da65..334bc8b28e 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -1539,7 +1539,7 @@ bool QQmlImportsPrivate::addFileImport(const QString& uri, const QString &prefix if (isImplicitImport) { for (QList::const_iterator it = nameSpace->imports.constBegin(); it != nameSpace->imports.constEnd(); ++it) { - if ((*it)->uri == importUri) { + if ((*it)->url == url) { (*it)->implicitlyImported = true; return true; } -- cgit v1.2.3 From fdfb34c84ba01114d34259cd88a2b84fa22eb610 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 9 Nov 2017 10:43:42 +0100 Subject: Improve encapsulation of the the IR de-serialization from QtQuick Compiler The code used by QQC to deserialize the IR requires setting the javaScriptCompilationUnit member in order to connect the generated C++ code. Knowledge of the QmlIR::Document data structure layout on the side of the generated code (thus application) has its downsides though (see referenced bug). We can avoid that dependency easily by doing the entire de-serialization on the QtQml library side. The old "API" (load member function) is still around until the qqc change is also in. Task-number: QTBUG-63474 Change-Id: I239838afacc71474c86114b5b05679ff36e4c2e2 Reviewed-by: Lars Knoll --- src/qml/qml/qqmltypeloader.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index d9d7c19312..842cf74887 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -2409,7 +2409,15 @@ void QQmlTypeData::dataReceived(const SourceCodeData &data) void QQmlTypeData::initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *unit) { m_document.reset(new QmlIR::Document(isDebugging())); - unit->loadIR(m_document.data(), unit); + if (unit->loadIR) { + // old code path for older generated code + unit->loadIR(m_document.data(), unit); + } else { + // new code path + QmlIR::IRLoader loader(unit->qmlData, m_document.data()); + loader.load(); + m_document->javaScriptCompilationUnit.adopt(unit->createCompilationUnit()); + } continueLoadFromIR(); } -- cgit v1.2.3 From c9a6f55659bc054f835aa682a521425f8fa2bf07 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 21 Sep 2017 14:53:44 +0200 Subject: Fix URL interception for qmldir files We need to intercept the URL when it is created. This relieves us of the need to hack around in it when actually retrieving the content of the qmldir file and prevents the futile attempt to load remote qmldir files via the code path that should load local ones (or vice versa). The back and forth conversion between URLs and strings is unfortunate, but can only be solved by using QUrl rather than QString where we actually mean URL. This would be a bigger change which is unsuitable for 5.9. Mind that nothing changes for code that doesn't use URL interceptors. Task-number: QTBUG-36773 Change-Id: I6bff3ae352009fdc0a17ec209691c7b390367f11 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlimport.cpp | 27 ++++++++++++++++++++++-- src/qml/qml/qqmlimport_p.h | 1 + src/qml/qml/qqmltypeloader.cpp | 48 +++++++++++++++++++++++++++++------------- 3 files changed, 59 insertions(+), 17 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index 4e3b25070f..18dc8e4b28 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -1266,11 +1266,20 @@ bool QQmlImportsPrivate::locateQmldir(const QString &uri, int vmaj, int vmin, QQ QQmlTypeLoader &typeLoader = QQmlEnginePrivate::get(database->engine)->typeLoader; - QStringList localImportPaths = database->importPathList(QQmlImportDatabase::Local); + // Interceptor might redirect remote files to local ones. + QQmlAbstractUrlInterceptor *interceptor = typeLoader.engine()->urlInterceptor(); + QStringList localImportPaths = database->importPathList( + interceptor ? QQmlImportDatabase::LocalOrRemote : QQmlImportDatabase::Local); // Search local import paths for a matching version const QStringList qmlDirPaths = QQmlImports::completeQmldirPaths(uri, localImportPaths, vmaj, vmin); - for (const QString &qmldirPath : qmlDirPaths) { + for (QString qmldirPath : qmlDirPaths) { + if (interceptor) { + qmldirPath = QQmlFile::urlToLocalFileOrQrc( + interceptor->intercept(QQmlImports::urlFromLocalFileOrQrcOrUrl(qmldirPath), + QQmlAbstractUrlInterceptor::QmldirFile)); + } + QString absoluteFilePath = typeLoader.absoluteFilePath(qmldirPath); if (!absoluteFilePath.isEmpty()) { QString url; @@ -1479,6 +1488,10 @@ bool QQmlImportsPrivate::addFileImport(const QString& uri, const QString &prefix QString qmldirUrl = resolveLocalUrl(base, importUri + (importUri.endsWith(Slash) ? String_qmldir : Slash_qmldir)); + if (QQmlAbstractUrlInterceptor *interceptor = typeLoader->engine()->urlInterceptor()) { + qmldirUrl = interceptor->intercept(QUrl(qmldirUrl), + QQmlAbstractUrlInterceptor::QmldirFile).toString(); + } QString qmldirIdentifier; if (QQmlFile::isLocalFile(qmldirUrl)) { @@ -1693,6 +1706,16 @@ bool QQmlImports::isLocal(const QUrl &url) return !QQmlFile::urlToLocalFileOrQrc(url).isEmpty(); } +QUrl QQmlImports::urlFromLocalFileOrQrcOrUrl(const QString &file) +{ + QUrl url(QLatin1String(file.at(0) == Colon ? "qrc" : "") + file); + + // We don't support single character schemes as those conflict with windows drive letters. + if (url.scheme().length() < 2) + return QUrl::fromLocalFile(file); + return url; +} + void QQmlImports::setDesignerSupportRequired(bool b) { designerSupportRequired = b; diff --git a/src/qml/qml/qqmlimport_p.h b/src/qml/qml/qqmlimport_p.h index 1bdd287690..9cb5340c68 100644 --- a/src/qml/qml/qqmlimport_p.h +++ b/src/qml/qml/qqmlimport_p.h @@ -184,6 +184,7 @@ public: static bool isLocal(const QString &url); static bool isLocal(const QUrl &url); + static QUrl urlFromLocalFileOrQrcOrUrl(const QString &); static void setDesignerSupportRequired(bool b); diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index d9d7c19312..1a7b8250e7 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -1436,8 +1436,13 @@ bool QQmlTypeLoader::Blob::addImport(const QV4::CompiledData::Import *import, QL // We haven't yet resolved this import m_unresolvedImports.insert(import, 0); - // Query any network import paths for this library - QStringList remotePathList = importDatabase->importPathList(QQmlImportDatabase::Remote); + QQmlAbstractUrlInterceptor *interceptor = typeLoader()->engine()->urlInterceptor(); + + // Query any network import paths for this library. + // Interceptor might redirect local paths. + QStringList remotePathList = importDatabase->importPathList( + interceptor ? QQmlImportDatabase::LocalOrRemote + : QQmlImportDatabase::Remote); if (!remotePathList.isEmpty()) { // Add this library and request the possible locations for it if (!m_importCache.addLibraryImport(importDatabase, importUri, importQualifier, import->majorVersion, @@ -1448,8 +1453,18 @@ bool QQmlTypeLoader::Blob::addImport(const QV4::CompiledData::Import *import, QL int priority = 0; const QStringList qmlDirPaths = QQmlImports::completeQmldirPaths(importUri, remotePathList, import->majorVersion, import->minorVersion); for (const QString &qmldirPath : qmlDirPaths) { - if (!fetchQmldir(QUrl(qmldirPath), import, ++priority, errors)) + if (interceptor) { + QUrl url = interceptor->intercept( + QQmlImports::urlFromLocalFileOrQrcOrUrl(qmldirPath), + QQmlAbstractUrlInterceptor::QmldirFile); + if (!QQmlFile::isLocalFile(url) + && !fetchQmldir(url, import, ++priority, errors)) { + return false; + } + } else if (!fetchQmldir(QUrl(qmldirPath), import, ++priority, errors)) { return false; + } + } } } @@ -1872,19 +1887,22 @@ It can also be a remote path for a remote directory import, but it will have bee */ const QQmlTypeLoaderQmldirContent *QQmlTypeLoader::qmldirContent(const QString &filePathIn) { - QUrl url(filePathIn); //May already contain http scheme - if (url.scheme() == QLatin1String("http") || url.scheme() == QLatin1String("https")) - return *(m_importQmlDirCache.value(filePathIn)); //Can't load the remote here, but should be cached - else - url = QUrl::fromLocalFile(filePathIn); - if (engine() && engine()->urlInterceptor()) - url = engine()->urlInterceptor()->intercept(url, QQmlAbstractUrlInterceptor::QmldirFile); - Q_ASSERT(url.scheme() == QLatin1String("file")); QString filePath; - if (url.scheme() == QLatin1String("file")) - filePath = url.toLocalFile(); - else - filePath = url.path(); + + // Try to guess if filePathIn is already a URL. This is necessarily fragile, because + // - paths can contain ':', which might make them appear as URLs with schemes. + // - windows drive letters appear as schemes (thus "< 2" below). + // - a "file:" URL is equivalent to the respective file, but will be treated differently. + // Yet, this heuristic is the best we can do until we pass more structured information here, + // for example a QUrl also for local files. + QUrl url(filePathIn); + if (url.scheme().length() < 2) { + filePath = filePathIn; + } else { + filePath = QQmlFile::urlToLocalFileOrQrc(url); + if (filePath.isEmpty()) // Can't load the remote here, but should be cached + return *(m_importQmlDirCache.value(filePathIn)); + } QQmlTypeLoaderQmldirContent *qmldir; QQmlTypeLoaderQmldirContent **val = m_importQmlDirCache.value(filePath); -- cgit v1.2.3 From 36ce1490fc541489f9091e9d91234aeac4f9df90 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 22 Sep 2017 15:55:42 +0200 Subject: Don't reject plugin-only qmldir files On QQmlImportsPrivate::updateQmldirContent we need to check if the new module has actually been established after figuring out that it doesn't have any components or scripts. If it has, then we shouldn't fail, as obviously a plugin has been loaded. We don't need to check the component and script versions in that case, as plugins don't have separate versions. Change-Id: Ie328b59038fe65c3f6a2eeecfe969927bba6cd68 Reviewed-by: Lars Knoll --- src/qml/qml/qqmlimport.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index 18dc8e4b28..c8d17c4b8e 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -1577,8 +1577,8 @@ bool QQmlImportsPrivate::updateQmldirContent(const QString &uri, const QString & if (import->setQmldirContent(qmldirUrl, qmldir, nameSpace, errors)) { if (import->qmlDirComponents.isEmpty() && import->qmlDirScripts.isEmpty()) { - // The implicit import qmldir can be empty - if (uri != QLatin1String(".")) { + // The implicit import qmldir can be empty, and plugins have no extra versions + if (uri != QLatin1String(".") && !QQmlMetaType::isModule(uri, vmaj, vmin)) { QQmlError error; if (QQmlMetaType::isAnyModule(uri)) error.setDescription(QQmlImportDatabase::tr("module \"%1\" version %2.%3 is not installed").arg(uri).arg(vmaj).arg(vmin)); -- cgit v1.2.3 From efe1926598c69a09c9365673bba6961a83936d49 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 17 Oct 2017 16:54:22 +0200 Subject: More fine-grained deferred property execution This allows Qt Quick Controls 2 to defer the execution of certain building blocks until needed. For example, a button control can defer its background item so that the default background is not executed at all when replaced by a custom background. First of all, this gives a massive performance boost for customized controls. Secondly, this avoids the most burning issue in QQC2, problems with asynchronous incubation ("Object destroyed during incubation"). Task-number: QTBUG-50992 Change-Id: If3616c9dac70e3a474a20070ad0452874d267164 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmldata_p.h | 3 ++ src/qml/qml/qqmlengine.cpp | 35 ++++++++++++++-- src/qml/qml/qqmlobjectcreator.cpp | 85 +++++++++++++++++++++++++++++++++++---- src/qml/qml/qqmlobjectcreator_p.h | 3 +- 4 files changed, 113 insertions(+), 13 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h index d692feb975..63994a392d 100644 --- a/src/qml/qml/qqmldata_p.h +++ b/src/qml/qml/qqmldata_p.h @@ -76,6 +76,7 @@ class QQmlNotifierEndpoint; namespace QV4 { namespace CompiledData { struct CompilationUnit; +struct Binding; } } @@ -216,12 +217,14 @@ public: struct DeferredData { unsigned int deferredIdx; + QMultiHash bindings; QV4::CompiledData::CompilationUnit *compilationUnit;//Not always the same as the other compilation unit QQmlContextData *context;//Could be either context or outerContext }; QV4::CompiledData::CompilationUnit *compilationUnit; QVector deferredData; + void deferData(int objectIndex, QV4::CompiledData::CompilationUnit *, QQmlContextData *); void releaseDeferredData(); QV4::WeakValue jsWrapper; diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index d99bec4c52..612c3439c1 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -1639,13 +1639,40 @@ void QQmlData::NotifyList::layout() todo = 0; } +void QQmlData::deferData(int objectIndex, QV4::CompiledData::CompilationUnit *compilationUnit, QQmlContextData *context) +{ + QQmlData::DeferredData *deferData = new QQmlData::DeferredData; + deferData->deferredIdx = objectIndex; + deferData->compilationUnit = compilationUnit; + deferData->compilationUnit->addref(); + deferData->context = context; + + const QV4::CompiledData::Object *compiledObject = compilationUnit->objectAt(objectIndex); + const QV4::CompiledData::BindingPropertyData &propertyData = compilationUnit->bindingPropertyDataPerObject.at(objectIndex); + + const QV4::CompiledData::Binding *binding = compiledObject->bindingTable(); + for (quint32 i = 0; i < compiledObject->nBindings; ++i, ++binding) { + const QQmlPropertyData *property = propertyData.at(i); + if (property && binding->flags & QV4::CompiledData::Binding::IsDeferredBinding) + deferData->bindings.insert(property->coreIndex(), binding); + } + + deferredData.append(deferData); +} + void QQmlData::releaseDeferredData() { - for (DeferredData *deferData : qAsConst(deferredData)) { - deferData->compilationUnit->release(); - delete deferData; + auto it = deferredData.begin(); + while (it != deferredData.end()) { + DeferredData *deferData = *it; + if (deferData->bindings.isEmpty()) { + deferData->compilationUnit->release(); + delete deferData; + it = deferredData.erase(it); + } else { + ++it; + } } - deferredData.clear(); } void QQmlData::addNotify(int index, QQmlNotifierEndpoint *endpoint) diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index b2f1421bcb..3663b06d55 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -233,6 +233,7 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlI return instance; } +// ### unify or keep in sync with populateDeferredBinding() bool QQmlObjectCreator::populateDeferredProperties(QObject *instance, QQmlData::DeferredData *deferredData) { QQmlData *declarativeData = QQmlData::get(instance); @@ -283,6 +284,80 @@ bool QQmlObjectCreator::populateDeferredProperties(QObject *instance, QQmlData:: qSwap(_qmlContext, qmlContext); qSwap(_scopeObject, scopeObject); + deferredData->bindings.clear(); + phase = ObjectsCreated; + + return errors.isEmpty(); +} + +// ### unify or keep in sync with populateDeferredProperties() +bool QQmlObjectCreator::populateDeferredBinding(const QQmlProperty &qmlProperty, QQmlData::DeferredData *deferredData, const QV4::CompiledData::Binding *binding) +{ + Q_ASSERT(binding->flags & QV4::CompiledData::Binding::IsDeferredBinding); + + QObject *instance = qmlProperty.object(); + QQmlData *declarativeData = QQmlData::get(instance); + context = deferredData->context; + sharedState->rootContext = context; + + QObject *bindingTarget = instance; + + QQmlRefPointer cache = declarativeData->propertyCache; + QQmlVMEMetaObject *vmeMetaObject = QQmlVMEMetaObject::get(instance); + + QObject *scopeObject = instance; + qSwap(_scopeObject, scopeObject); + + QV4::Scope valueScope(v4); + + Q_ASSERT(topLevelCreator); + if (!sharedState->allJavaScriptObjects) + sharedState->allJavaScriptObjects = valueScope.alloc(compilationUnit->totalObjectCount); + + QV4::QmlContext *qmlContext = static_cast(valueScope.alloc(1)); + + qSwap(_qmlContext, qmlContext); + + qSwap(_propertyCache, cache); + qSwap(_qobject, instance); + + int objectIndex = deferredData->deferredIdx; + qSwap(_compiledObjectIndex, objectIndex); + + const QV4::CompiledData::Object *obj = qmlUnit->objectAt(_compiledObjectIndex); + qSwap(_compiledObject, obj); + + qSwap(_ddata, declarativeData); + qSwap(_bindingTarget, bindingTarget); + qSwap(_vmeMetaObject, vmeMetaObject); + + QQmlListProperty savedList; + qSwap(_currentList, savedList); + + const QQmlPropertyData &property = QQmlPropertyPrivate::get(qmlProperty)->core; + + if (property.isQList()) { + void *argv[1] = { (void*)&_currentList }; + QMetaObject::metacall(_qobject, QMetaObject::ReadProperty, property.coreIndex(), argv); + } else if (_currentList.object) { + _currentList = QQmlListProperty(); + } + + setPropertyBinding(&property, binding); + + qSwap(_currentList, savedList); + + qSwap(_vmeMetaObject, vmeMetaObject); + qSwap(_bindingTarget, bindingTarget); + qSwap(_ddata, declarativeData); + qSwap(_compiledObject, obj); + qSwap(_compiledObjectIndex, objectIndex); + qSwap(_qobject, instance); + qSwap(_propertyCache, cache); + + qSwap(_qmlContext, qmlContext); + qSwap(_scopeObject, scopeObject); + phase = ObjectsCreated; return errors.isEmpty(); @@ -1341,14 +1416,8 @@ bool QQmlObjectCreator::populateInstance(int index, QObject *instance, QObject * qSwap(_propertyCache, cache); qSwap(_vmeMetaObject, vmeMetaObject); - if (_compiledObject->flags & QV4::CompiledData::Object::HasDeferredBindings) { - QQmlData::DeferredData *deferData = new QQmlData::DeferredData; - deferData->deferredIdx = _compiledObjectIndex; - deferData->compilationUnit = compilationUnit; - deferData->compilationUnit->addref(); - deferData->context = context; - _ddata->deferredData.append(deferData); - } + if (_compiledObject->flags & QV4::CompiledData::Object::HasDeferredBindings) + _ddata->deferData(_compiledObjectIndex, compilationUnit, context); if (_compiledObject->nFunctions > 0) setupFunctions(); diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h index 0c2d427c58..e2371cb4f1 100644 --- a/src/qml/qml/qqmlobjectcreator_p.h +++ b/src/qml/qml/qqmlobjectcreator_p.h @@ -81,7 +81,7 @@ struct QQmlObjectCreatorSharedState : public QSharedData QRecursionNode recursionNode; }; -class QQmlObjectCreator +class Q_QML_PRIVATE_EXPORT QQmlObjectCreator { Q_DECLARE_TR_FUNCTIONS(QQmlObjectCreator) public: @@ -90,6 +90,7 @@ public: QObject *create(int subComponentIndex = -1, QObject *parent = 0, QQmlInstantiationInterrupt *interrupt = 0); bool populateDeferredProperties(QObject *instance, QQmlData::DeferredData *deferredData); + bool populateDeferredBinding(const QQmlProperty &qmlProperty, QQmlData::DeferredData *deferredData, const QV4::CompiledData::Binding *binding); QQmlContextData *finalize(QQmlInstantiationInterrupt &interrupt); void cancel(QObject *object); void clear(); -- cgit v1.2.3 From 787dbda672d6df4ff2336bb3afda62a233b88aaa Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 25 Oct 2017 14:50:14 +0200 Subject: Check linked contexts for context objects being deleted In QQmlObjectCreator::createInstance we can assign the new object as context object to a linkedContext of its QQmlData, not only it's ownContext. Consequently, we have to check all the linked contexts and remove the object when found on deletion. Change-Id: I09bccdb0190406245fa5a379edaff0a8f118062f Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlengine.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 612c3439c1..5350ad38a3 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -714,8 +714,11 @@ void QQmlPrivate::qdeclarativeelement_destructor(QObject *o) { if (QQmlData *d = QQmlData::get(o)) { if (d->ownContext) { - for (QQmlContextData *lc = d->ownContext->linkedContext; lc; lc = lc->linkedContext) + for (QQmlContextData *lc = d->ownContext->linkedContext; lc; lc = lc->linkedContext) { lc->invalidate(); + if (lc->contextObject == o) + lc->contextObject = nullptr; + } d->ownContext->invalidate(); if (d->ownContext->contextObject == o) d->ownContext->contextObject = nullptr; -- cgit v1.2.3 From cc46992fbb94f1775ac22aa23b42d76f810a5913 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 21 Nov 2017 12:18:56 -0600 Subject: Fix issue with circular singleton instantiations While a recursion check exists and works, it can lead to instanting the same singleton multiple times (leaking all but one copy). Change-Id: Icf342aad71c5cb225488262341517d95786e1f84 Reviewed-by: Erik Verbruggen Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlmetatype.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index 8e6be538ef..0f388cf7b7 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -274,8 +274,10 @@ void QQmlType::SingletonInstanceInfo::init(QQmlEngine *e) QQmlData::ensurePropertyCache(e, o); } else if (!url.isEmpty() && !qobjectApi(e)) { QQmlComponent component(e, url, QQmlComponent::PreferSynchronous); - QObject *o = component.create(); + QObject *o = component.beginCreate(e->rootContext()); setQObjectApi(e, o); + if (o) + component.completeCreate(); } v4->popContext(); } -- cgit v1.2.3 From dac71f3d6f6bc4f159f6107c792bc70cfe7c308e Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 30 Nov 2017 13:49:46 +0100 Subject: Fix QQmlImportsPrivate::resolvedUri() Qt Quick Controls 2 styles have a version in the middle of the path/URI (e.g. qml/QtQuick/Controls.2/Material). The resolvedUri() helper method, which is used by addFileImport() for implicit imports, was never taught to deal with this type of versioning. It was only attempting to remove the version from the end. Change-Id: Ibdf23dc6c3b0794527d5f9330602858291c23e01 Task-number: QTBUG-64868 Reviewed-by: Simon Hausmann Reviewed-by: Lars Knoll --- src/qml/qml/qqmlimport.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index 334bc8b28e..a7cafa1a93 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -1231,10 +1231,12 @@ QString QQmlImportsPrivate::resolvedUri(const QString &dir_arg, QQmlImportDataba stableRelativePath.replace(Backslash, Slash); // remove optional versioning in dot notation from uri - int lastSlash = stableRelativePath.lastIndexOf(Slash); - if (lastSlash >= 0) { - int versionDot = stableRelativePath.indexOf(Dot, lastSlash); - if (versionDot >= 0) + int versionDot = stableRelativePath.lastIndexOf(Dot); + if (versionDot >= 0) { + int nextSlash = stableRelativePath.indexOf(Slash, versionDot); + if (nextSlash >= 0) + stableRelativePath.remove(versionDot, nextSlash - versionDot); + else stableRelativePath = stableRelativePath.left(versionDot); } -- cgit v1.2.3 From 2cfe1bb09c11432ca5033f9589243e9e62fe9488 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 27 Oct 2017 12:54:57 +0200 Subject: Add a means to unregister custom qml types In cases where Qt is used in a plugin it is possible that a plugin will be unloaded while Qt itself is still loaded and as a result there is a chance that there will be conflicting types registered. Therefore, to ensure that plugins correctly clean up after themselves cleanly, we need to add a means to unregister qml types. This is intended to only be used when the user knows what they are doing. Task-number: QTBUG-56521 Task-number: QTBUG-56532 Change-Id: Ie396e522385004e6e9f3841e04f8072ff29cb15b Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlmetatype.cpp | 21 +++++++++++++++++++++ src/qml/qml/qqmlmetatype_p.h | 2 ++ 2 files changed, 23 insertions(+) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index ac670bdabb..3a0d5c3daf 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -2238,6 +2238,27 @@ QQmlPropertyCache *QQmlMetaType::propertyCache(const QQmlType &type, int minorVe return data->propertyCache(type, minorVersion); } +void qmlUnregisterType(int typeIndex) +{ + QMutexLocker lock(metaTypeDataLock()); + QQmlMetaTypeData *data = metaTypeData(); + { + const QQmlTypePrivate *d = data->types.value(typeIndex).priv(); + if (d) { + removeQQmlTypePrivate(data->idToType, d); + removeQQmlTypePrivate(data->nameToType, d); + removeQQmlTypePrivate(data->urlToType, d); + removeQQmlTypePrivate(data->urlToNonFileImportType, d); + removeQQmlTypePrivate(data->metaObjectToType, d); + for (QQmlMetaTypeData::TypeModules::Iterator module = data->uriToModule.begin(); module != data->uriToModule.end(); ++module) { + QQmlTypeModulePrivate *modulePrivate = (*module)->priv(); + modulePrivate->remove(d); + } + data->types[typeIndex] = QQmlType(); + } + } +} + void QQmlMetaType::freeUnusedTypesAndCaches() { QMutexLocker lock(metaTypeDataLock()); diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h index 4bfdf52de1..f5b9beb905 100644 --- a/src/qml/qml/qqmlmetatype_p.h +++ b/src/qml/qml/qqmlmetatype_p.h @@ -75,6 +75,8 @@ class QQmlCompiledData; namespace QV4 { struct String; } +void Q_QML_PRIVATE_EXPORT qmlUnregisterType(int type); + class Q_QML_PRIVATE_EXPORT QQmlMetaType { public: -- cgit v1.2.3 From 4fff2bb14e55484eacec0a1b49a2b02958f75eca Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 15 Dec 2017 13:53:55 +0100 Subject: Fix QQml_setParent_noEvent not to print undefined behavior errors When building Qt with -fsanitize undefined, the usage of QQml_setParent_noEvent caused the following error message: "qqmlglobal_p.h:233:5: runtime error: downcast of address 0x60300061bf10 which does not point to an object of type 'QQmlGraphics_DerivedObject'". Instead of casting to the referred type, use QObjectPrivate::get to access the d_ptr. Change-Id: I2f2224bdb20a8d2e35a3291961378231f03c4ba2 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlglobal_p.h | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlglobal_p.h b/src/qml/qml/qqmlglobal_p.h index a6c113f5a7..5c46da0ea4 100644 --- a/src/qml/qml/qqmlglobal_p.h +++ b/src/qml/qml/qqmlglobal_p.h @@ -193,16 +193,6 @@ do { \ return QObjectPrivate::get(sender)->isSignalConnected(signalIdx); \ } while (0) -struct QQmlGraphics_DerivedObject : public QObject -{ - void setParent_noEvent(QObject *parent) { - bool sce = d_ptr->sendChildEvents; - d_ptr->sendChildEvents = false; - setParent(parent); - d_ptr->sendChildEvents = sce; - } -}; - /*! Returns true if the case of \a fileName is equivalent to the file case of \a fileName on disk, and false otherwise. @@ -230,7 +220,11 @@ bool QQml_isFileCaseCorrect(const QString &fileName, int length = -1); */ inline void QQml_setParent_noEvent(QObject *object, QObject *parent) { - static_cast(object)->setParent_noEvent(parent); + QObjectPrivate *d_ptr = QObjectPrivate::get(object); + bool sce = d_ptr->sendChildEvents; + d_ptr->sendChildEvents = false; + object->setParent(parent); + d_ptr->sendChildEvents = sce; } class Q_QML_PRIVATE_EXPORT QQmlValueTypeProvider -- cgit v1.2.3 From 52bc4fbfbae6aa1569dc134dd103e966f04bc2e6 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 11 Dec 2017 12:44:47 +0100 Subject: Use potentially intercepted URL as ID for compilation units We generally have to pass a URL and a file name everywhere because the logical URL might be something else than the actual file being loaded. For example a QQmlFileSelector might modify the URL to be loaded for a specific file. This resulting URL, however, should not be used to resolve further URLs defined in the file loaded that way. As we need to access QQmlTypeLoader::m_url as string more often now, cache it and avoid frequent translations between QUrl and QString. Furthermore, QQmlDataBlob's URLs are changed to follow the same semantics. The finalUrl is the one that should be used to resolve further URLs, the url is the one used to load the content, and subject to any redirects or interceptions. This changes the semantics of URL redirects. Previously a redirected URL was used as the base URL for furher URL resolution. This doesn't work because redirection occurs after interception and interception should not influence the resolution of further URLs. We now use the original URL as base URL for resolution of further URLs and rely on the server to redirect those, too. Task-number: QTBUG-61209 Change-Id: I93822f820bed2515995de3cb118099218b510ca4 Reviewed-by: Michael Brasser --- src/qml/qml/qqmlcomponent.cpp | 2 +- src/qml/qml/qqmlcontext.cpp | 4 +- src/qml/qml/qqmlincubator.cpp | 2 +- src/qml/qml/qqmlobjectcreator.cpp | 5 ++- src/qml/qml/qqmltypeloader.cpp | 80 +++++++++++++++++++++++---------------- src/qml/qml/qqmltypeloader_p.h | 2 + 6 files changed, 56 insertions(+), 39 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 7f1121c1e1..e872b1d92e 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -561,7 +561,7 @@ QQmlComponent::QQmlComponent(QQmlEngine *engine, QV4::CompiledData::CompilationU Q_D(QQmlComponent); d->compilationUnit = compilationUnit; d->start = start; - d->url = compilationUnit->url(); + d->url = compilationUnit->finalUrl(); d->progress = 1.0; } diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp index 37cb328b36..59e2c83a63 100644 --- a/src/qml/qml/qqmlcontext.cpp +++ b/src/qml/qml/qqmlcontext.cpp @@ -845,14 +845,14 @@ QV4::IdentifierHash &QQmlContextData::detachedPropertyNames() QUrl QQmlContextData::url() const { if (typeCompilationUnit) - return typeCompilationUnit->url(); + return typeCompilationUnit->finalUrl(); return baseUrl; } QString QQmlContextData::urlString() const { if (typeCompilationUnit) - return typeCompilationUnit->fileName(); + return typeCompilationUnit->finalUrlString(); return baseUrlString; } diff --git a/src/qml/qml/qqmlincubator.cpp b/src/qml/qml/qqmlincubator.cpp index 6d0e4b915a..93bb67de20 100644 --- a/src/qml/qml/qqmlincubator.cpp +++ b/src/qml/qml/qqmlincubator.cpp @@ -272,7 +272,7 @@ void QQmlIncubatorPrivate::incubate(QQmlInstantiationInterrupt &i) if (!compilationUnit) return; - QML_MEMORY_SCOPE_URL(compilationUnit->url()); + QML_MEMORY_SCOPE_URL(compilationUnit->finalUrl()); QExplicitlySharedDataPointer protectThis(this); diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 3663b06d55..9c6630190f 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -445,7 +445,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const QString string = binding->valueAsString(qmlUnit); // Encoded dir-separators defeat QUrl processing - decode them first string.replace(QLatin1String("%2f"), QLatin1String("/"), Qt::CaseInsensitive); - QUrl value = string.isEmpty() ? QUrl() : compilationUnit->url().resolved(QUrl(string)); + QUrl value = string.isEmpty() ? QUrl() : compilationUnit->finalUrl().resolved(QUrl(string)); // Apply URL interceptor if (engine->urlInterceptor()) value = engine->urlInterceptor()->intercept(value, QQmlAbstractUrlInterceptor::UrlString); @@ -643,7 +643,8 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const } else if (property->propType() == qMetaTypeId >()) { Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_String); QString urlString = binding->valueAsString(qmlUnit); - QUrl u = urlString.isEmpty() ? QUrl() : compilationUnit->url().resolved(QUrl(urlString)); + QUrl u = urlString.isEmpty() ? QUrl() + : compilationUnit->finalUrl().resolved(QUrl(urlString)); QList value; value.append(u); property->writeProperty(_qobject, &value, propertyWriteFlags); diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index f3077f673b..19e57fbdba 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -356,8 +356,10 @@ qreal QQmlDataBlob::progress() const } /*! -Returns the blob url passed to the constructor. If a network redirect -happens while fetching the data, this url remains the same. +Returns the physical url of the data. Initially this is the same as +finalUrl(), but if a network redirect happens while fetching the data, this url +is updated to reflect the new location. Also, if a URL interceptor is set, it +will work on this URL and leave finalUrl() alone. \sa finalUrl() */ @@ -366,16 +368,25 @@ QUrl QQmlDataBlob::url() const return m_url; } +QString QQmlDataBlob::urlString() const +{ + if (m_urlString.isEmpty()) + m_urlString = m_url.toString(); + + return m_urlString; +} + /*! -Returns the final url of the data. Initially this is the same as -url(), but if a network redirect happens while fetching the data, this url -is updated to reflect the new location. +Returns the logical URL to be used for resolving further URLs referred to in +the code. -May only be called from the load thread, or after the blob isCompleteOrError(). +This is the blob url passed to the constructor. If a network redirect +happens while fetching the data, this url remains the same. + +\sa url() */ QUrl QQmlDataBlob::finalUrl() const { - Q_ASSERT(isCompleteOrError() || (m_typeLoader && m_typeLoader->m_thread->isThisThread())); return m_finalUrl; } @@ -384,7 +395,6 @@ Returns the finalUrl() as a string. */ QString QQmlDataBlob::finalUrlString() const { - Q_ASSERT(isCompleteOrError() || (m_typeLoader && m_typeLoader->m_thread->isThisThread())); if (m_finalUrlString.isEmpty()) m_finalUrlString = m_finalUrl.toString(); @@ -433,7 +443,7 @@ void QQmlDataBlob::setError(const QList &errors) m_data.setStatus(Error); if (dumpErrors()) { - qWarning().nospace() << "Errors for " << m_finalUrl.toString(); + qWarning().nospace() << "Errors for " << urlString(); for (int ii = 0; ii < errors.count(); ++ii) qWarning().nospace() << " " << qPrintable(errors.at(ii).toString()); } @@ -472,7 +482,7 @@ void QQmlDataBlob::setError(const QString &description) { QQmlError e; e.setDescription(description); - e.setUrl(finalUrl()); + e.setUrl(url()); setError(e); } @@ -537,7 +547,7 @@ void QQmlDataBlob::networkError(QNetworkReply::NetworkError networkError) Q_UNUSED(networkError); QQmlError error; - error.setUrl(m_finalUrl); + error.setUrl(m_url); const char *errorString = 0; switch (networkError) { @@ -654,7 +664,7 @@ void QQmlDataBlob::tryDone() addref(); #ifdef DATABLOB_DEBUG - qWarning("QQmlDataBlob::done() %s", qPrintable(url().toString())); + qWarning("QQmlDataBlob::done() %s", qPrintable(urlString())); #endif done(); @@ -893,7 +903,7 @@ void QQmlTypeLoaderThread::callCompletedMain(QQmlDataBlob *b) { QML_MEMORY_SCOPE_URL(b->url()); #ifdef DATABLOB_DEBUG - qWarning("QQmlTypeLoaderThread: %s completed() callback", qPrintable(b->url().toString())); + qWarning("QQmlTypeLoaderThread: %s completed() callback", qPrintable(b->urlString())); #endif b->completed(); b->release(); @@ -903,7 +913,7 @@ void QQmlTypeLoaderThread::callDownloadProgressChangedMain(QQmlDataBlob *b, qrea { #ifdef DATABLOB_DEBUG qWarning("QQmlTypeLoaderThread: %s downloadProgressChanged(%f) callback", - qPrintable(b->url().toString()), p); + qPrintable(b->urlString()), p); #endif b->downloadProgressChanged(p); b->release(); @@ -1037,7 +1047,7 @@ template void QQmlTypeLoader::doLoad(const Loader &loader, QQmlDataBlob *blob, Mode mode) { #ifdef DATABLOB_DEBUG - qWarning("QQmlTypeLoader::doLoad(%s): %s thread", qPrintable(blob->m_url.toString()), + qWarning("QQmlTypeLoader::doLoad(%s): %s thread", qPrintable(blob->urlString()), m_thread->isThisThread()?"Compile":"Engine"); #endif blob->startLoading(); @@ -1159,7 +1169,7 @@ void QQmlTypeLoader::loadThread(QQmlDataBlob *blob) } #ifdef DATABLOB_DEBUG - qWarning("QQmlDataBlob: requested %s", qPrintable(blob->url().toString())); + qWarning("QQmlDataBlob: requested %s", qPrintable(blob->urlString())); #endif // DATABLOB_DEBUG #endif // qml_network } @@ -1185,14 +1195,15 @@ void QQmlTypeLoader::networkReplyFinished(QNetworkReply *reply) QVariant redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute); if (redirect.isValid()) { QUrl url = reply->url().resolved(redirect.toUrl()); - blob->m_finalUrl = url; + blob->m_url = url; + blob->m_urlString.clear(); QNetworkReply *reply = m_thread->networkAccessManager()->get(QNetworkRequest(url)); QObject *nrp = m_thread->networkReplyProxy(); QObject::connect(reply, SIGNAL(finished()), nrp, SLOT(finished())); m_networkReplies.insert(reply, blob); #ifdef DATABLOB_DEBUG - qWarning("QQmlDataBlob: redirected to %s", qPrintable(blob->m_finalUrl.toString())); + qWarning("QQmlDataBlob: redirected to %s", qPrintable(blob->urlString())); #endif return; } @@ -1348,7 +1359,7 @@ bool QQmlTypeLoader::Blob::fetchQmldir(const QUrl &url, const QV4::CompiledData: bool QQmlTypeLoader::Blob::updateQmldir(QQmlQmldirData *data, const QV4::CompiledData::Import *import, QList *errors) { - QString qmldirIdentifier = data->url().toString(); + QString qmldirIdentifier = data->urlString(); QString qmldirUrl = qmldirIdentifier.left(qmldirIdentifier.lastIndexOf(QLatin1Char('/')) + 1); typeLoader()->setQmldirContent(qmldirIdentifier, data->content()); @@ -2104,7 +2115,7 @@ bool QQmlTypeData::tryLoadFromDiskCache() { QString error; if (!unit->loadFromDisk(url(), m_backupSourceCode.sourceTimeStamp(), v4->iselFactory.data(), &error)) { - qCDebug(DBG_DISK_CACHE) << "Error loading" << url().toString() << "from disk cache:" << error; + qCDebug(DBG_DISK_CACHE) << "Error loading" << urlString() << "from disk cache:" << error; return false; } } @@ -2224,10 +2235,10 @@ void QQmlTypeData::done() if (script.script->isError()) { QList errors = script.script->errors(); QQmlError error; - error.setUrl(finalUrl()); + error.setUrl(url()); error.setLine(script.location.line); error.setColumn(script.location.column); - error.setDescription(QQmlTypeLoader::tr("Script %1 unavailable").arg(script.script->url().toString())); + error.setDescription(QQmlTypeLoader::tr("Script %1 unavailable").arg(script.script->urlString())); errors.prepend(error); setError(errors); return; @@ -2244,7 +2255,7 @@ void QQmlTypeData::done() QList errors = type.typeData->errors(); QQmlError error; - error.setUrl(finalUrl()); + error.setUrl(url()); error.setLine(type.location.line); error.setColumn(type.location.column); error.setDescription(QQmlTypeLoader::tr("Type %1 unavailable").arg(typeName)); @@ -2263,7 +2274,7 @@ void QQmlTypeData::done() QList errors = type.typeData->errors(); QQmlError error; - error.setUrl(finalUrl()); + error.setUrl(url()); error.setLine(type.location.line); error.setColumn(type.location.column); error.setDescription(QQmlTypeLoader::tr("Type %1 unavailable").arg(typeName)); @@ -2293,7 +2304,7 @@ void QQmlTypeData::done() // verify if any dependencies changed if we're using a cache if (m_document.isNull() && !m_compiledData->verifyChecksum(dependencyHasher)) { - qCDebug(DBG_DISK_CACHE) << "Checksum mismatch for cached version of" << m_compiledData->url().toString(); + qCDebug(DBG_DISK_CACHE) << "Checksum mismatch for cached version of" << m_compiledData->fileName(); if (!loadFromSource()) return; m_backupSourceCode = SourceCodeData(); @@ -2458,7 +2469,7 @@ bool QQmlTypeData::loadFromSource() errors.reserve(compiler.errors.count()); for (const QQmlJS::DiagnosticMessage &msg : qAsConst(compiler.errors)) { QQmlError e; - e.setUrl(finalUrl()); + e.setUrl(url()); e.setLine(msg.loc.startLine); e.setColumn(msg.loc.startColumn); e.setDescription(msg.message); @@ -2475,7 +2486,8 @@ void QQmlTypeData::restoreIR(QQmlRefPointer m_document.reset(new QmlIR::Document(isDebugging())); QmlIR::IRLoader loader(unit->data, m_document.data()); loader.load(); - m_document->jsModule.setFileName(finalUrlString()); + m_document->jsModule.setFileName(urlString()); + m_document->jsModule.setFinalUrl(finalUrlString()); m_document->javaScriptCompilationUnit = unit; continueLoadFromIR(); } @@ -2598,7 +2610,7 @@ void QQmlTypeData::compile(const QQmlRefPointer &typeNameCach // ignore error, keep using the in-memory compilation unit. } } else { - qCDebug(DBG_DISK_CACHE) << "Error saving cached version of" << m_compiledData->url().toString() << "to disk:" << errorString; + qCDebug(DBG_DISK_CACHE) << "Error saving cached version of" << m_compiledData->fileName() << "to disk:" << errorString; } } } @@ -2969,7 +2981,7 @@ void QQmlScriptBlob::dataReceived(const SourceCodeData &data) initializeFromCompilationUnit(unit); return; } else { - qCDebug(DBG_DISK_CACHE()) << "Error loading" << url().toString() << "from disk cache:" << error; + qCDebug(DBG_DISK_CACHE()) << "Error loading" << urlString() << "from disk cache:" << error; } } @@ -2987,7 +2999,9 @@ void QQmlScriptBlob::dataReceived(const SourceCodeData &data) QmlIR::ScriptDirectivesCollector collector(&irUnit.jsParserEngine, &irUnit.jsGenerator); QList errors; - QQmlRefPointer unit = QV4::Script::precompile(&irUnit.jsModule, &irUnit.jsGenerator, v4, finalUrl(), source, &errors, &collector); + QQmlRefPointer unit = QV4::Script::precompile( + &irUnit.jsModule, &irUnit.jsGenerator, v4, urlString(), finalUrlString(), + source, &errors, &collector); // No need to addref on unit, it's initial refcount is 1 source.clear(); if (!errors.isEmpty()) { @@ -3011,7 +3025,7 @@ void QQmlScriptBlob::dataReceived(const SourceCodeData &data) if (!disableDiskCache() || forceDiskCache()) { QString errorString; if (!unit->saveToDisk(url(), &errorString)) { - qCDebug(DBG_DISK_CACHE()) << "Error saving cached version of" << unit->url().toString() << "to disk:" << errorString; + qCDebug(DBG_DISK_CACHE()) << "Error saving cached version of" << unit->fileName() << "to disk:" << errorString; } } @@ -3035,10 +3049,10 @@ void QQmlScriptBlob::done() if (script.script->isError()) { QList errors = script.script->errors(); QQmlError error; - error.setUrl(finalUrl()); + error.setUrl(url()); error.setLine(script.location.line); error.setColumn(script.location.column); - error.setDescription(QQmlTypeLoader::tr("Script %1 unavailable").arg(script.script->url().toString())); + error.setDescription(QQmlTypeLoader::tr("Script %1 unavailable").arg(script.script->urlString())); errors.prepend(error); setError(errors); return; diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h index 22ac61968f..ab32bac7b2 100644 --- a/src/qml/qml/qqmltypeloader_p.h +++ b/src/qml/qml/qqmltypeloader_p.h @@ -129,6 +129,7 @@ public: qreal progress() const; QUrl url() const; + QString urlString() const; QUrl finalUrl() const; QString finalUrlString() const; @@ -207,6 +208,7 @@ private: QUrl m_url; QUrl m_finalUrl; + mutable QString m_urlString; mutable QString m_finalUrlString; // List of QQmlDataBlob's that are waiting for me to complete. -- cgit v1.2.3 From 8836896dff45fe1d21736835845e36d03763117f Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 12 Dec 2017 11:16:45 +0100 Subject: Allow QQmlComponent::loadUrl() to load absolute URLs with relative paths Currently, QQmlTypeLoader::getType() will assert if passed a relative URL, because it needs absolute URLs in order to ensure that it can use them as keys for its cache. After dc6b73390 was merged, URLs like QUrl::fromLocalFile("main.qml") (which are currently used in examples of how to load a QQmlComponent) started causing the assertion to fail. As mentioned in the comments of the bug report, some patches have already been applied to QQmlComponent's QString-based constructors, but both the constructors taking a QUrl and loadUrl() itself need fixing. This patch puts the fix into loadUrl() (the constructors call this function) so that every operation involving URLs is successful when using the documented methods. Task-number: QTBUG-58837 Change-Id: Ib54ca52eddce6e7781cf96015f4c15af604233d3 Reviewed-by: David Faure --- src/qml/qml/qqmlcomponent.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index e872b1d92e..4da6b7958c 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -496,8 +496,7 @@ QQmlComponent::QQmlComponent(QQmlEngine *engine, QObject *parent) Create a QQmlComponent from the given \a url and give it the specified \a parent and \a engine. - Ensure that the URL provided is full and correct, in particular, use - \l QUrl::fromLocalFile() when loading a file from the local filesystem. + \include qqmlcomponent.qdoc url-note \sa loadUrl() */ @@ -511,8 +510,7 @@ QQmlComponent::QQmlComponent(QQmlEngine *engine, const QUrl &url, QObject *paren specified \a parent and \a engine. If \a mode is \l Asynchronous, the component will be loaded and compiled asynchronously. - Ensure that the URL provided is full and correct, in particular, use - \l QUrl::fromLocalFile() when loading a file from the local filesystem. + \include qqmlcomponent.qdoc url-note \sa loadUrl() */ @@ -548,7 +546,7 @@ QQmlComponent::QQmlComponent(QQmlEngine *engine, const QString &fileName, : QQmlComponent(engine, parent) { Q_D(QQmlComponent); - const QUrl url = QDir::isAbsolutePath(fileName) ? QUrl::fromLocalFile(fileName) : d->engine->baseUrl().resolved(QUrl(fileName)); + const QUrl url = QDir::isAbsolutePath(fileName) ? QUrl::fromLocalFile(fileName) : QUrl(fileName); d->loadUrl(url, mode); } @@ -608,8 +606,7 @@ QQmlContext *QQmlComponent::creationContext() const /*! Load the QQmlComponent from the provided \a url. - Ensure that the URL provided is full and correct, in particular, use - \l QUrl::fromLocalFile() when loading a file from the local filesystem. + \include qqmlcomponent.qdoc url-note */ void QQmlComponent::loadUrl(const QUrl &url) { @@ -621,8 +618,7 @@ void QQmlComponent::loadUrl(const QUrl &url) Load the QQmlComponent from the provided \a url. If \a mode is \l Asynchronous, the component will be loaded and compiled asynchronously. - Ensure that the URL provided is full and correct, in particular, use - \l QUrl::fromLocalFile() when loading a file from the local filesystem. + \include qqmlcomponent.qdoc url-note */ void QQmlComponent::loadUrl(const QUrl &url, QQmlComponent::CompilationMode mode) { @@ -635,11 +631,21 @@ void QQmlComponentPrivate::loadUrl(const QUrl &newUrl, QQmlComponent::Compilatio Q_Q(QQmlComponent); clear(); - if ((newUrl.isRelative() && !newUrl.isEmpty()) - || newUrl.scheme() == QLatin1String("file")) // Workaround QTBUG-11929 - url = engine->baseUrl().resolved(newUrl); - else + if (newUrl.isRelative()) { + // The new URL is a relative URL like QUrl("main.qml"). + url = engine->baseUrl().resolved(QUrl(newUrl.toString())); + } else if (engine->baseUrl().isLocalFile() && newUrl.isLocalFile() && !QDir::isAbsolutePath(newUrl.toLocalFile())) { + // The new URL is a file on disk but it's a relative path; e.g.: + // QUrl::fromLocalFile("main.qml") or QUrl("file:main.qml") + // We need to remove the scheme so that it becomes a relative URL with a relative path: + QUrl fixedUrl(newUrl); + fixedUrl.setScheme(QString()); + // Then, turn it into an absolute URL with an absolute path by resolving it against the engine's baseUrl(). + // This is a compatibility hack for QTBUG-58837. + url = engine->baseUrl().resolved(fixedUrl); + } else { url = newUrl; + } if (newUrl.isEmpty()) { QQmlError error; -- cgit v1.2.3 From d949d52383e92ba814e935ed2ef2135a1af9cd9b Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 18 Dec 2017 19:45:28 +0100 Subject: Drop some dead code Change-Id: Ia3d8adac5c1cd791b05b435ecb063f1b1304cdf3 Reviewed-by: Lars Knoll --- src/qml/qml/v8/qv8engine.cpp | 4 ---- src/qml/qml/v8/qv8engine_p.h | 10 ---------- 2 files changed, 14 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp index dadff819cf..2947f7870a 100644 --- a/src/qml/qml/v8/qv8engine.cpp +++ b/src/qml/qml/v8/qv8engine.cpp @@ -127,7 +127,6 @@ QV8Engine::QV8Engine(QJSEngine* qq) : q(qq) , m_engine(0) , m_xmlHttpRequestData(0) - , m_listModelData(0) { #ifdef Q_PROCESSOR_X86_32 if (!qCpuHasFeature(SSE2)) { @@ -164,9 +163,6 @@ QV8Engine::~QV8Engine() m_xmlHttpRequestData = 0; #endif - delete m_listModelData; - m_listModelData = 0; - delete m_v4Engine; } diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h index a430fba0e6..98b182147c 100644 --- a/src/qml/qml/v8/qv8engine_p.h +++ b/src/qml/qml/v8/qv8engine_p.h @@ -77,12 +77,6 @@ namespace QV4 { struct QObjectMethod; } -#define V4THROW_ERROR(string) \ - return ctx->engine()->throwError(QString::fromUtf8(string)); - -#define V4THROW_TYPE(string) \ - return ctx->engine()->throwTypeError(QStringLiteral(string)); - #define V4_DEFINE_EXTENSION(dataclass, datafunction) \ static inline dataclass *datafunction(QV4::ExecutionEngine *engine) \ { \ @@ -183,9 +177,6 @@ public: void *xmlHttpRequestData() const { return m_xmlHttpRequestData; } - Deletable *listModelData() const { return m_listModelData; } - void setListModelData(Deletable *d) { if (m_listModelData) delete m_listModelData; m_listModelData = d; } - void freezeObject(const QV4::Value &value); #if QT_CONFIG(qml_network) @@ -222,7 +213,6 @@ protected: void *m_xmlHttpRequestData; QVector m_extensionData; - Deletable *m_listModelData; QSet m_illegalNames; -- cgit v1.2.3 From 2e8a45d99f94cbd2c805dd3de56d60d9baa9bd4e Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 8 Jan 2018 15:00:03 +0100 Subject: Fix regression with simple qsTr() bindings on non-string properties Commit 61887379b0c823953b61120532055fcbd881aadd introduced an optimization to avoid lengthy JS evaluation for simple qsTr("constant string") bindings. Unfortunately it missed the case that the binding is _not_ to a QString "native" property, resulting in memory corruption: property var str: qsTr("sometimes") ... where QQmlVMEMetaObject's metacall would expect the void *arg to be a QVariant and the translation binding would "deliver" a QString pointer. [ChangeLog[Qt][Qml] Fix crash with simple qsTr() bindings on var properties. Change-Id: I8d35eecbf6697fb3e3ad184389deb81890b08e29 Task-number: QTBUG-65624 Reviewed-by: Lars Knoll --- src/qml/qml/qqmlbinding.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index 566fbb86ac..9453e6480b 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -307,7 +307,7 @@ public: } void doUpdate(const DeleteWatcher &watcher, - QQmlPropertyData::WriteFlags flags, QV4::Scope &) Q_DECL_OVERRIDE Q_DECL_FINAL + QQmlPropertyData::WriteFlags flags, QV4::Scope &scope) Q_DECL_OVERRIDE Q_DECL_FINAL { if (watcher.wasDeleted()) return; @@ -323,7 +323,12 @@ public: QQmlPropertyData vpd; getPropertyData(&pd, &vpd); Q_ASSERT(pd); - doStore(result, pd, flags); + if (pd->propType() == QMetaType::QString) { + doStore(result, pd, flags); + } else { + QV4::ScopedString value(scope, scope.engine->newString(result)); + slowWrite(*pd, vpd, value, /*isUndefined*/false, flags); + } } private: -- cgit v1.2.3 From bc8f9f28a3aaba7c9708720cfac632700bc66c18 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 2 Jan 2018 14:02:17 +0100 Subject: Simplify and cleanup code in QQmlContext Simply forward the setContext(QObject *) call to the QVariant overload. Change-Id: I6f7d03419788c4323fd3dc2a725628bfe1170102 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlcontext.cpp | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp index 37cb328b36..fbf73a944c 100644 --- a/src/qml/qml/qqmlcontext.cpp +++ b/src/qml/qml/qqmlcontext.cpp @@ -306,15 +306,6 @@ void QQmlContext::setContextProperty(const QString &name, const QVariant &value) return; } - if (data->engine) { - bool ok; - QObject *o = QQmlEnginePrivate::get(data->engine)->toQObject(value, &ok); - if (ok) { - setContextProperty(name, o); - return; - } - } - QV4::IdentifierHash &properties = data->detachedPropertyNames(); int idx = properties.value(name); if (idx == -1) { @@ -335,34 +326,7 @@ void QQmlContext::setContextProperty(const QString &name, const QVariant &value) */ void QQmlContext::setContextProperty(const QString &name, QObject *value) { - Q_D(QQmlContext); - if (d->notifyIndex == -1) - d->notifyIndex = QMetaObjectPrivate::absoluteSignalCount(&QQmlContext::staticMetaObject); - - QQmlContextData *data = d->data; - - if (data->isInternal) { - qWarning("QQmlContext: Cannot set property on internal context."); - return; - } - - if (!isValid()) { - qWarning("QQmlContext: Cannot set property on invalid context."); - return; - } - - QV4::IdentifierHash &properties = data->detachedPropertyNames(); - int idx = properties.value(name); - - if (idx == -1) { - properties.add(name, data->idValueCount + d->propertyValues.count()); - d->propertyValues.append(QVariant::fromValue(value)); - - data->refreshExpressions(); - } else { - d->propertyValues[idx] = QVariant::fromValue(value); - QMetaObject::activate(this, d->notifyIndex, idx, 0); - } + setContextProperty(name, QVariant::fromValue(value)); } /*! -- cgit v1.2.3 From ebf024a136b5d9950c0b17ce64363bd23be2f637 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 2 Jan 2018 14:23:46 +0100 Subject: Cleanup IdentifierHash This class is only used in one place, so there's no point in it being a template. Change-Id: Ibbbed8d5be1d02015339c9b39cd1b167f36b8885 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlcontext.cpp | 12 ++++++------ src/qml/qml/qqmlcontext_p.h | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp index fbf73a944c..a32ed6e998 100644 --- a/src/qml/qml/qqmlcontext.cpp +++ b/src/qml/qml/qqmlcontext.cpp @@ -306,7 +306,7 @@ void QQmlContext::setContextProperty(const QString &name, const QVariant &value) return; } - QV4::IdentifierHash &properties = data->detachedPropertyNames(); + QV4::IdentifierHash &properties = data->detachedPropertyNames(); int idx = properties.value(name); if (idx == -1) { properties.add(name, data->idValueCount + d->propertyValues.count()); @@ -341,7 +341,7 @@ QVariant QQmlContext::contextProperty(const QString &name) const QQmlContextData *data = d->data; - const QV4::IdentifierHash &properties = data->propertyNames(); + const QV4::IdentifierHash &properties = data->propertyNames(); if (properties.count()) idx = properties.value(name); @@ -746,7 +746,7 @@ void QQmlContextData::setIdProperty(int idx, QObject *obj) QString QQmlContextData::findObjectId(const QObject *obj) const { - const QV4::IdentifierHash &properties = propertyNames(); + const QV4::IdentifierHash &properties = propertyNames(); if (propertyNameCache.isEmpty()) return QString(); @@ -788,18 +788,18 @@ void QQmlContextData::initFromTypeCompilationUnit(const QQmlRefPointer &QQmlContextData::propertyNames() const +const QV4::IdentifierHash &QQmlContextData::propertyNames() const { if (propertyNameCache.isEmpty()) { if (typeCompilationUnit) propertyNameCache = typeCompilationUnit->namedObjectsPerComponent(componentObjectIndex); else - propertyNameCache = QV4::IdentifierHash(QV8Engine::getV4(engine)); + propertyNameCache = QV4::IdentifierHash(QV8Engine::getV4(engine)); } return propertyNameCache; } -QV4::IdentifierHash &QQmlContextData::detachedPropertyNames() +QV4::IdentifierHash &QQmlContextData::detachedPropertyNames() { propertyNames(); propertyNameCache.detach(); diff --git a/src/qml/qml/qqmlcontext_p.h b/src/qml/qml/qqmlcontext_p.h index d01820a430..8939c810fe 100644 --- a/src/qml/qml/qqmlcontext_p.h +++ b/src/qml/qml/qqmlcontext_p.h @@ -158,9 +158,9 @@ public: void initFromTypeCompilationUnit(const QQmlRefPointer &unit, int subComponentIndex); // flag indicates whether the context owns the cache (after mutation) or not. - mutable QV4::IdentifierHash propertyNameCache; - const QV4::IdentifierHash &propertyNames() const; - QV4::IdentifierHash &detachedPropertyNames(); + mutable QV4::IdentifierHash propertyNameCache; + const QV4::IdentifierHash &propertyNames() const; + QV4::IdentifierHash &detachedPropertyNames(); // Context object QObject *contextObject; -- cgit v1.2.3 From ecb52e7991abe8d880f74f65dcdd92d7fde715d5 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 10 Jan 2018 15:39:53 +0100 Subject: Constify QObject* argument to QQmlData::wasDeleted() Because it doesn't hurt and it makes it easier to use it in QObjectWrapper::query(). Change-Id: I727ce4b862fa34866513cbb80a221a8a3aeca363 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmldata_p.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h index 63994a392d..4848f48766 100644 --- a/src/qml/qml/qqmldata_p.h +++ b/src/qml/qml/qqmldata_p.h @@ -259,7 +259,7 @@ public: bool hasExtendedData() const { return extendedData != 0; } QHash *attachedProperties() const; - static inline bool wasDeleted(QObject *); + static inline bool wasDeleted(const QObject *); static void markAsDeleted(QObject *); static void setQueuedForDeletion(QObject *); @@ -296,16 +296,16 @@ private: } }; -bool QQmlData::wasDeleted(QObject *object) +bool QQmlData::wasDeleted(const QObject *object) { if (!object) return true; - QObjectPrivate *priv = QObjectPrivate::get(object); + const QObjectPrivate *priv = QObjectPrivate::get(object); if (!priv || priv->wasDeleted) return true; - QQmlData *ddata = QQmlData::get(object); + const QQmlData *ddata = QQmlData::get(object); return ddata && ddata->isQueuedForDeletion; } -- cgit v1.2.3 From 4d6830546619d16275b01f1f049fdcb0b6489f7a Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Wed, 10 Jan 2018 15:59:07 +0100 Subject: Add setContextProperties() Setting all properties in one batch avoids unnecessary refreshing of expressions and is therefore a lot faster if there are many expressions in the context. In an example I created it takes 500ms to set 10 context properties using setContextProperty() and it takes about 150ms to set the context properties using setContextProperties. Change-Id: Ic7cf03cda292b316198f37f963b61a2388a288c9 Reviewed-by: Thomas Hartmann Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlcontext.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ src/qml/qml/qqmlcontext.h | 5 +++++ 2 files changed, 48 insertions(+) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp index a32ed6e998..9d2e37a2ab 100644 --- a/src/qml/qml/qqmlcontext.cpp +++ b/src/qml/qml/qqmlcontext.cpp @@ -329,6 +329,49 @@ void QQmlContext::setContextProperty(const QString &name, QObject *value) setContextProperty(name, QVariant::fromValue(value)); } +/*! + \since 5.11 + + Set a batch of \a properties on this context. + + Setting all properties in one batch avoids unnecessary + refreshing expressions, and is therefore recommended + instead of calling \l setContextProperty() for each individual property. + + \sa QQmlContext::setContextProperty() +*/ +void QQmlContext::setContextProperties(const QVector &properties) +{ + Q_D(const QQmlContext); + + QQmlContextData *data = d->data; + + QQmlJavaScriptExpression *expressions = data->expressions; + QQmlContextData *childContexts = data->childContexts; + + data->expressions = 0; + data->childContexts = 0; + + for (auto property : properties) + setContextProperty(property.name, property.value); + + data->expressions = expressions; + data->childContexts = childContexts; + + data->refreshExpressions(); +} + +/*! + \since 5.11 + + \class QQmlContext::PropertyPair + + This struct contains a property name and a property value. + It is used as a parameter for the \c setContextProperties function. + + \sa QQQmlContext::setContextProperties() +*/ + /*! Returns the value of the \a name property for this context as a QVariant. diff --git a/src/qml/qml/qqmlcontext.h b/src/qml/qml/qqmlcontext.h index b2b95b7573..506ae216b2 100644 --- a/src/qml/qml/qqmlcontext.h +++ b/src/qml/qml/qqmlcontext.h @@ -42,6 +42,8 @@ #include #include +#include +#include #include #include #include @@ -62,6 +64,8 @@ class Q_QML_EXPORT QQmlContext : public QObject Q_DECLARE_PRIVATE(QQmlContext) public: + struct PropertyPair { QString name; QVariant value; }; + QQmlContext(QQmlEngine *parent, QObject *objParent = nullptr); QQmlContext(QQmlContext *parent, QObject *objParent = nullptr); virtual ~QQmlContext(); @@ -77,6 +81,7 @@ public: QVariant contextProperty(const QString &) const; void setContextProperty(const QString &, QObject *); void setContextProperty(const QString &, const QVariant &); + void setContextProperties(const QVector &properties); // ### Qt 6: no need for a mutable object, this should become a const QObject pointer QString nameForObject(QObject *) const; -- cgit v1.2.3 From 4e1512baf6d1220c9e89c8a36f16de400bb1b519 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 5 Dec 2017 10:45:14 +0100 Subject: Convert more builtin functions to use the new calling convention Convert most of the methods used QML objects to the new calling convention. Converted IndexedBuiltinFunction to do the same. Change-Id: I41b26042c2f56f24988485b06e8ccd214e2573c0 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlcomponent.cpp | 34 ++++++++++++++++----------------- src/qml/qml/qqmldelayedcallqueue.cpp | 21 ++++++++++---------- src/qml/qml/qqmldelayedcallqueue_p.h | 4 ++-- src/qml/qml/qqmllistwrapper.cpp | 8 ++++---- src/qml/qml/qqmllistwrapper_p.h | 2 +- src/qml/qml/qqmlvaluetypewrapper.cpp | 15 +++++++-------- src/qml/qml/qqmlvaluetypewrapper_p.h | 2 +- src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 4 ++-- src/qml/qml/v8/qqmlbuiltinfunctions_p.h | 2 +- 9 files changed, 46 insertions(+), 46 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 5a03f2dd93..e3dc3be81e 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1111,11 +1111,11 @@ struct QmlIncubatorObject : public QV4::Object V4_OBJECT2(QmlIncubatorObject, Object) V4_NEEDS_DESTROY - static ReturnedValue method_get_statusChanged(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_set_statusChanged(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_get_status(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_get_object(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_forceCompletion(const BuiltinFunction *, CallData *callData); + static ReturnedValue method_get_statusChanged(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_set_statusChanged(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_status(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_object(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_forceCompletion(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); void statusChanged(QQmlIncubator::Status); void setInitialState(QObject *); @@ -1460,20 +1460,20 @@ QQmlComponentExtension::QQmlComponentExtension(QV4::ExecutionEngine *v4) incubationProto.set(v4, proto); } -QV4::ReturnedValue QV4::QmlIncubatorObject::method_get_object(const BuiltinFunction *b, CallData *callData) +QV4::ReturnedValue QV4::QmlIncubatorObject::method_get_object(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - QV4::Scoped o(scope, callData->thisObject.as()); + QV4::Scoped o(scope, thisObject->as()); if (!o) THROW_TYPE_ERROR(); return QV4::QObjectWrapper::wrap(scope.engine, o->d()->incubator->object()); } -QV4::ReturnedValue QV4::QmlIncubatorObject::method_forceCompletion(const BuiltinFunction *b, CallData *callData) +QV4::ReturnedValue QV4::QmlIncubatorObject::method_forceCompletion(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - QV4::Scoped o(scope, callData->thisObject.as()); + QV4::Scoped o(scope, thisObject->as()); if (!o) THROW_TYPE_ERROR(); @@ -1482,34 +1482,34 @@ QV4::ReturnedValue QV4::QmlIncubatorObject::method_forceCompletion(const Builtin RETURN_UNDEFINED(); } -QV4::ReturnedValue QV4::QmlIncubatorObject::method_get_status(const BuiltinFunction *b, CallData *callData) +QV4::ReturnedValue QV4::QmlIncubatorObject::method_get_status(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - QV4::Scoped o(scope, callData->thisObject.as()); + QV4::Scoped o(scope, thisObject->as()); if (!o) THROW_TYPE_ERROR(); return QV4::Encode(o->d()->incubator->status()); } -QV4::ReturnedValue QV4::QmlIncubatorObject::method_get_statusChanged(const BuiltinFunction *b, CallData *callData) +QV4::ReturnedValue QV4::QmlIncubatorObject::method_get_statusChanged(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - QV4::Scoped o(scope, callData->thisObject.as()); + QV4::Scoped o(scope, thisObject->as()); if (!o) THROW_TYPE_ERROR(); return QV4::Encode(o->d()->statusChanged); } -QV4::ReturnedValue QV4::QmlIncubatorObject::method_set_statusChanged(const BuiltinFunction *b, CallData *callData) +QV4::ReturnedValue QV4::QmlIncubatorObject::method_set_statusChanged(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { QV4::Scope scope(b); - QV4::Scoped o(scope, callData->thisObject.as()); - if (!o || callData->argc() < 1) + QV4::Scoped o(scope, thisObject->as()); + if (!o || argc < 1) THROW_TYPE_ERROR(); - o->d()->statusChanged.set(scope.engine, callData->args[0]); + o->d()->statusChanged.set(scope.engine, argv[0]); RETURN_UNDEFINED(); } diff --git a/src/qml/qml/qqmldelayedcallqueue.cpp b/src/qml/qml/qqmldelayedcallqueue.cpp index df4030e522..268f91c8ba 100644 --- a/src/qml/qml/qqmldelayedcallqueue.cpp +++ b/src/qml/qml/qqmldelayedcallqueue.cpp @@ -106,18 +106,19 @@ void QQmlDelayedCallQueue::init(QV4::ExecutionEngine* engine) m_tickedMethod = metaObject.method(methodIndex); } -QV4::ReturnedValue QQmlDelayedCallQueue::addUniquelyAndExecuteLater(const QV4::BuiltinFunction *b, QV4::CallData *callData) +QV4::ReturnedValue QQmlDelayedCallQueue::addUniquelyAndExecuteLater(const QV4::FunctionObject *b, const QV4::Value *, const QV4::Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() == 0) + if (argc == 0) THROW_GENERIC_ERROR("Qt.callLater: no arguments given"); - const QV4::FunctionObject *func = callData->args[0].as(); + const QV4::FunctionObject *func = argv[0].as(); if (!func) THROW_GENERIC_ERROR("Qt.callLater: first argument not a function or signal"); QPair functionData = QV4::QObjectMethod::extractQtMethod(func); + QV4::ReturnedValue arg0 = argc ? argv[0].asReturnedValue() : QV4::Encode::undefined(); QVector::Iterator iter; if (functionData.second != -1) { @@ -136,7 +137,7 @@ QV4::ReturnedValue QQmlDelayedCallQueue::addUniquelyAndExecuteLater(const QV4::B iter = m_delayedFunctionCalls.begin(); while (iter != m_delayedFunctionCalls.end()) { DelayedFunctionCall& dfc = *iter; - if (callData->argument(0) == dfc.m_function.value()) { + if (arg0 == dfc.m_function.value()) { break; // Already stored! } ++iter; @@ -149,7 +150,7 @@ QV4::ReturnedValue QQmlDelayedCallQueue::addUniquelyAndExecuteLater(const QV4::B m_delayedFunctionCalls.erase(iter); m_delayedFunctionCalls.append(dfc); } else { - m_delayedFunctionCalls.append(QV4::PersistentValue(m_engine, callData->argument(0))); + m_delayedFunctionCalls.append(QV4::PersistentValue(m_engine, arg0)); } DelayedFunctionCall& dfc = m_delayedFunctionCalls.last(); @@ -165,7 +166,7 @@ QV4::ReturnedValue QQmlDelayedCallQueue::addUniquelyAndExecuteLater(const QV4::B dfc.m_guarded = true; } } - storeAnyArguments(dfc, callData, 1, m_engine); + storeAnyArguments(dfc, argv, argc, 1, m_engine); if (!m_callbackOutstanding) { m_tickedMethod.invoke(this, Qt::QueuedConnection); @@ -174,9 +175,9 @@ QV4::ReturnedValue QQmlDelayedCallQueue::addUniquelyAndExecuteLater(const QV4::B return QV4::Encode::undefined(); } -void QQmlDelayedCallQueue::storeAnyArguments(DelayedFunctionCall &dfc, const QV4::CallData *callData, int offset, QV4::ExecutionEngine *engine) +void QQmlDelayedCallQueue::storeAnyArguments(DelayedFunctionCall &dfc, const QV4::Value *argv, int argc, int offset, QV4::ExecutionEngine *engine) { - const int length = callData->argc() - offset; + const int length = argc - offset; if (length == 0) { dfc.m_args.clear(); return; @@ -184,8 +185,8 @@ void QQmlDelayedCallQueue::storeAnyArguments(DelayedFunctionCall &dfc, const QV4 QV4::Scope scope(engine); QV4::ScopedArrayObject array(scope, engine->newArrayObject(length)); uint i = 0; - for (int j = offset, ej = callData->argc(); j < ej; ++i, ++j) - array->putIndexed(i, callData->args[j]); + for (int j = offset, ej = argc; j < ej; ++i, ++j) + array->putIndexed(i, argv[j]); dfc.m_args.set(engine, array); } diff --git a/src/qml/qml/qqmldelayedcallqueue_p.h b/src/qml/qml/qqmldelayedcallqueue_p.h index 5b3043cfed..b3d361581d 100644 --- a/src/qml/qml/qqmldelayedcallqueue_p.h +++ b/src/qml/qml/qqmldelayedcallqueue_p.h @@ -70,7 +70,7 @@ public: void init(QV4::ExecutionEngine *); - QV4::ReturnedValue addUniquelyAndExecuteLater(const QV4::BuiltinFunction *, QV4::CallData *callData); + QV4::ReturnedValue addUniquelyAndExecuteLater(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); public Q_SLOTS: void ticked(); @@ -90,7 +90,7 @@ private: bool m_guarded; }; - void storeAnyArguments(DelayedFunctionCall& dfc, const QV4::CallData *callData, int offset, QV4::ExecutionEngine *engine); + void storeAnyArguments(DelayedFunctionCall& dfc, const QV4::Value *argv, int argc, int offset, QV4::ExecutionEngine *engine); void executeAllExpired_Later(); QV4::ExecutionEngine *m_engine; diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp index b4be83a156..cdeb991e11 100644 --- a/src/qml/qml/qqmllistwrapper.cpp +++ b/src/qml/qml/qqmllistwrapper.cpp @@ -171,10 +171,10 @@ void PropertyListPrototype::init(ExecutionEngine *) defineDefaultProperty(QStringLiteral("push"), method_push, 1); } -ReturnedValue PropertyListPrototype::method_push(const BuiltinFunction *b, CallData *callData) +ReturnedValue PropertyListPrototype::method_push(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { Scope scope(b); - ScopedObject instance(scope, callData->thisObject.toObject(scope.engine)); + ScopedObject instance(scope, thisObject->toObject(scope.engine)); if (!instance) RETURN_UNDEFINED(); QmlListWrapper *w = instance->as(); @@ -184,9 +184,9 @@ ReturnedValue PropertyListPrototype::method_push(const BuiltinFunction *b, CallD THROW_GENERIC_ERROR("List doesn't define an Append function"); QV4::ScopedObject so(scope); - for (int i = 0, ei = callData->argc(); i < ei; ++i) + for (int i = 0, ei = argc; i < ei; ++i) { - so = callData->args[i].toObject(scope.engine); + so = argv[i].toObject(scope.engine); if (QV4::QObjectWrapper *wrapper = so->as()) w->d()->property().append(&w->d()->property(), wrapper->object() ); } diff --git a/src/qml/qml/qqmllistwrapper_p.h b/src/qml/qml/qqmllistwrapper_p.h index 0b53395d2b..e02831c8d1 100644 --- a/src/qml/qml/qqmllistwrapper_p.h +++ b/src/qml/qml/qqmllistwrapper_p.h @@ -103,7 +103,7 @@ struct PropertyListPrototype : Object { void init(ExecutionEngine *engine); - static ReturnedValue method_push(const BuiltinFunction *, CallData *callData); + static ReturnedValue method_push(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); }; } diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index 90ca08537c..d37065ce43 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -316,17 +316,16 @@ bool QQmlValueTypeWrapper::write(QObject *target, int propertyIndex) const return true; } -ReturnedValue QQmlValueTypeWrapper::method_toString(const BuiltinFunction *b, CallData *callData) +ReturnedValue QQmlValueTypeWrapper::method_toString(const FunctionObject *b, const Value *thisObject, const Value *, int) { - Scope scope(b); - Object *o = callData->thisObject.as(); + const Object *o = thisObject->as(); if (!o) - THROW_TYPE_ERROR(); - QQmlValueTypeWrapper *w = o->as(); + return b->engine()->throwTypeError(); + const QQmlValueTypeWrapper *w = o->as(); if (!w) - THROW_TYPE_ERROR(); + return b->engine()->throwTypeError(); - if (QQmlValueTypeReference *ref = w->as()) + if (const QQmlValueTypeReference *ref = w->as()) if (!ref->readReferenceValue()) RETURN_UNDEFINED(); @@ -351,7 +350,7 @@ ReturnedValue QQmlValueTypeWrapper::method_toString(const BuiltinFunction *b, Ca } result += QLatin1Char(')'); } - return Encode(scope.engine->newString(result)); + return Encode(b->engine()->newString(result)); } ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, String *name, bool *hasProperty) diff --git a/src/qml/qml/qqmlvaluetypewrapper_p.h b/src/qml/qml/qqmlvaluetypewrapper_p.h index da03af6dbc..f99d207d68 100644 --- a/src/qml/qml/qqmlvaluetypewrapper_p.h +++ b/src/qml/qml/qqmlvaluetypewrapper_p.h @@ -112,7 +112,7 @@ public: static PropertyAttributes query(const Managed *, String *name); static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes); - static ReturnedValue method_toString(const BuiltinFunction *, CallData *callData); + static ReturnedValue method_toString(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); static void initProto(ExecutionEngine *v4); }; diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 3627f29cb2..14245831a1 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -2098,10 +2098,10 @@ be passed on to the function invoked. Note that if redundant calls are eliminated, then only the last set of arguments will be passed to the function. */ -ReturnedValue QtObject::method_callLater(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_callLater(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { QV8Engine *v8engine = b->engine()->v8Engine; - return v8engine->delayedCallQueue()->addUniquelyAndExecuteLater(b, callData); + return v8engine->delayedCallQueue()->addUniquelyAndExecuteLater(b, thisObject, argv, argc); } QT_END_NAMESPACE diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h index 7d61aa0ada..5b7dc67e8c 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h +++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h @@ -131,7 +131,7 @@ struct QtObject : Object static ReturnedValue method_get_inputMethod(const BuiltinFunction *, CallData *callData); static ReturnedValue method_get_styleHints(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_callLater(const BuiltinFunction *, CallData *callData); + static ReturnedValue method_callLater(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); private: void addAll(); -- cgit v1.2.3 From 4a29f6881be30d34b2f171727eb13a08457c6d7b Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 5 Dec 2017 11:39:19 +0100 Subject: Convert QQmlLocale to the new builtin calling convention Change-Id: Iebe9f18d688d991346cbb52b3c939d31159b7fef Reviewed-by: Simon Hausmann --- src/qml/qml/qqmllocale.cpp | 284 ++++++++++++++++++++++----------------------- src/qml/qml/qqmllocale_p.h | 86 +++++++------- 2 files changed, 185 insertions(+), 185 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp index 3f2a373966..eafe2792c1 100644 --- a/src/qml/qml/qqmllocale.cpp +++ b/src/qml/qml/qqmllocale.cpp @@ -86,37 +86,37 @@ void QQmlDateExtension::registerExtension(QV4::ExecutionEngine *engine) engine->dateCtor()->defineDefaultProperty(QStringLiteral("timeZoneUpdated"), method_timeZoneUpdated); } -ReturnedValue QQmlDateExtension::method_toLocaleString(const BuiltinFunction *b, CallData *callData) +ReturnedValue QQmlDateExtension::method_toLocaleString(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { Scope scope(b); - if (callData->argc() > 2) - return QV4::DatePrototype::method_toLocaleString(b, &callData->thisObject, callData->args, callData->argc()); + if (argc > 2) + return QV4::DatePrototype::method_toLocaleString(b, thisObject, argv, argc); - QV4::DateObject *date = callData->thisObject.as(); + const QV4::DateObject *date = thisObject->as(); if (!date) - return QV4::DatePrototype::method_toLocaleString(b, &callData->thisObject, callData->args, callData->argc()); + return QV4::DatePrototype::method_toLocaleString(b, thisObject, argv, argc); QDateTime dt = date->toQDateTime(); - if (callData->argc() == 0) { + if (argc == 0) { // Use QLocale for standard toLocaleString() function QLocale locale; RETURN_RESULT(scope.engine->newString(locale.toString(dt))); } - if (!isLocaleObject(callData->args[0])) - return QV4::DatePrototype::method_toLocaleString(b, &callData->thisObject, callData->args, callData->argc()); // Use the default Date toLocaleString() + if (!isLocaleObject(argv[0])) + return QV4::DatePrototype::method_toLocaleString(b, thisObject, argv, argc); // Use the default Date toLocaleString() - GET_LOCALE_DATA_RESOURCE(callData->args[0]); + GET_LOCALE_DATA_RESOURCE(argv[0]); QLocale::FormatType enumFormat = QLocale::LongFormat; QString formattedDt; - if (callData->argc() == 2) { - if (String *s = callData->args[1].stringValue()) { + if (argc == 2) { + if (String *s = argv[1].stringValue()) { QString format = s->toQString(); formattedDt = r->d()->locale->toString(dt, format); - } else if (callData->args[1].isNumber()) { - quint32 intFormat = callData->args[1].toNumber(); + } else if (argv[1].isNumber()) { + quint32 intFormat = argv[1].toNumber(); QLocale::FormatType format = QLocale::FormatType(intFormat); formattedDt = r->d()->locale->toString(dt, format); } else { @@ -129,38 +129,38 @@ ReturnedValue QQmlDateExtension::method_toLocaleString(const BuiltinFunction *b, RETURN_RESULT(scope.engine->newString(formattedDt)); } -ReturnedValue QQmlDateExtension::method_toLocaleTimeString(const BuiltinFunction *b, CallData *callData) +ReturnedValue QQmlDateExtension::method_toLocaleTimeString(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { Scope scope(b); - if (callData->argc() > 2) - return QV4::DatePrototype::method_toLocaleTimeString(b, &callData->thisObject, callData->args, callData->argc()); + if (argc > 2) + return QV4::DatePrototype::method_toLocaleTimeString(b, thisObject, argv, argc); - QV4::DateObject *date = callData->thisObject.as(); + const QV4::DateObject *date = thisObject->as(); if (!date) - return QV4::DatePrototype::method_toLocaleTimeString(b, &callData->thisObject, callData->args, callData->argc()); + return QV4::DatePrototype::method_toLocaleTimeString(b, thisObject, argv, argc); QDateTime dt = date->toQDateTime(); QTime time = dt.time(); - if (callData->argc() == 0) { + if (argc == 0) { // Use QLocale for standard toLocaleString() function QLocale locale; RETURN_RESULT(scope.engine->newString(locale.toString(time))); } - if (!isLocaleObject(callData->args[0])) - return QV4::DatePrototype::method_toLocaleTimeString(b, &callData->thisObject, callData->args, callData->argc()); // Use the default Date toLocaleTimeString() + if (!isLocaleObject(argv[0])) + return QV4::DatePrototype::method_toLocaleTimeString(b, thisObject, argv, argc); // Use the default Date toLocaleTimeString() - GET_LOCALE_DATA_RESOURCE(callData->args[0]); + GET_LOCALE_DATA_RESOURCE(argv[0]); QLocale::FormatType enumFormat = QLocale::LongFormat; QString formattedTime; - if (callData->argc() == 2) { - if (String *s = callData->args[1].stringValue()) { + if (argc == 2) { + if (String *s = argv[1].stringValue()) { QString format = s->toQString(); formattedTime = r->d()->locale->toString(time, format); - } else if (callData->args[1].isNumber()) { - quint32 intFormat = callData->args[1].toNumber(); + } else if (argv[1].isNumber()) { + quint32 intFormat = argv[1].toNumber(); QLocale::FormatType format = QLocale::FormatType(intFormat); formattedTime = r->d()->locale->toString(time, format); } else { @@ -173,38 +173,38 @@ ReturnedValue QQmlDateExtension::method_toLocaleTimeString(const BuiltinFunction RETURN_RESULT(scope.engine->newString(formattedTime)); } -ReturnedValue QQmlDateExtension::method_toLocaleDateString(const BuiltinFunction *b, CallData *callData) +ReturnedValue QQmlDateExtension::method_toLocaleDateString(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { Scope scope(b); - if (callData->argc() > 2) - return QV4::DatePrototype::method_toLocaleDateString(b, &callData->thisObject, callData->args, callData->argc()); + if (argc > 2) + return QV4::DatePrototype::method_toLocaleDateString(b, thisObject, argv, argc); - QV4::DateObject *dateObj = callData->thisObject.as(); + const QV4::DateObject *dateObj = thisObject->as(); if (!dateObj) - return QV4::DatePrototype::method_toLocaleDateString(b, &callData->thisObject, callData->args, callData->argc()); + return QV4::DatePrototype::method_toLocaleDateString(b, thisObject, argv, argc); QDateTime dt = dateObj->toQDateTime(); QDate date = dt.date(); - if (callData->argc() == 0) { + if (argc == 0) { // Use QLocale for standard toLocaleString() function QLocale locale; RETURN_RESULT(scope.engine->newString(locale.toString(date))); } - if (!isLocaleObject(callData->args[0])) - return QV4::DatePrototype::method_toLocaleDateString(b, &callData->thisObject, callData->args, callData->argc()); // Use the default Date toLocaleDateString() + if (!isLocaleObject(argv[0])) + return QV4::DatePrototype::method_toLocaleDateString(b, thisObject, argv, argc); // Use the default Date toLocaleDateString() - GET_LOCALE_DATA_RESOURCE(callData->args[0]); + GET_LOCALE_DATA_RESOURCE(argv[0]); QLocale::FormatType enumFormat = QLocale::LongFormat; QString formattedDate; - if (callData->argc() == 2) { - if (String *s = callData->args[1].stringValue()) { + if (argc == 2) { + if (String *s = argv[1].stringValue()) { QString format = s->toQString(); formattedDate = r->d()->locale->toString(date, format); - } else if (callData->args[1].isNumber()) { - quint32 intFormat = callData->args[1].toNumber(); + } else if (argv[1].isNumber()) { + quint32 intFormat = argv[1].toNumber(); QLocale::FormatType format = QLocale::FormatType(intFormat); formattedDate = r->d()->locale->toString(date, format); } else { @@ -217,12 +217,12 @@ ReturnedValue QQmlDateExtension::method_toLocaleDateString(const BuiltinFunction RETURN_RESULT(scope.engine->newString(formattedDate)); } -ReturnedValue QQmlDateExtension::method_fromLocaleString(const BuiltinFunction *b, CallData *callData) +ReturnedValue QQmlDateExtension::method_fromLocaleString(const QV4::FunctionObject *b, const QV4::Value *, const QV4::Value *argv, int argc) { QV4::Scope scope(b); QV4::ExecutionEngine * const engine = scope.engine; - if (callData->argc() == 1) { - if (String *s = callData->args[0].stringValue()) { + if (argc == 1) { + if (String *s = argv[0].stringValue()) { QLocale locale; QString dateString = s->toQString(); QDateTime dt = locale.toDateTime(dateString); @@ -230,20 +230,20 @@ ReturnedValue QQmlDateExtension::method_fromLocaleString(const BuiltinFunction * } } - if (callData->argc() < 1 || callData->argc() > 3 || !isLocaleObject(callData->args[0])) + if (argc < 1 || argc > 3 || !isLocaleObject(argv[0])) THROW_ERROR("Locale: Date.fromLocaleString(): Invalid arguments"); - GET_LOCALE_DATA_RESOURCE(callData->args[0]); + GET_LOCALE_DATA_RESOURCE(argv[0]); QLocale::FormatType enumFormat = QLocale::LongFormat; QDateTime dt; - QString dateString = callData->args[1].toQStringNoThrow(); - if (callData->argc() == 3) { - if (String *s = callData->args[2].stringValue()) { + QString dateString = argv[1].toQStringNoThrow(); + if (argc == 3) { + if (String *s = argv[2].stringValue()) { QString format = s->toQString(); dt = r->d()->locale->toDateTime(dateString, format); - } else if (callData->args[2].isNumber()) { - quint32 intFormat = callData->args[2].toNumber(); + } else if (argv[2].isNumber()) { + quint32 intFormat = argv[2].toNumber(); QLocale::FormatType format = QLocale::FormatType(intFormat); dt = r->d()->locale->toDateTime(dateString, format); } else { @@ -256,13 +256,13 @@ ReturnedValue QQmlDateExtension::method_fromLocaleString(const BuiltinFunction * RETURN_RESULT(engine->newDateObject(dt)); } -ReturnedValue QQmlDateExtension::method_fromLocaleTimeString(const BuiltinFunction *b, CallData *callData) +ReturnedValue QQmlDateExtension::method_fromLocaleTimeString(const QV4::FunctionObject *b, const QV4::Value *, const QV4::Value *argv, int argc) { QV4::Scope scope(b); QV4::ExecutionEngine * const engine = scope.engine; - if (callData->argc() == 1) { - if (String *s = callData->args[0].stringValue()) { + if (argc == 1) { + if (String *s = argv[0].stringValue()) { QLocale locale; QString timeString = s->toQString(); QTime time = locale.toTime(timeString); @@ -272,20 +272,20 @@ ReturnedValue QQmlDateExtension::method_fromLocaleTimeString(const BuiltinFuncti } } - if (callData->argc() < 1 || callData->argc() > 3 || !isLocaleObject(callData->args[0])) + if (argc < 1 || argc > 3 || !isLocaleObject(argv[0])) THROW_ERROR("Locale: Date.fromLocaleTimeString(): Invalid arguments"); - GET_LOCALE_DATA_RESOURCE(callData->args[0]); + GET_LOCALE_DATA_RESOURCE(argv[0]); QLocale::FormatType enumFormat = QLocale::LongFormat; QTime tm; - QString dateString = callData->args[1].toQStringNoThrow(); - if (callData->argc() == 3) { - if (String *s = callData->args[2].stringValue()) { + QString dateString = argv[1].toQStringNoThrow(); + if (argc == 3) { + if (String *s = argv[2].stringValue()) { QString format = s->toQString(); tm = r->d()->locale->toTime(dateString, format); - } else if (callData->args[2].isNumber()) { - quint32 intFormat = callData->args[2].toNumber(); + } else if (argv[2].isNumber()) { + quint32 intFormat = argv[2].toNumber(); QLocale::FormatType format = QLocale::FormatType(intFormat); tm = r->d()->locale->toTime(dateString, format); } else { @@ -304,13 +304,13 @@ ReturnedValue QQmlDateExtension::method_fromLocaleTimeString(const BuiltinFuncti RETURN_RESULT(engine->newDateObject(dt)); } -ReturnedValue QQmlDateExtension::method_fromLocaleDateString(const BuiltinFunction *b, CallData *callData) +ReturnedValue QQmlDateExtension::method_fromLocaleDateString(const QV4::FunctionObject *b, const QV4::Value *, const QV4::Value *argv, int argc) { QV4::Scope scope(b); QV4::ExecutionEngine * const engine = scope.engine; - if (callData->argc() == 1) { - if (String *s = callData->args[0].stringValue()) { + if (argc == 1) { + if (String *s = argv[0].stringValue()) { QLocale locale; QString dateString = s->toQString(); QDate date = locale.toDate(dateString); @@ -318,20 +318,20 @@ ReturnedValue QQmlDateExtension::method_fromLocaleDateString(const BuiltinFuncti } } - if (callData->argc() < 1 || callData->argc() > 3 || !isLocaleObject(callData->args[0])) + if (argc < 1 || argc > 3 || !isLocaleObject(argv[0])) THROW_ERROR("Locale: Date.fromLocaleDateString(): Invalid arguments"); - GET_LOCALE_DATA_RESOURCE(callData->args[0]); + GET_LOCALE_DATA_RESOURCE(argv[0]); QLocale::FormatType enumFormat = QLocale::LongFormat; QDate dt; - QString dateString = callData->args[1].toQStringNoThrow(); - if (callData->argc() == 3) { - if (String *s = callData->args[2].stringValue()) { + QString dateString = argv[1].toQStringNoThrow(); + if (argc == 3) { + if (String *s = argv[2].stringValue()) { QString format = s->toQString(); dt = r->d()->locale->toDate(dateString, format); - } else if (callData->args[2].isNumber()) { - quint32 intFormat = callData->args[2].toNumber(); + } else if (argv[2].isNumber()) { + quint32 intFormat = argv[2].toNumber(); QLocale::FormatType format = QLocale::FormatType(intFormat); dt = r->d()->locale->toDate(dateString, format); } else { @@ -344,10 +344,10 @@ ReturnedValue QQmlDateExtension::method_fromLocaleDateString(const BuiltinFuncti RETURN_RESULT(engine->newDateObject(QDateTime(dt))); } -ReturnedValue QQmlDateExtension::method_timeZoneUpdated(const BuiltinFunction *b, CallData *callData) +ReturnedValue QQmlDateExtension::method_timeZoneUpdated(const QV4::FunctionObject *b, const QV4::Value *, const QV4::Value *, int argc) { QV4::Scope scope(b); - if (callData->argc() != 0) + if (argc != 0) THROW_ERROR("Locale: Date.timeZoneUpdated(): Invalid arguments"); QV4::DatePrototype::timezoneUpdated(); @@ -365,92 +365,92 @@ void QQmlNumberExtension::registerExtension(QV4::ExecutionEngine *engine) engine->numberCtor()->defineDefaultProperty(QStringLiteral("fromLocaleString"), method_fromLocaleString); } -QV4::ReturnedValue QQmlNumberExtension::method_toLocaleString(const BuiltinFunction *b, CallData *callData) +QV4::ReturnedValue QQmlNumberExtension::method_toLocaleString(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() > 3) + if (argc > 3) THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments"); - double number = callData->thisObject.toNumber(); + double number = thisObject->toNumber(); - if (callData->argc() == 0) { + if (argc == 0) { // Use QLocale for standard toLocaleString() function QLocale locale; RETURN_RESULT(scope.engine->newString(locale.toString(number))); } - if (!isLocaleObject(callData->args[0])) - return QV4::NumberPrototype::method_toLocaleString(b, &callData->thisObject, callData->args, callData->argc()); // Use the default Number toLocaleString() + if (!isLocaleObject(argv[0])) + return QV4::NumberPrototype::method_toLocaleString(b, thisObject, argv, argc); // Use the default Number toLocaleString() - GET_LOCALE_DATA_RESOURCE(callData->args[0]); + GET_LOCALE_DATA_RESOURCE(argv[0]); quint16 format = 'f'; - if (callData->argc() > 1) { - if (!callData->args[1].isString()) + if (argc > 1) { + if (!argv[1].isString()) THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments"); - QString fs = callData->args[1].toQString(); + QString fs = argv[1].toQString(); if (fs.length()) format = fs.at(0).unicode(); } int prec = 2; - if (callData->argc() > 2) { - if (!callData->args[2].isNumber()) + if (argc > 2) { + if (!argv[2].isNumber()) THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments"); - prec = callData->args[2].toInt32(); + prec = argv[2].toInt32(); } RETURN_RESULT(scope.engine->newString(r->d()->locale->toString(number, (char)format, prec))); } -ReturnedValue QQmlNumberExtension::method_toLocaleCurrencyString(const BuiltinFunction *b, CallData *callData) +ReturnedValue QQmlNumberExtension::method_toLocaleCurrencyString(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() > 2) + if (argc > 2) THROW_ERROR("Locale: Number.toLocaleCurrencyString(): Invalid arguments"); - double number = callData->thisObject.toNumber(); + double number = thisObject->toNumber(); - if (callData->argc() == 0) { + if (argc == 0) { // Use QLocale for standard toLocaleString() function QLocale locale; RETURN_RESULT(scope.engine->newString(locale.toString(number))); } - if (!isLocaleObject(callData->args[0])) + if (!isLocaleObject(argv[0])) THROW_ERROR("Locale: Number.toLocaleCurrencyString(): Invalid arguments"); - GET_LOCALE_DATA_RESOURCE(callData->args[0]); + GET_LOCALE_DATA_RESOURCE(argv[0]); QString symbol; - if (callData->argc() > 1) { - if (!callData->args[1].isString()) + if (argc > 1) { + if (!argv[1].isString()) THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments"); - symbol = callData->args[1].toQStringNoThrow(); + symbol = argv[1].toQStringNoThrow(); } RETURN_RESULT(scope.engine->newString(r->d()->locale->toCurrencyString(number, symbol))); } -ReturnedValue QQmlNumberExtension::method_fromLocaleString(const BuiltinFunction *b, CallData *callData) +ReturnedValue QQmlNumberExtension::method_fromLocaleString(const QV4::FunctionObject *b, const QV4::Value *, const QV4::Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() < 1 || callData->argc() > 2) + if (argc < 1 || argc > 2) THROW_ERROR("Locale: Number.fromLocaleString(): Invalid arguments"); int numberIdx = 0; QLocale locale; - if (callData->argc() == 2) { - if (!isLocaleObject(callData->args[0])) + if (argc == 2) { + if (!isLocaleObject(argv[0])) THROW_ERROR("Locale: Number.fromLocaleString(): Invalid arguments"); - GET_LOCALE_DATA_RESOURCE(callData->args[0]); + GET_LOCALE_DATA_RESOURCE(argv[0]); locale = *r->d()->locale; numberIdx = 1; } - QString ns = callData->args[numberIdx].toQString(); + QString ns = argv[numberIdx].toQString(); if (!ns.length()) RETURN_RESULT(QV4::Encode(Q_QNAN)); @@ -466,10 +466,10 @@ ReturnedValue QQmlNumberExtension::method_fromLocaleString(const BuiltinFunction //-------------- // Locale object -ReturnedValue QQmlLocaleData::method_get_firstDayOfWeek(const BuiltinFunction *b, CallData *callData) +ReturnedValue QQmlLocaleData::method_get_firstDayOfWeek(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) { QV4::Scope scope(b); - QLocale *locale = getThisLocale(scope, callData); + const QLocale *locale = getThisLocale(scope, thisObject); if (!locale) return Encode::undefined(); int fdow = int(locale->firstDayOfWeek()); @@ -478,29 +478,29 @@ ReturnedValue QQmlLocaleData::method_get_firstDayOfWeek(const BuiltinFunction *b RETURN_RESULT(fdow); } -ReturnedValue QQmlLocaleData::method_get_measurementSystem(const BuiltinFunction *b, CallData *callData) +ReturnedValue QQmlLocaleData::method_get_measurementSystem(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) { QV4::Scope scope(b); - QLocale *locale = getThisLocale(scope, callData); + const QLocale *locale = getThisLocale(scope, thisObject); if (!locale) return Encode::undefined(); return QV4::Encode(locale->measurementSystem()); } -ReturnedValue QQmlLocaleData::method_get_textDirection(const BuiltinFunction *b, CallData *callData) +ReturnedValue QQmlLocaleData::method_get_textDirection(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) { QV4::Scope scope(b); - QLocale *locale = getThisLocale(scope, callData); + const QLocale *locale = getThisLocale(scope, thisObject); if (!locale) return Encode::undefined(); return QV4::Encode(locale->textDirection()); } -ReturnedValue QQmlLocaleData::method_get_weekDays(const BuiltinFunction *b, CallData *callData) +ReturnedValue QQmlLocaleData::method_get_weekDays(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) { QV4::Scope scope(b); - QLocale *locale = getThisLocale(scope, callData); + const QLocale *locale = getThisLocale(scope, thisObject); if (!locale) return Encode::undefined(); @@ -519,10 +519,10 @@ ReturnedValue QQmlLocaleData::method_get_weekDays(const BuiltinFunction *b, Call return result.asReturnedValue(); } -ReturnedValue QQmlLocaleData::method_get_uiLanguages(const BuiltinFunction *b, CallData *callData) +ReturnedValue QQmlLocaleData::method_get_uiLanguages(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) { QV4::Scope scope(b); - QLocale *locale = getThisLocale(scope, callData); + const QLocale *locale = getThisLocale(scope, thisObject); if (!locale) return Encode::undefined(); @@ -538,19 +538,19 @@ ReturnedValue QQmlLocaleData::method_get_uiLanguages(const BuiltinFunction *b, C return result.asReturnedValue(); } -ReturnedValue QQmlLocaleData::method_currencySymbol(const BuiltinFunction *b, CallData *callData) +ReturnedValue QQmlLocaleData::method_currencySymbol(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { QV4::Scope scope(b); - QLocale *locale = getThisLocale(scope, callData); + const QLocale *locale = getThisLocale(scope, thisObject); if (!locale) return Encode::undefined(); - if (callData->argc() > 1) + if (argc > 1) THROW_ERROR("Locale: currencySymbol(): Invalid arguments"); QLocale::CurrencySymbolFormat format = QLocale::CurrencySymbol; - if (callData->argc() == 1) { - quint32 intFormat = callData->args[0].toNumber(); + if (argc == 1) { + quint32 intFormat = argv[0].toNumber(); format = QLocale::CurrencySymbolFormat(intFormat); } @@ -558,16 +558,16 @@ ReturnedValue QQmlLocaleData::method_currencySymbol(const BuiltinFunction *b, Ca } #define LOCALE_FORMAT(FUNC) \ -ReturnedValue QQmlLocaleData::method_ ##FUNC (const BuiltinFunction *b, CallData *callData) { \ +ReturnedValue QQmlLocaleData::method_ ##FUNC (const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { \ QV4::Scope scope(b); \ - QLocale *locale = getThisLocale(scope, callData); \ + const QLocale *locale = getThisLocale(scope, thisObject); \ if (!locale) \ return Encode::undefined(); \ - if (callData->argc() > 1) \ + if (argc > 1) \ THROW_ERROR("Locale: " #FUNC "(): Invalid arguments"); \ QLocale::FormatType format = QLocale::LongFormat;\ - if (callData->argc() == 1) { \ - quint32 intFormat = callData->args[0].toUInt32(); \ + if (argc == 1) { \ + quint32 intFormat = argv[0].toUInt32(); \ format = QLocale::FormatType(intFormat); \ } \ RETURN_RESULT(scope.engine->newString(locale-> FUNC (format))); \ @@ -579,21 +579,21 @@ LOCALE_FORMAT(dateFormat) // +1 added to idx because JS is 0-based, whereas QLocale months begin at 1. #define LOCALE_FORMATTED_MONTHNAME(VARIABLE) \ -ReturnedValue QQmlLocaleData::method_ ## VARIABLE (const BuiltinFunction *b, CallData *callData) {\ +ReturnedValue QQmlLocaleData::method_ ## VARIABLE (const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) {\ Scope scope(b); \ - QLocale *locale = getThisLocale(scope, callData); \ + const QLocale *locale = getThisLocale(scope, thisObject); \ if (!locale) \ return Encode::undefined(); \ - if (callData->argc() < 1 || callData->argc() > 2) \ + if (argc < 1 || argc > 2) \ THROW_ERROR("Locale: " #VARIABLE "(): Invalid arguments"); \ QLocale::FormatType enumFormat = QLocale::LongFormat; \ - int idx = callData->args[0].toInt32() + 1; \ + int idx = argv[0].toInt32() + 1; \ if (idx < 1 || idx > 12) \ THROW_ERROR("Locale: Invalid month"); \ QString name; \ - if (callData->argc() == 2) { \ - if (callData->args[1].isNumber()) { \ - quint32 intFormat = callData->args[1].toUInt32(); \ + if (argc == 2) { \ + if (argv[1].isNumber()) { \ + quint32 intFormat = argv[1].toUInt32(); \ QLocale::FormatType format = QLocale::FormatType(intFormat); \ name = locale-> VARIABLE(idx, format); \ } else { \ @@ -607,22 +607,22 @@ ReturnedValue QQmlLocaleData::method_ ## VARIABLE (const BuiltinFunction *b, Cal // 0 -> 7 as Qt::Sunday is 7, but Sunday is 0 in JS Date #define LOCALE_FORMATTED_DAYNAME(VARIABLE) \ -ReturnedValue QQmlLocaleData::method_ ## VARIABLE (const BuiltinFunction *b, CallData *callData) {\ +ReturnedValue QQmlLocaleData::method_ ## VARIABLE (const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) {\ Scope scope(b); \ - QLocale *locale = getThisLocale(scope, callData); \ + const QLocale *locale = getThisLocale(scope, thisObject); \ if (!locale) \ return Encode::undefined(); \ - if (callData->argc() < 1 || callData->argc() > 2) \ + if (argc < 1 || argc > 2) \ THROW_ERROR("Locale: " #VARIABLE "(): Invalid arguments"); \ QLocale::FormatType enumFormat = QLocale::LongFormat; \ - int idx = callData->args[0].toInt32(); \ + int idx = argv[0].toInt32(); \ if (idx < 0 || idx > 7) \ THROW_ERROR("Locale: Invalid day"); \ if (idx == 0) idx = 7; \ QString name; \ - if (callData->argc() == 2) { \ - if (callData->args[1].isNumber()) { \ - quint32 intFormat = callData->args[1].toUInt32(); \ + if (argc == 2) { \ + if (argv[1].isNumber()) { \ + quint32 intFormat = argv[1].toUInt32(); \ QLocale::FormatType format = QLocale::FormatType(intFormat); \ name = locale-> VARIABLE(idx, format); \ } else { \ @@ -640,10 +640,10 @@ LOCALE_FORMATTED_DAYNAME(dayName) LOCALE_FORMATTED_DAYNAME(standaloneDayName) #define LOCALE_STRING_PROPERTY(VARIABLE) \ -ReturnedValue QQmlLocaleData::method_get_ ## VARIABLE (const BuiltinFunction *b, CallData *callData) \ +ReturnedValue QQmlLocaleData::method_get_ ## VARIABLE (const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) \ { \ Scope scope(b); \ - QLocale *locale = getThisLocale(scope, callData); \ + const QLocale *locale = getThisLocale(scope, thisObject); \ if (!locale) \ return Encode::undefined(); \ RETURN_RESULT(scope.engine->newString(locale-> VARIABLE()));\ @@ -837,16 +837,16 @@ void QQmlLocale::registerStringLocaleCompare(QV4::ExecutionEngine *engine) engine->stringPrototype()->defineDefaultProperty(QStringLiteral("localeCompare"), method_localeCompare); } -ReturnedValue QQmlLocale::method_localeCompare(const BuiltinFunction *b, CallData *callData) +ReturnedValue QQmlLocale::method_localeCompare(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { - if (callData->argc() != 1 || (!callData->args[0].isString() && !callData->args[0].as())) - return QV4::StringPrototype::method_localeCompare(b, &callData->thisObject, callData->args, callData->argc()); + if (argc != 1 || (!argv[0].isString() && !argv[0].as())) + return QV4::StringPrototype::method_localeCompare(b, thisObject, argv, argc); - if (!callData->thisObject.isString() && !callData->thisObject.as()) - return QV4::StringPrototype::method_localeCompare(b, &callData->thisObject, callData->args, callData->argc()); + if (!thisObject->isString() && !thisObject->as()) + return QV4::StringPrototype::method_localeCompare(b, thisObject, argv, argc); - QString thisString = callData->thisObject.toQStringNoThrow(); - QString thatString = callData->args[0].toQStringNoThrow(); + QString thisString = thisObject->toQStringNoThrow(); + QString thatString = argv[0].toQStringNoThrow(); return QV4::Encode(QString::localeAwareCompare(thisString, thatString)); } diff --git a/src/qml/qml/qqmllocale_p.h b/src/qml/qml/qqmllocale_p.h index a81fe07b8e..57666c64f1 100644 --- a/src/qml/qml/qqmllocale_p.h +++ b/src/qml/qml/qqmllocale_p.h @@ -67,13 +67,13 @@ public: static void registerExtension(QV4::ExecutionEngine *engine); private: - static QV4::ReturnedValue method_toLocaleString(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_toLocaleTimeString(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_toLocaleDateString(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_fromLocaleString(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_fromLocaleTimeString(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_fromLocaleDateString(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_timeZoneUpdated(const QV4::BuiltinFunction *, QV4::CallData *callData); + static QV4::ReturnedValue method_toLocaleString(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_toLocaleTimeString(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_toLocaleDateString(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_fromLocaleString(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_fromLocaleTimeString(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_fromLocaleDateString(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_timeZoneUpdated(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); }; @@ -83,9 +83,9 @@ public: static void registerExtension(QV4::ExecutionEngine *engine); private: - static QV4::ReturnedValue method_toLocaleString(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_fromLocaleString(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_toLocaleCurrencyString(const QV4::BuiltinFunction *, QV4::CallData *callData); + static QV4::ReturnedValue method_toLocaleString(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_fromLocaleString(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_toLocaleCurrencyString(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); }; @@ -135,7 +135,7 @@ public: private: QQmlLocale(); - static QV4::ReturnedValue method_localeCompare(const QV4::BuiltinFunction *, QV4::CallData *callData); + static QV4::ReturnedValue method_localeCompare(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); }; namespace QV4 { @@ -158,43 +158,43 @@ struct QQmlLocaleData : public QV4::Object V4_OBJECT2(QQmlLocaleData, Object) V4_NEEDS_DESTROY - static QLocale *getThisLocale(QV4::Scope &scope, QV4::CallData *callData) { - QV4::Object *o = callData->thisObject.as(); - QQmlLocaleData *thisObject = o ? o->as() : 0; - if (!thisObject) { + static QLocale *getThisLocale(QV4::Scope &scope, const QV4::Value *thisObject) { + const QV4::Object *o = thisObject->as(); + const QQmlLocaleData *data = o ? o->as() : nullptr; + if (!data) { scope.engine->throwTypeError(); return 0; } - return thisObject->d()->locale; + return data->d()->locale; } - static QV4::ReturnedValue method_currencySymbol(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_dateTimeFormat(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_timeFormat(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_dateFormat(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_monthName(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_standaloneMonthName(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_dayName(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_standaloneDayName(const QV4::BuiltinFunction *, QV4::CallData *callData); - - static QV4::ReturnedValue method_get_firstDayOfWeek(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_get_measurementSystem(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_get_textDirection(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_get_weekDays(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_get_uiLanguages(const QV4::BuiltinFunction *, QV4::CallData *callData); - - static QV4::ReturnedValue method_get_name(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_get_nativeLanguageName(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_get_nativeCountryName(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_get_decimalPoint(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_get_groupSeparator(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_get_percent(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_get_zeroDigit(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_get_negativeSign(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_get_positiveSign(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_get_exponential(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_get_amText(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue method_get_pmText(const QV4::BuiltinFunction *, QV4::CallData *callData); + static QV4::ReturnedValue method_currencySymbol(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_dateTimeFormat(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_timeFormat(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_dateFormat(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_monthName(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_standaloneMonthName(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_dayName(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_standaloneDayName(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + + static QV4::ReturnedValue method_get_firstDayOfWeek(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_get_measurementSystem(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_get_textDirection(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_get_weekDays(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_get_uiLanguages(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + + static QV4::ReturnedValue method_get_name(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_get_nativeLanguageName(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_get_nativeCountryName(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_get_decimalPoint(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_get_groupSeparator(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_get_percent(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_get_zeroDigit(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_get_negativeSign(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_get_positiveSign(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_get_exponential(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_get_amText(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_get_pmText(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); }; } -- cgit v1.2.3 From 9643635f867b67e263d1c615965a93a1579f8b34 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 14 Sep 2017 14:38:36 +0200 Subject: Allow exported signal handlers for signals with revision Properties of QML objects or alias properties to QML objects have to know about the revision of the QML type. If the property is used as a grouped property and a signal or property is assigned. Without this patch this is not working with signals that have a revision. To get this working we store the minor version of the QML type in QQmlPropertyData and retrieve the QQmlPropertyCache with the correct AllowedRevisionCache using this minor version. Task-number: QTCREATORBUG-18820 Change-Id: I1e20169e0d5a2ae11059a951aa83a5c94106accb Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlengine.cpp | 8 ++++++-- src/qml/qml/qqmlengine_p.h | 2 +- src/qml/qml/qqmlpropertycache.cpp | 3 ++- src/qml/qml/qqmlpropertycache_p.h | 41 ++++++++++++++++++++++++++++++++------- 4 files changed, 43 insertions(+), 11 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index c47d8a0a81..a66bcaa9bd 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -2342,7 +2342,7 @@ QQmlPropertyCache *QQmlEnginePrivate::propertyCacheForType(int t) } } -QQmlPropertyCache *QQmlEnginePrivate::rawPropertyCacheForType(int t) +QQmlPropertyCache *QQmlEnginePrivate::rawPropertyCacheForType(int t, int minorVersion) { Locker locker(this); auto iter = m_compositeTypes.constFind(t); @@ -2351,7 +2351,11 @@ QQmlPropertyCache *QQmlEnginePrivate::rawPropertyCacheForType(int t) } else { QQmlType type = QQmlMetaType::qmlType(t); locker.unlock(); - return type.isValid() ? cache(type.baseMetaObject()) : 0; + + if (minorVersion >= 0) + return type.isValid() ? cache(type, minorVersion) : 0; + else + return type.isValid() ? cache(type.baseMetaObject()) : 0; } } diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h index 791660cac7..74e232fd84 100644 --- a/src/qml/qml/qqmlengine_p.h +++ b/src/qml/qml/qqmlengine_p.h @@ -220,7 +220,7 @@ public: QQmlMetaObject rawMetaObjectForType(int) const; QQmlMetaObject metaObjectForType(int) const; QQmlPropertyCache *propertyCacheForType(int); - QQmlPropertyCache *rawPropertyCacheForType(int); + QQmlPropertyCache *rawPropertyCacheForType(int, int minorVersion = -1); void registerInternalCompositeType(QV4::CompiledData::CompilationUnit *compilationUnit); void unregisterInternalCompositeType(QV4::CompiledData::CompilationUnit *compilationUnit); diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp index 7178dffa8b..bce81c1504 100644 --- a/src/qml/qml/qqmlpropertycache.cpp +++ b/src/qml/qml/qqmlpropertycache.cpp @@ -321,13 +321,14 @@ QQmlPropertyCache *QQmlPropertyCache::copyAndReserve(int propertyCount, int meth This is different from QMetaMethod::methodIndex(). */ void QQmlPropertyCache::appendProperty(const QString &name, QQmlPropertyData::Flags flags, - int coreIndex, int propType, int notifyIndex) + int coreIndex, int propType, int minorVersion, int notifyIndex) { QQmlPropertyData data; data.setPropType(propType); data.setCoreIndex(coreIndex); data.setNotifyIndex(notifyIndex); data.setFlags(flags); + data.setTypeMinorVersion(minorVersion); QQmlPropertyData *old = findNamedProperty(name); if (old) diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h index 6cdb82bd46..e032d4f4c7 100644 --- a/src/qml/qml/qqmlpropertycache_p.h +++ b/src/qml/qml/qqmlpropertycache_p.h @@ -218,12 +218,38 @@ public: _coreIndex = qint16(idx); } - int revision() const { return _revision; } - void setRevision(int rev) + quint8 revision() const { return _revision; } + void setRevision(quint8 rev) { - Q_ASSERT(rev >= std::numeric_limits::min()); - Q_ASSERT(rev <= std::numeric_limits::max()); - _revision = qint16(rev); + Q_ASSERT(rev >= std::numeric_limits::min()); + Q_ASSERT(rev <= std::numeric_limits::max()); + _revision = quint8(rev); + } + + /* If a property is a C++ type, then we store the minor + * version of this type. + * This is required to resolve property or signal revisions + * if this property is used as a grouped property. + * + * Test.qml + * property TextEdit someTextEdit: TextEdit {} + * + * Test { + * someTextEdit.preeditText: "test" //revision 7 + * someTextEdit.onEditingFinished: console.log("test") //revision 6 + * } + * + * To determine if these properties with revisions are available we need + * the minor version of TextEdit as imported in Test.qml. + * + */ + + quint8 typeMinorVersion() const { return _typeMinorVersion; } + void setTypeMinorVersion(quint8 rev) + { + Q_ASSERT(rev >= std::numeric_limits::min()); + Q_ASSERT(rev <= std::numeric_limits::max()); + _typeMinorVersion = quint8(rev); } QQmlPropertyCacheMethodArguments *arguments() const { return _arguments; } @@ -257,7 +283,8 @@ private: qint16 _notifyIndex; qint16 _overrideIndex; - qint16 _revision; + quint8 _revision; + quint8 _typeMinorVersion; qint16 _metaObjectOffset; QQmlPropertyCacheMethodArguments *_arguments; @@ -390,7 +417,7 @@ public: QQmlPropertyCache *copyAndReserve(int propertyCount, int methodCount, int signalCount, int enumCount); void appendProperty(const QString &, QQmlPropertyRawData::Flags flags, int coreIndex, - int propType, int notifyIndex); + int propType, int revision, int notifyIndex); void appendSignal(const QString &, QQmlPropertyRawData::Flags, int coreIndex, const int *types = 0, const QList &names = QList()); void appendMethod(const QString &, QQmlPropertyData::Flags flags, int coreIndex, -- cgit v1.2.3 From 1832d111226ad522a13225532256f0d8bf28b060 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 5 Dec 2017 11:59:01 +0100 Subject: Convert methods in qqmlbuiltinfunctions.* to new calling convention Change-Id: I8f289668b9321460778d2a431cb9c2af1f22eb93 Reviewed-by: Simon Hausmann --- src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 504 ++++++++++++++++---------------- src/qml/qml/v8/qqmlbuiltinfunctions_p.h | 114 ++++---- 2 files changed, 309 insertions(+), 309 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 14245831a1..f2b396ad00 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -228,12 +228,12 @@ void QtObject::advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint \qmlmethod bool Qt::isQtObject(object) Returns true if \c object is a valid reference to a Qt or QML object, otherwise false. */ -ReturnedValue QtObject::method_isQtObject(const BuiltinFunction *, CallData *callData) +ReturnedValue QtObject::method_isQtObject(const FunctionObject *, const Value *, const Value *argv, int argc) { - if (callData->argc() == 0) + if (argc == 0) RETURN_RESULT(QV4::Encode(false)); - return QV4::Encode(callData->args[0].as() != 0); + return QV4::Encode(argv[0].as() != 0); } /*! @@ -242,17 +242,16 @@ ReturnedValue QtObject::method_isQtObject(const BuiltinFunction *, CallData *cal Returns a color with the specified \c red, \c green, \c blue and \c alpha components. All components should be in the range 0-1 inclusive. */ -ReturnedValue QtObject::method_rgba(const BuiltinFunction *builtin, CallData *callData) +ReturnedValue QtObject::method_rgba(const FunctionObject *f, const Value *, const Value *argv, int argc) { - QV4::Scope scope(builtin); - int argCount = callData->argc(); - if (argCount < 3 || argCount > 4) + QV4::Scope scope(f); + if (argc < 3 || argc > 4) THROW_GENERIC_ERROR("Qt.rgba(): Invalid arguments"); - double r = callData->args[0].toNumber(); - double g = callData->args[1].toNumber(); - double b = callData->args[2].toNumber(); - double a = (argCount == 4) ? callData->args[3].toNumber() : 1; + double r = argv[0].toNumber(); + double g = argv[1].toNumber(); + double b = argv[2].toNumber(); + double a = (argc == 4) ? argv[3].toNumber() : 1; if (r < 0.0) r=0.0; if (r > 1.0) r=1.0; @@ -272,17 +271,17 @@ ReturnedValue QtObject::method_rgba(const BuiltinFunction *builtin, CallData *ca Returns a color with the specified \c hue, \c saturation, \c lightness and \c alpha components. All components should be in the range 0-1 inclusive. */ -ReturnedValue QtObject::method_hsla(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_hsla(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - int argCount = callData->argc(); + int argCount = argc; if (argCount < 3 || argCount > 4) THROW_GENERIC_ERROR("Qt.hsla(): Invalid arguments"); - double h = callData->args[0].toNumber(); - double s = callData->args[1].toNumber(); - double l = callData->args[2].toNumber(); - double a = (argCount == 4) ? callData->args[3].toNumber() : 1; + double h = argv[0].toNumber(); + double s = argv[1].toNumber(); + double l = argv[2].toNumber(); + double a = (argCount == 4) ? argv[3].toNumber() : 1; if (h < 0.0) h=0.0; if (h > 1.0) h=1.0; @@ -304,17 +303,17 @@ All components should be in the range 0-1 inclusive. \since 5.5 */ -ReturnedValue QtObject::method_hsva(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_hsva(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - int argCount = callData->argc(); + int argCount = argc; if (argCount < 3 || argCount > 4) THROW_GENERIC_ERROR("Qt.hsva(): Invalid arguments"); - double h = callData->args[0].toNumber(); - double s = callData->args[1].toNumber(); - double v = callData->args[2].toNumber(); - double a = (argCount == 4) ? callData->args[3].toNumber() : 1; + double h = argv[0].toNumber(); + double s = argv[1].toNumber(); + double v = argv[2].toNumber(); + double a = (argCount == 4) ? argv[3].toNumber() : 1; h = qBound(0.0, h, 1.0); s = qBound(0.0, s, 1.0); @@ -332,15 +331,15 @@ may be either color values or string values. If a string value is supplied it must be convertible to a color, as described for the \l{colorbasictypedocs}{color} basic type. */ -ReturnedValue QtObject::method_colorEqual(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_colorEqual(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() != 2) + if (argc != 2) THROW_GENERIC_ERROR("Qt.colorEqual(): Invalid arguments"); bool ok = false; - QVariant lhs = scope.engine->toVariant(callData->args[0], -1); + QVariant lhs = scope.engine->toVariant(argv[0], -1); if (lhs.userType() == QVariant::String) { lhs = QQmlStringConverters::colorFromString(lhs.toString(), &ok); if (!ok) { @@ -350,7 +349,7 @@ ReturnedValue QtObject::method_colorEqual(const BuiltinFunction *b, CallData *ca THROW_GENERIC_ERROR("Qt.colorEqual(): Invalid arguments"); } - QVariant rhs = scope.engine->toVariant(callData->args[1], -1); + QVariant rhs = scope.engine->toVariant(argv[1], -1); if (rhs.userType() == QVariant::String) { rhs = QQmlStringConverters::colorFromString(rhs.toString(), &ok); if (!ok) { @@ -371,16 +370,16 @@ Returns a \c rect with the top-left corner at \c x, \c y and the specified \c wi The returned object has \c x, \c y, \c width and \c height attributes with the given values. */ -ReturnedValue QtObject::method_rect(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_rect(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() != 4) + if (argc != 4) THROW_GENERIC_ERROR("Qt.rect(): Invalid arguments"); - double x = callData->args[0].toNumber(); - double y = callData->args[1].toNumber(); - double w = callData->args[2].toNumber(); - double h = callData->args[3].toNumber(); + double x = argv[0].toNumber(); + double y = argv[1].toNumber(); + double w = argv[2].toNumber(); + double h = argv[3].toNumber(); return scope.engine->fromVariant(QVariant::fromValue(QRectF(x, y, w, h))); } @@ -389,14 +388,14 @@ ReturnedValue QtObject::method_rect(const BuiltinFunction *b, CallData *callData \qmlmethod point Qt::point(int x, int y) Returns a Point with the specified \c x and \c y coordinates. */ -ReturnedValue QtObject::method_point(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_point(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() != 2) + if (argc != 2) THROW_GENERIC_ERROR("Qt.point(): Invalid arguments"); - double x = callData->args[0].toNumber(); - double y = callData->args[1].toNumber(); + double x = argv[0].toNumber(); + double y = argv[1].toNumber(); return scope.engine->fromVariant(QVariant::fromValue(QPointF(x, y))); } @@ -405,14 +404,14 @@ ReturnedValue QtObject::method_point(const BuiltinFunction *b, CallData *callDat \qmlmethod Qt::size(int width, int height) Returns a Size with the specified \c width and \c height. */ -ReturnedValue QtObject::method_size(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_size(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() != 2) + if (argc != 2) THROW_GENERIC_ERROR("Qt.size(): Invalid arguments"); - double w = callData->args[0].toNumber(); - double h = callData->args[1].toNumber(); + double w = argv[0].toNumber(); + double h = argv[1].toNumber(); return scope.engine->fromVariant(QVariant::fromValue(QSizeF(w, h))); } @@ -425,15 +424,15 @@ key-value pairs where valid keys are the \l{fontbasictypedocs}{font} type's subproperty names, and the values are valid values for each subproperty. Invalid keys will be ignored. */ -ReturnedValue QtObject::method_font(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_font(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() != 1 || !callData->args[0].isObject()) + if (argc != 1 || !argv[0].isObject()) THROW_GENERIC_ERROR("Qt.font(): Invalid arguments"); QV4::ExecutionEngine *v4 = scope.engine; bool ok = false; - QVariant v = QQml_valueTypeProvider()->createVariantFromJsObject(QMetaType::QFont, QQmlV4Handle(callData->args[0]), v4, &ok); + QVariant v = QQml_valueTypeProvider()->createVariantFromJsObject(QMetaType::QFont, QQmlV4Handle(argv[0]), v4, &ok); if (!ok) THROW_GENERIC_ERROR("Qt.font(): Invalid argument: no valid font subproperties specified"); return scope.engine->fromVariant(v); @@ -445,15 +444,15 @@ ReturnedValue QtObject::method_font(const BuiltinFunction *b, CallData *callData \qmlmethod Qt::vector2d(real x, real y) Returns a Vector2D with the specified \c x and \c y. */ -ReturnedValue QtObject::method_vector2d(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_vector2d(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() != 2) + if (argc != 2) THROW_GENERIC_ERROR("Qt.vector2d(): Invalid arguments"); float xy[3]; // qvector2d uses float internally - xy[0] = callData->args[0].toNumber(); - xy[1] = callData->args[1].toNumber(); + xy[0] = argv[0].toNumber(); + xy[1] = argv[1].toNumber(); const void *params[] = { xy }; return scope.engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QVector2D, 1, params)); @@ -463,16 +462,16 @@ ReturnedValue QtObject::method_vector2d(const BuiltinFunction *b, CallData *call \qmlmethod Qt::vector3d(real x, real y, real z) Returns a Vector3D with the specified \c x, \c y and \c z. */ -ReturnedValue QtObject::method_vector3d(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_vector3d(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() != 3) + if (argc != 3) THROW_GENERIC_ERROR("Qt.vector3d(): Invalid arguments"); float xyz[3]; // qvector3d uses float internally - xyz[0] = callData->args[0].toNumber(); - xyz[1] = callData->args[1].toNumber(); - xyz[2] = callData->args[2].toNumber(); + xyz[0] = argv[0].toNumber(); + xyz[1] = argv[1].toNumber(); + xyz[2] = argv[2].toNumber(); const void *params[] = { xyz }; return scope.engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QVector3D, 1, params)); @@ -482,17 +481,17 @@ ReturnedValue QtObject::method_vector3d(const BuiltinFunction *b, CallData *call \qmlmethod Qt::vector4d(real x, real y, real z, real w) Returns a Vector4D with the specified \c x, \c y, \c z and \c w. */ -ReturnedValue QtObject::method_vector4d(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_vector4d(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() != 4) + if (argc != 4) THROW_GENERIC_ERROR("Qt.vector4d(): Invalid arguments"); float xyzw[4]; // qvector4d uses float internally - xyzw[0] = callData->args[0].toNumber(); - xyzw[1] = callData->args[1].toNumber(); - xyzw[2] = callData->args[2].toNumber(); - xyzw[3] = callData->args[3].toNumber(); + xyzw[0] = argv[0].toNumber(); + xyzw[1] = argv[1].toNumber(); + xyzw[2] = argv[2].toNumber(); + xyzw[3] = argv[3].toNumber(); const void *params[] = { xyzw }; return scope.engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QVector4D, 1, params)); @@ -502,17 +501,17 @@ ReturnedValue QtObject::method_vector4d(const BuiltinFunction *b, CallData *call \qmlmethod Qt::quaternion(real scalar, real x, real y, real z) Returns a Quaternion with the specified \c scalar, \c x, \c y, and \c z. */ -ReturnedValue QtObject::method_quaternion(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_quaternion(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() != 4) + if (argc != 4) THROW_GENERIC_ERROR("Qt.quaternion(): Invalid arguments"); qreal sxyz[4]; // qquaternion uses qreal internally - sxyz[0] = callData->args[0].toNumber(); - sxyz[1] = callData->args[1].toNumber(); - sxyz[2] = callData->args[2].toNumber(); - sxyz[3] = callData->args[3].toNumber(); + sxyz[0] = argv[0].toNumber(); + sxyz[1] = argv[1].toNumber(); + sxyz[2] = argv[2].toNumber(); + sxyz[3] = argv[3].toNumber(); const void *params[] = { sxyz }; return scope.engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QQuaternion, 1, params)); @@ -527,42 +526,42 @@ matrix values. Finally, the function may be called with no arguments and the resulting matrix will be the identity matrix. */ -ReturnedValue QtObject::method_matrix4x4(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_matrix4x4(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() == 0) { + if (argc == 0) { return scope.engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QMatrix4x4, 0, nullptr)); } - if (callData->argc() == 1 && callData->args[0].isObject()) { + if (argc == 1 && argv[0].isObject()) { bool ok = false; - QVariant v = QQml_valueTypeProvider()->createVariantFromJsObject(QMetaType::QMatrix4x4, QQmlV4Handle(callData->args[0]), scope.engine, &ok); + QVariant v = QQml_valueTypeProvider()->createVariantFromJsObject(QMetaType::QMatrix4x4, QQmlV4Handle(argv[0]), scope.engine, &ok); if (!ok) THROW_GENERIC_ERROR("Qt.matrix4x4(): Invalid argument: not a valid matrix4x4 values array"); return scope.engine->fromVariant(v); } - if (callData->argc() != 16) + if (argc != 16) THROW_GENERIC_ERROR("Qt.matrix4x4(): Invalid arguments"); qreal vals[16]; // qmatrix4x4 uses qreal internally - vals[0] = callData->args[0].toNumber(); - vals[1] = callData->args[1].toNumber(); - vals[2] = callData->args[2].toNumber(); - vals[3] = callData->args[3].toNumber(); - vals[4] = callData->args[4].toNumber(); - vals[5] = callData->args[5].toNumber(); - vals[6] = callData->args[6].toNumber(); - vals[7] = callData->args[7].toNumber(); - vals[8] = callData->args[8].toNumber(); - vals[9] = callData->args[9].toNumber(); - vals[10] = callData->args[10].toNumber(); - vals[11] = callData->args[11].toNumber(); - vals[12] = callData->args[12].toNumber(); - vals[13] = callData->args[13].toNumber(); - vals[14] = callData->args[14].toNumber(); - vals[15] = callData->args[15].toNumber(); + vals[0] = argv[0].toNumber(); + vals[1] = argv[1].toNumber(); + vals[2] = argv[2].toNumber(); + vals[3] = argv[3].toNumber(); + vals[4] = argv[4].toNumber(); + vals[5] = argv[5].toNumber(); + vals[6] = argv[6].toNumber(); + vals[7] = argv[7].toNumber(); + vals[8] = argv[8].toNumber(); + vals[9] = argv[9].toNumber(); + vals[10] = argv[10].toNumber(); + vals[11] = argv[11].toNumber(); + vals[12] = argv[12].toNumber(); + vals[13] = argv[13].toNumber(); + vals[14] = argv[14].toNumber(); + vals[15] = argv[15].toNumber(); const void *params[] = { vals }; return scope.engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QMatrix4x4, 1, params)); @@ -582,13 +581,13 @@ by factor and converts the color back to RGB. If \c factor is not supplied, returns a color 50% lighter than \c baseColor (factor 1.5). */ -ReturnedValue QtObject::method_lighter(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_lighter(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() != 1 && callData->argc() != 2) + if (argc != 1 && argc != 2) THROW_GENERIC_ERROR("Qt.lighter(): Invalid arguments"); - QVariant v = scope.engine->toVariant(callData->args[0], -1); + QVariant v = scope.engine->toVariant(argv[0], -1); if (v.userType() == QVariant::String) { bool ok = false; v = QQmlStringConverters::colorFromString(v.toString(), &ok); @@ -600,8 +599,8 @@ ReturnedValue QtObject::method_lighter(const BuiltinFunction *b, CallData *callD } qreal factor = 1.5; - if (callData->argc() == 2) - factor = callData->args[1].toNumber(); + if (argc == 2) + factor = argv[1].toNumber(); return scope.engine->fromVariant(QQml_colorProvider()->lighter(v, factor)); } @@ -621,13 +620,13 @@ by factor and converts the color back to RGB. If \c factor is not supplied, returns a color 50% darker than \c baseColor (factor 2.0). */ -ReturnedValue QtObject::method_darker(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_darker(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() != 1 && callData->argc() != 2) + if (argc != 1 && argc != 2) THROW_GENERIC_ERROR("Qt.darker(): Invalid arguments"); - QVariant v = scope.engine->toVariant(callData->args[0], -1); + QVariant v = scope.engine->toVariant(argv[0], -1); if (v.userType() == QVariant::String) { bool ok = false; v = QQmlStringConverters::colorFromString(v.toString(), &ok); @@ -639,8 +638,8 @@ ReturnedValue QtObject::method_darker(const BuiltinFunction *b, CallData *callDa } qreal factor = 2.0; - if (callData->argc() == 2) - factor = callData->args[1].toNumber(); + if (argc == 2) + factor = argv[1].toNumber(); return scope.engine->fromVariant(QQml_colorProvider()->darker(v, factor)); } @@ -669,14 +668,14 @@ ReturnedValue QtObject::method_darker(const BuiltinFunction *b, CallData *callDa Tint is most useful when a subtle change is intended to be conveyed due to some event; you can then use tinting to more effectively tune the visible color. */ -ReturnedValue QtObject::method_tint(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_tint(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() != 2) + if (argc != 2) THROW_GENERIC_ERROR("Qt.tint(): Invalid arguments"); // base color - QVariant v1 = scope.engine->toVariant(callData->args[0], -1); + QVariant v1 = scope.engine->toVariant(argv[0], -1); if (v1.userType() == QVariant::String) { bool ok = false; v1 = QQmlStringConverters::colorFromString(v1.toString(), &ok); @@ -688,7 +687,7 @@ ReturnedValue QtObject::method_tint(const BuiltinFunction *b, CallData *callData } // tint color - QVariant v2 = scope.engine->toVariant(callData->args[1], -1); + QVariant v2 = scope.engine->toVariant(argv[1], -1); if (v2.userType() == QVariant::String) { bool ok = false; v2 = QQmlStringConverters::colorFromString(v2.toString(), &ok); @@ -718,22 +717,22 @@ If \a format is not specified, \a date is formatted using \sa Locale */ -ReturnedValue QtObject::method_formatDate(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_formatDate(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() < 1 || callData->argc() > 2) + if (argc < 1 || argc > 2) THROW_GENERIC_ERROR("Qt.formatDate(): Invalid arguments"); Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; - QDate date = scope.engine->toVariant(callData->args[0], -1).toDateTime().date(); + QDate date = scope.engine->toVariant(argv[0], -1).toDateTime().date(); QString formattedDate; - if (callData->argc() == 2) { - QV4::ScopedString s(scope, callData->args[1]); + if (argc == 2) { + QV4::ScopedString s(scope, argv[1]); if (s) { QString format = s->toQString(); formattedDate = date.toString(format); - } else if (callData->args[1].isNumber()) { - quint32 intFormat = callData->args[1].asDouble(); + } else if (argv[1].isNumber()) { + quint32 intFormat = argv[1].asDouble(); Qt::DateFormat format = Qt::DateFormat(intFormat); formattedDate = date.toString(format); } else { @@ -761,28 +760,28 @@ If \a format is not specified, \a time is formatted using \sa Locale */ -ReturnedValue QtObject::method_formatTime(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_formatTime(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() < 1 || callData->argc() > 2) + if (argc < 1 || argc > 2) THROW_GENERIC_ERROR("Qt.formatTime(): Invalid arguments"); - QVariant argVariant = scope.engine->toVariant(callData->args[0], -1); + QVariant argVariant = scope.engine->toVariant(argv[0], -1); QTime time; - if (callData->args[0].as() || (argVariant.type() == QVariant::String)) + if (argv[0].as() || (argVariant.type() == QVariant::String)) time = argVariant.toDateTime().time(); else // if (argVariant.type() == QVariant::Time), or invalid. time = argVariant.toTime(); Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; QString formattedTime; - if (callData->argc() == 2) { - QV4::ScopedString s(scope, callData->args[1]); + if (argc == 2) { + QV4::ScopedString s(scope, argv[1]); if (s) { QString format = s->toQString(); formattedTime = time.toString(format); - } else if (callData->args[1].isNumber()) { - quint32 intFormat = callData->args[1].asDouble(); + } else if (argv[1].isNumber()) { + quint32 intFormat = argv[1].asDouble(); Qt::DateFormat format = Qt::DateFormat(intFormat); formattedTime = time.toString(format); } else { @@ -887,22 +886,22 @@ with the \a format values below to produce the following results: \sa Locale */ -ReturnedValue QtObject::method_formatDateTime(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_formatDateTime(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() < 1 || callData->argc() > 2) + if (argc < 1 || argc > 2) THROW_GENERIC_ERROR("Qt.formatDateTime(): Invalid arguments"); Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; - QDateTime dt = scope.engine->toVariant(callData->args[0], -1).toDateTime(); + QDateTime dt = scope.engine->toVariant(argv[0], -1).toDateTime(); QString formattedDt; - if (callData->argc() == 2) { - QV4::ScopedString s(scope, callData->args[1]); + if (argc == 2) { + QV4::ScopedString s(scope, argv[1]); if (s) { QString format = s->toQString(); formattedDt = dt.toString(format); - } else if (callData->args[1].isNumber()) { - quint32 intFormat = callData->args[1].asDouble(); + } else if (argv[1].isNumber()) { + quint32 intFormat = argv[1].asDouble(); Qt::DateFormat format = Qt::DateFormat(intFormat); formattedDt = dt.toString(format); } else { @@ -926,14 +925,13 @@ ReturnedValue QtObject::method_formatDateTime(const BuiltinFunction *b, CallData still fail to launch or fail to open the requested URL. This result will not be reported back to the application. */ -ReturnedValue QtObject::method_openUrlExternally(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_openUrlExternally(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() != 1) { + if (argc != 1) return QV4::Encode(false); - } - ScopedValue result(scope, method_resolvedUrl(b, callData)); + ScopedValue result(scope, method_resolvedUrl(b, thisObject, argv, argc)); QUrl url(result->toQStringNoThrow()); return scope.engine->fromVariant(QQml_guiProvider()->openUrlExternally(url)); } @@ -942,11 +940,13 @@ ReturnedValue QtObject::method_openUrlExternally(const BuiltinFunction *b, CallD \qmlmethod url Qt::resolvedUrl(url url) Returns \a url resolved relative to the URL of the caller. */ -ReturnedValue QtObject::method_resolvedUrl(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_resolvedUrl(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); + if (argc != 1) + return Encode::undefined(); - QUrl url = scope.engine->toVariant(callData->args[0], -1).toUrl(); + QUrl url = scope.engine->toVariant(argv[0], -1).toUrl(); QQmlEngine *e = scope.engine->qmlEngine(); QQmlEnginePrivate *p = 0; if (e) p = QQmlEnginePrivate::get(e); @@ -965,10 +965,10 @@ ReturnedValue QtObject::method_resolvedUrl(const BuiltinFunction *b, CallData *c \qmlmethod list Qt::fontFamilies() Returns a list of the font families available to the application. */ -ReturnedValue QtObject::method_fontFamilies(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_fontFamilies(const FunctionObject *b, const Value *, const Value *, int argc) { QV4::Scope scope(b); - if (callData->argc() != 0) + if (argc != 0) THROW_GENERIC_ERROR("Qt.fontFamilies(): Invalid arguments"); return scope.engine->fromVariant(QVariant(QQml_guiProvider()->fontFamilies())); @@ -978,13 +978,13 @@ ReturnedValue QtObject::method_fontFamilies(const BuiltinFunction *b, CallData * \qmlmethod string Qt::md5(data) Returns a hex string of the md5 hash of \c data. */ -ReturnedValue QtObject::method_md5(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_md5(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() != 1) + if (argc != 1) THROW_GENERIC_ERROR("Qt.md5(): Invalid arguments"); - QByteArray data = callData->args[0].toQStringNoThrow().toUtf8(); + QByteArray data = argv[0].toQStringNoThrow().toUtf8(); QByteArray result = QCryptographicHash::hash(data, QCryptographicHash::Md5); return Encode(scope.engine->newString(QLatin1String(result.toHex()))); } @@ -993,13 +993,13 @@ ReturnedValue QtObject::method_md5(const BuiltinFunction *b, CallData *callData) \qmlmethod string Qt::btoa(data) Binary to ASCII - this function returns a base64 encoding of \c data. */ -ReturnedValue QtObject::method_btoa(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_btoa(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() != 1) + if (argc != 1) THROW_GENERIC_ERROR("Qt.btoa(): Invalid arguments"); - QByteArray data = callData->args[0].toQStringNoThrow().toUtf8(); + QByteArray data = argv[0].toQStringNoThrow().toUtf8(); return Encode(scope.engine->newString(QLatin1String(data.toBase64()))); } @@ -1008,13 +1008,13 @@ ReturnedValue QtObject::method_btoa(const BuiltinFunction *b, CallData *callData \qmlmethod string Qt::atob(data) ASCII to binary - this function decodes the base64 encoded \a data string and returns it. */ -ReturnedValue QtObject::method_atob(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_atob(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() != 1) + if (argc != 1) THROW_GENERIC_ERROR("Qt.atob(): Invalid arguments"); - QByteArray data = callData->args[0].toQStringNoThrow().toLatin1(); + QByteArray data = argv[0].toQStringNoThrow().toLatin1(); return Encode(scope.engine->newString(QString::fromUtf8(QByteArray::fromBase64(data)))); } @@ -1028,7 +1028,7 @@ QQmlEngine::quit() signal to the QCoreApplication::quit() slot. \sa exit() */ -ReturnedValue QtObject::method_quit(const BuiltinFunction *b, CallData *) +ReturnedValue QtObject::method_quit(const FunctionObject *b, const Value *, const Value *, int) { QQmlEnginePrivate::get(b->engine()->qmlEngine())->sendQuit(); return Encode::undefined(); @@ -1045,13 +1045,13 @@ ReturnedValue QtObject::method_quit(const BuiltinFunction *b, CallData *) \sa quit() */ -ReturnedValue QtObject::method_exit(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_exit(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() != 1) + if (argc != 1) THROW_GENERIC_ERROR("Qt.exit(): Invalid arguments"); - int retCode = callData->args[0].toNumber(); + int retCode = argv[0].toNumber(); QQmlEnginePrivate::get(scope.engine->qmlEngine())->sendExit(retCode); return QV4::Encode::undefined(); @@ -1081,10 +1081,10 @@ If this is the case, consider using \l{QtQml::Qt::createComponent()}{Qt.createCo See \l {Dynamic QML Object Creation from JavaScript} for more information on using this function. */ -ReturnedValue QtObject::method_createQmlObject(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_createQmlObject(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() < 2 || callData->argc() > 3) + if (argc < 2 || argc > 3) THROW_GENERIC_ERROR("Qt.createQmlObject(): Invalid arguments"); struct Error { @@ -1128,13 +1128,13 @@ ReturnedValue QtObject::method_createQmlObject(const BuiltinFunction *b, CallDat effectiveContext = context->asQQmlContext(); Q_ASSERT(effectiveContext); - QString qml = callData->args[0].toQStringNoThrow(); + QString qml = argv[0].toQStringNoThrow(); if (qml.isEmpty()) RETURN_RESULT(Encode::null()); QUrl url; - if (callData->argc() > 2) - url = QUrl(callData->args[2].toQStringNoThrow()); + if (argc > 2) + url = QUrl(argv[2].toQStringNoThrow()); else url = QUrl(QLatin1String("inline")); @@ -1142,7 +1142,7 @@ ReturnedValue QtObject::method_createQmlObject(const BuiltinFunction *b, CallDat url = context->resolvedUrl(url); QObject *parentArg = 0; - QV4::Scoped qobjectWrapper(scope, callData->args[1]); + QV4::Scoped qobjectWrapper(scope, argv[1]); if (!!qobjectWrapper) parentArg = qobjectWrapper->object(); if (!parentArg) @@ -1238,10 +1238,10 @@ See \l {Dynamic QML Object Creation from JavaScript} for more information on usi To create a QML object from an arbitrary string of QML (instead of a file), use \l{QtQml::Qt::createQmlObject()}{Qt.createQmlObject()}. */ -ReturnedValue QtObject::method_createComponent(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_createComponent(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() < 1 || callData->argc() > 3) + if (argc < 1 || argc > 3) THROW_GENERIC_ERROR("Qt.createComponent(): Invalid arguments"); QV8Engine *v8engine = scope.engine->v8Engine; @@ -1253,7 +1253,7 @@ ReturnedValue QtObject::method_createComponent(const BuiltinFunction *b, CallDat if (context->isPragmaLibraryContext) effectiveContext = 0; - QString arg = callData->args[0].toQStringNoThrow(); + QString arg = argv[0].toQStringNoThrow(); if (arg.isEmpty()) RETURN_RESULT(QV4::Encode::null()); @@ -1261,23 +1261,23 @@ ReturnedValue QtObject::method_createComponent(const BuiltinFunction *b, CallDat QObject *parentArg = 0; int consumedCount = 1; - if (callData->argc() > 1) { - ScopedValue lastArg(scope, callData->args[callData->argc()-1]); + if (argc > 1) { + ScopedValue lastArg(scope, argv[argc-1]); // The second argument could be the mode enum - if (callData->args[1].isInteger()) { - int mode = callData->args[1].integerValue(); + if (argv[1].isInteger()) { + int mode = argv[1].integerValue(); if (mode != int(QQmlComponent::PreferSynchronous) && mode != int(QQmlComponent::Asynchronous)) THROW_GENERIC_ERROR("Qt.createComponent(): Invalid arguments"); compileMode = QQmlComponent::CompilationMode(mode); consumedCount += 1; } else { // The second argument could be the parent only if there are exactly two args - if ((callData->argc() != 2) || !(lastArg->isObject() || lastArg->isNull())) + if ((argc != 2) || !(lastArg->isObject() || lastArg->isNull())) THROW_GENERIC_ERROR("Qt.createComponent(): Invalid arguments"); } - if (consumedCount < callData->argc()) { + if (consumedCount < argc) { if (lastArg->isObject()) { Scoped qobjectWrapper(scope, lastArg); if (qobjectWrapper) @@ -1321,17 +1321,17 @@ ReturnedValue QtObject::method_createComponent(const BuiltinFunction *b, CallDat \sa Locale */ -ReturnedValue QtObject::method_locale(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_locale(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); QString code; - if (callData->argc() > 1) + if (argc > 1) THROW_GENERIC_ERROR("locale() requires 0 or 1 argument"); - if (callData->argc() == 1 && !callData->args[0].isString()) + if (argc == 1 && !argv[0].isString()) THROW_TYPE_ERROR_WITH_MESSAGE("locale(): argument (locale code) must be a string"); - if (callData->argc() == 1) - code = callData->args[0].toQStringNoThrow(); + if (argc == 1) + code = argv[0].toQStringNoThrow(); return QQmlLocale::locale(scope.engine, code); } @@ -1395,12 +1395,12 @@ DEFINE_OBJECT_VTABLE(QQmlBindingFunction); \since 5.0 */ -ReturnedValue QtObject::method_binding(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_binding(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() != 1) + if (argc != 1) THROW_GENERIC_ERROR("binding() requires 1 argument"); - const QV4::FunctionObject *f = callData->args[0].as(); + const QV4::FunctionObject *f = argv[0].as(); if (!f) THROW_TYPE_ERROR_WITH_MESSAGE("binding(): argument (binding expression) must be a function"); @@ -1408,14 +1408,14 @@ ReturnedValue QtObject::method_binding(const BuiltinFunction *b, CallData *callD } -ReturnedValue QtObject::method_get_platform(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_get_platform(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); // ### inefficient. Should be just a value based getter - Object *o = callData->thisObject.as(); + const Object *o = thisObject->as(); if (!o) THROW_TYPE_ERROR(); - QtObject *qt = o->as(); + const QtObject *qt = o->as(); if (!qt) THROW_TYPE_ERROR(); @@ -1426,14 +1426,14 @@ ReturnedValue QtObject::method_get_platform(const BuiltinFunction *b, CallData * return QV4::QObjectWrapper::wrap(scope.engine, qt->d()->platform); } -ReturnedValue QtObject::method_get_application(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_get_application(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); // ### inefficient. Should be just a value based getter - Object *o = callData->thisObject.as(); + const Object *o = thisObject->as(); if (!o) THROW_TYPE_ERROR(); - QtObject *qt = o->as(); + const QtObject *qt = o->as(); if (!qt) THROW_TYPE_ERROR(); @@ -1444,13 +1444,13 @@ ReturnedValue QtObject::method_get_application(const BuiltinFunction *b, CallDat return QV4::QObjectWrapper::wrap(scope.engine, qt->d()->application); } -ReturnedValue QtObject::method_get_inputMethod(const BuiltinFunction *b, CallData *) +ReturnedValue QtObject::method_get_inputMethod(const FunctionObject *b, const Value *, const Value *, int) { QObject *o = QQml_guiProvider()->inputMethod(); return QV4::QObjectWrapper::wrap(b->engine(), o); } -ReturnedValue QtObject::method_get_styleHints(const BuiltinFunction *b, CallData *) +ReturnedValue QtObject::method_get_styleHints(const FunctionObject *b, const Value *, const Value *, int) { QObject *o = QQml_guiProvider()->styleHints(); return QV4::QObjectWrapper::wrap(b->engine(), o); @@ -1513,7 +1513,7 @@ static QString jsStack(QV4::ExecutionEngine *engine) { return stack; } -static ReturnedValue writeToConsole(const BuiltinFunction *b, CallData *callData, +static ReturnedValue writeToConsole(const FunctionObject *b, const Value *, const Value *argv, int argc, ConsoleLogTypes logType, bool printStack = false) { QLoggingCategory *loggingCategory = 0; @@ -1522,8 +1522,8 @@ static ReturnedValue writeToConsole(const BuiltinFunction *b, CallData *callData QV4::ExecutionEngine *v4 = scope.engine; int start = 0; - if (callData->argc() > 0) { - if (const QObjectWrapper* wrapper = callData->args[0].as()) { + if (argc > 0) { + if (const QObjectWrapper* wrapper = argv[0].as()) { if (QQmlLoggingCategory* category = qobject_cast(wrapper->object())) { if (category->category()) loggingCategory = category->category(); @@ -1535,14 +1535,14 @@ static ReturnedValue writeToConsole(const BuiltinFunction *b, CallData *callData } - for (int i = start, ei = callData->argc(); i < ei; ++i) { + for (int i = start, ei = argc; i < ei; ++i) { if (i != start) result.append(QLatin1Char(' ')); - if (callData->args[i].as()) - result += QLatin1Char('[') + callData->args[i].toQStringNoThrow() + QLatin1Char(']'); + if (argv[i].as()) + result += QLatin1Char('[') + argv[i].toQStringNoThrow() + QLatin1Char(']'); else - result.append(callData->args[i].toQStringNoThrow()); + result.append(argv[i].toQStringNoThrow()); } if (printStack) @@ -1584,25 +1584,25 @@ static ReturnedValue writeToConsole(const BuiltinFunction *b, CallData *callData DEFINE_OBJECT_VTABLE(ConsoleObject); -ReturnedValue ConsoleObject::method_error(const BuiltinFunction *b, CallData *callData) +ReturnedValue ConsoleObject::method_error(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { - return writeToConsole(b, callData, Error); + return writeToConsole(b, thisObject, argv, argc, Error); } -ReturnedValue ConsoleObject::method_log(const BuiltinFunction *b, CallData *callData) +ReturnedValue ConsoleObject::method_log(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { //console.log //console.debug //print - return writeToConsole(b, callData, Log); + return writeToConsole(b, thisObject, argv, argc, Log); } -ReturnedValue ConsoleObject::method_info(const BuiltinFunction *b, CallData *callData) +ReturnedValue ConsoleObject::method_info(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { - return writeToConsole(b, callData, Info); + return writeToConsole(b, thisObject, argv, argc, Info); } -ReturnedValue ConsoleObject::method_profile(const BuiltinFunction *b, CallData *) +ReturnedValue ConsoleObject::method_profile(const FunctionObject *b, const Value *, const Value *, int) { QV4::Scope scope(b); QV4::ExecutionEngine *v4 = scope.engine; @@ -1622,7 +1622,7 @@ ReturnedValue ConsoleObject::method_profile(const BuiltinFunction *b, CallData * return QV4::Encode::undefined(); } -ReturnedValue ConsoleObject::method_profileEnd(const BuiltinFunction *b, CallData *) +ReturnedValue ConsoleObject::method_profileEnd(const FunctionObject *b, const Value *, const Value *, int) { QV4::Scope scope(b); QV4::ExecutionEngine *v4 = scope.engine; @@ -1643,28 +1643,28 @@ ReturnedValue ConsoleObject::method_profileEnd(const BuiltinFunction *b, CallDat return QV4::Encode::undefined(); } -ReturnedValue ConsoleObject::method_time(const BuiltinFunction *b, CallData *callData) +ReturnedValue ConsoleObject::method_time(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() != 1) + if (argc != 1) THROW_GENERIC_ERROR("console.time(): Invalid arguments"); QV8Engine *v8engine = scope.engine->v8Engine; - QString name = callData->args[0].toQStringNoThrow(); + QString name = argv[0].toQStringNoThrow(); v8engine->startTimer(name); return QV4::Encode::undefined(); } -ReturnedValue ConsoleObject::method_timeEnd(const BuiltinFunction *b, CallData *callData) +ReturnedValue ConsoleObject::method_timeEnd(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() != 1) + if (argc != 1) THROW_GENERIC_ERROR("console.timeEnd(): Invalid arguments"); QV8Engine *v8engine = scope.engine->v8Engine; - QString name = callData->args[0].toQStringNoThrow(); + QString name = argv[0].toQStringNoThrow(); bool wasRunning; qint64 elapsed = v8engine->stopTimer(name, &wasRunning); if (wasRunning) { @@ -1673,12 +1673,12 @@ ReturnedValue ConsoleObject::method_timeEnd(const BuiltinFunction *b, CallData * return QV4::Encode::undefined(); } -ReturnedValue ConsoleObject::method_count(const BuiltinFunction *b, CallData *callData) +ReturnedValue ConsoleObject::method_count(const FunctionObject *b, const Value *, const Value *argv, int argc) { // first argument: name to print. Ignore any additional arguments QString name; - if (callData->argc() > 0) - name = callData->args[0].toQStringNoThrow(); + if (argc > 0) + name = argv[0].toQStringNoThrow(); Scope scope(b); QV4::ExecutionEngine *v4 = scope.engine; @@ -1698,10 +1698,10 @@ ReturnedValue ConsoleObject::method_count(const BuiltinFunction *b, CallData *ca return QV4::Encode::undefined(); } -ReturnedValue ConsoleObject::method_trace(const BuiltinFunction *b, CallData *callData) +ReturnedValue ConsoleObject::method_trace(const FunctionObject *b, const Value *, const Value *, int argc) { QV4::Scope scope(b); - if (callData->argc() != 0) + if (argc != 0) THROW_GENERIC_ERROR("console.trace(): Invalid arguments"); QV4::ExecutionEngine *v4 = scope.engine; @@ -1716,26 +1716,26 @@ ReturnedValue ConsoleObject::method_trace(const BuiltinFunction *b, CallData *ca return QV4::Encode::undefined(); } -ReturnedValue ConsoleObject::method_warn(const BuiltinFunction *b, CallData *callData) +ReturnedValue ConsoleObject::method_warn(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { - return writeToConsole(b, callData, Warn); + return writeToConsole(b, thisObject, argv, argc, Warn); } -ReturnedValue ConsoleObject::method_assert(const BuiltinFunction *b, CallData *callData) +ReturnedValue ConsoleObject::method_assert(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() == 0) + if (argc == 0) THROW_GENERIC_ERROR("console.assert(): Missing argument"); QV4::ExecutionEngine *v4 = scope.engine; - if (!callData->args[0].toBoolean()) { + if (!argv[0].toBoolean()) { QString message; - for (int i = 1, ei = callData->argc(); i < ei; ++i) { + for (int i = 1, ei = argc; i < ei; ++i) { if (i != 1) message.append(QLatin1Char(' ')); - message.append(callData->args[i].toQStringNoThrow()); + message.append(argv[i].toQStringNoThrow()); } QString stack = jsStack(v4); @@ -1749,13 +1749,13 @@ ReturnedValue ConsoleObject::method_assert(const BuiltinFunction *b, CallData *c return QV4::Encode::undefined(); } -ReturnedValue ConsoleObject::method_exception(const BuiltinFunction *b, CallData *callData) +ReturnedValue ConsoleObject::method_exception(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() == 0) + if (argc == 0) THROW_GENERIC_ERROR("console.exception(): Missing argument"); - return writeToConsole(b, callData, Error, true); + return writeToConsole(b, thisObject, argv, argc, Error, true); } @@ -1811,32 +1811,32 @@ void QV4::GlobalExtensions::init(Object *globalObject, QJSEngine::Extensions ext \sa {Internationalization and Localization with Qt Quick} */ -ReturnedValue GlobalExtensions::method_qsTranslate(const BuiltinFunction *b, CallData *callData) +ReturnedValue GlobalExtensions::method_qsTranslate(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() < 2) + if (argc < 2) THROW_GENERIC_ERROR("qsTranslate() requires at least two arguments"); - if (!callData->args[0].isString()) + if (!argv[0].isString()) THROW_GENERIC_ERROR("qsTranslate(): first argument (context) must be a string"); - if (!callData->args[1].isString()) + if (!argv[1].isString()) THROW_GENERIC_ERROR("qsTranslate(): second argument (sourceText) must be a string"); - if ((callData->argc() > 2) && !callData->args[2].isString()) + if ((argc > 2) && !argv[2].isString()) THROW_GENERIC_ERROR("qsTranslate(): third argument (disambiguation) must be a string"); - QString context = callData->args[0].toQStringNoThrow(); - QString text = callData->args[1].toQStringNoThrow(); + QString context = argv[0].toQStringNoThrow(); + QString text = argv[1].toQStringNoThrow(); QString comment; - if (callData->argc() > 2) comment = callData->args[2].toQStringNoThrow(); + if (argc > 2) comment = argv[2].toQStringNoThrow(); int i = 3; - if (callData->argc() > i && callData->args[i].isString()) { + if (argc > i && argv[i].isString()) { qWarning("qsTranslate(): specifying the encoding as fourth argument is deprecated"); ++i; } int n = -1; - if (callData->argc() > i) - n = callData->args[i].toInt32(); + if (argc > i) + n = argv[i].toInt32(); QString result = QCoreApplication::translate(context.toUtf8().constData(), text.toUtf8().constData(), @@ -1868,13 +1868,13 @@ ReturnedValue GlobalExtensions::method_qsTranslate(const BuiltinFunction *b, Cal \sa {Internationalization and Localization with Qt Quick} */ -ReturnedValue GlobalExtensions::method_qsTranslateNoOp(const BuiltinFunction *b, CallData *callData) +ReturnedValue GlobalExtensions::method_qsTranslateNoOp(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() < 2) + if (argc < 2) return QV4::Encode::undefined(); else - return callData->args[1].asReturnedValue(); + return argv[1].asReturnedValue(); } /*! @@ -1894,16 +1894,16 @@ ReturnedValue GlobalExtensions::method_qsTranslateNoOp(const BuiltinFunction *b, \sa {Internationalization and Localization with Qt Quick} */ -ReturnedValue GlobalExtensions::method_qsTr(const BuiltinFunction *b, CallData *callData) +ReturnedValue GlobalExtensions::method_qsTr(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() < 1) + if (argc < 1) THROW_GENERIC_ERROR("qsTr() requires at least one argument"); - if (!callData->args[0].isString()) + if (!argv[0].isString()) THROW_GENERIC_ERROR("qsTr(): first argument (sourceText) must be a string"); - if ((callData->argc() > 1) && !callData->args[1].isString()) + if ((argc > 1) && !argv[1].isString()) THROW_GENERIC_ERROR("qsTr(): second argument (disambiguation) must be a string"); - if ((callData->argc() > 2) && !callData->args[2].isNumber()) + if ((argc > 2) && !argv[2].isNumber()) THROW_GENERIC_ERROR("qsTr(): third argument (n) must be a number"); QString context; @@ -1933,13 +1933,13 @@ ReturnedValue GlobalExtensions::method_qsTr(const BuiltinFunction *b, CallData * } } - QString text = callData->args[0].toQStringNoThrow(); + QString text = argv[0].toQStringNoThrow(); QString comment; - if (callData->argc() > 1) - comment = callData->args[1].toQStringNoThrow(); + if (argc > 1) + comment = argv[1].toQStringNoThrow(); int n = -1; - if (callData->argc() > 2) - n = callData->args[2].toInt32(); + if (argc > 2) + n = argv[2].toInt32(); QString result = QCoreApplication::translate(context.toUtf8().constData(), text.toUtf8().constData(), comment.toUtf8().constData(), n); @@ -1969,12 +1969,12 @@ ReturnedValue GlobalExtensions::method_qsTr(const BuiltinFunction *b, CallData * \sa {Internationalization and Localization with Qt Quick} */ -ReturnedValue GlobalExtensions::method_qsTrNoOp(const BuiltinFunction *, CallData *callData) +ReturnedValue GlobalExtensions::method_qsTrNoOp(const FunctionObject *, const Value *, const Value *argv, int argc) { - if (callData->argc() < 1) + if (argc < 1) return QV4::Encode::undefined(); else - return callData->args[0].asReturnedValue(); + return argv[0].asReturnedValue(); } /*! @@ -2007,21 +2007,21 @@ ReturnedValue GlobalExtensions::method_qsTrNoOp(const BuiltinFunction *, CallDat \sa QT_TRID_NOOP(), {Internationalization and Localization with Qt Quick} */ -ReturnedValue GlobalExtensions::method_qsTrId(const BuiltinFunction *b, CallData *callData) +ReturnedValue GlobalExtensions::method_qsTrId(const FunctionObject *b, const Value *, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() < 1) + if (argc < 1) THROW_GENERIC_ERROR("qsTrId() requires at least one argument"); - if (!callData->args[0].isString()) + if (!argv[0].isString()) THROW_TYPE_ERROR_WITH_MESSAGE("qsTrId(): first argument (id) must be a string"); - if (callData->argc() > 1 && !callData->args[1].isNumber()) + if (argc > 1 && !argv[1].isNumber()) THROW_TYPE_ERROR_WITH_MESSAGE("qsTrId(): second argument (n) must be a number"); int n = -1; - if (callData->argc() > 1) - n = callData->args[1].toInt32(); + if (argc > 1) + n = argv[1].toInt32(); - return Encode(scope.engine->newString(qtTrId(callData->args[0].toQStringNoThrow().toUtf8().constData(), n))); + return Encode(scope.engine->newString(qtTrId(argv[0].toQStringNoThrow().toUtf8().constData(), n))); } /*! @@ -2040,17 +2040,17 @@ ReturnedValue GlobalExtensions::method_qsTrId(const BuiltinFunction *b, CallData \sa qsTrId(), {Internationalization and Localization with Qt Quick} */ -ReturnedValue GlobalExtensions::method_qsTrIdNoOp(const BuiltinFunction *, CallData *callData) +ReturnedValue GlobalExtensions::method_qsTrIdNoOp(const FunctionObject *, const Value *, const Value *argv, int argc) { - if (callData->argc() < 1) + if (argc < 1) return QV4::Encode::undefined(); else - return callData->args[0].asReturnedValue(); + return argv[0].asReturnedValue(); } #endif // translation -ReturnedValue GlobalExtensions::method_gc(const BuiltinFunction *b, CallData *) +ReturnedValue GlobalExtensions::method_gc(const FunctionObject *b, const Value *, const Value *, int) { b->engine()->memoryManager->runGC(); @@ -2059,15 +2059,15 @@ ReturnedValue GlobalExtensions::method_gc(const BuiltinFunction *b, CallData *) -ReturnedValue GlobalExtensions::method_string_arg(const BuiltinFunction *b, CallData *callData) +ReturnedValue GlobalExtensions::method_string_arg(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() != 1) + if (argc != 1) THROW_GENERIC_ERROR("String.arg(): Invalid arguments"); - QString value = callData->thisObject.toQString(); + QString value = thisObject->toQString(); - QV4::ScopedValue arg(scope, callData->args[0]); + QV4::ScopedValue arg(scope, argv[0]); if (arg->isInteger()) RETURN_RESULT(scope.engine->newString(value.arg(arg->integerValue()))); else if (arg->isDouble()) diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h index 5b7dc67e8c..104dae5d79 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h +++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h @@ -93,43 +93,43 @@ struct QtObject : Object static ReturnedValue get(const Managed *m, String *name, bool *hasProperty); static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes); - static ReturnedValue method_isQtObject(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_rgba(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_hsla(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_hsva(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_colorEqual(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_font(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_rect(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_point(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_size(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_vector2d(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_vector3d(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_vector4d(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_quaternion(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_matrix4x4(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_lighter(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_darker(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_tint(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_formatDate(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_formatTime(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_formatDateTime(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_openUrlExternally(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_fontFamilies(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_md5(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_btoa(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_atob(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_quit(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_exit(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_resolvedUrl(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_createQmlObject(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_createComponent(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_locale(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_binding(const BuiltinFunction *, CallData *callData); - - static ReturnedValue method_get_platform(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_get_application(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_get_inputMethod(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_get_styleHints(const BuiltinFunction *, CallData *callData); + static ReturnedValue method_isQtObject(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_rgba(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_hsla(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_hsva(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_colorEqual(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_font(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_rect(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_point(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_size(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_vector2d(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_vector3d(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_vector4d(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_quaternion(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_matrix4x4(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_lighter(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_darker(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_tint(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_formatDate(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_formatTime(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_formatDateTime(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_openUrlExternally(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_fontFamilies(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_md5(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_btoa(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_atob(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_quit(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_exit(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_resolvedUrl(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_createQmlObject(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_createComponent(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_locale(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_binding(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + + static ReturnedValue method_get_platform(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_application(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_inputMethod(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_styleHints(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); static ReturnedValue method_callLater(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); @@ -142,18 +142,18 @@ struct ConsoleObject : Object { V4_OBJECT2(ConsoleObject, Object) - static ReturnedValue method_error(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_log(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_info(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_profile(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_profileEnd(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_time(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_timeEnd(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_count(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_trace(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_warn(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_assert(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_exception(const BuiltinFunction *, CallData *callData); + static ReturnedValue method_error(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_log(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_info(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_profile(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_profileEnd(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_time(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_timeEnd(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_count(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_trace(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_warn(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_assert(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_exception(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); }; @@ -161,17 +161,17 @@ struct Q_QML_PRIVATE_EXPORT GlobalExtensions { static void init(Object *globalObject, QJSEngine::Extensions extensions); #if QT_CONFIG(translation) - static ReturnedValue method_qsTranslate(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_qsTranslateNoOp(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_qsTr(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_qsTrNoOp(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_qsTrId(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_qsTrIdNoOp(const BuiltinFunction *, CallData *callData); + static ReturnedValue method_qsTranslate(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_qsTranslateNoOp(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_qsTr(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_qsTrNoOp(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_qsTrId(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_qsTrIdNoOp(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); #endif - static ReturnedValue method_gc(const BuiltinFunction *, CallData *callData); + static ReturnedValue method_gc(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); // on String:prototype - static ReturnedValue method_string_arg(const BuiltinFunction *, CallData *callData); + static ReturnedValue method_string_arg(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); }; -- cgit v1.2.3 From f57a74facb18b46475a77113ac29f4dd321e69cb Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 5 Dec 2017 11:46:15 +0100 Subject: Convert XmlHttpRequest methods to new calling convention Change-Id: Ife44dbb4b18f0542a9fc54047baa6cccc78b2e22 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlxmlhttprequest.cpp | 268 ++++++++++++++++++------------------- 1 file changed, 134 insertions(+), 134 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 08842e714c..9c9e199a5b 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -276,25 +276,25 @@ public: static void initClass(ExecutionEngine *engine); // JS API - static ReturnedValue method_get_nodeName(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_get_nodeValue(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_get_nodeType(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_get_namespaceUri(const BuiltinFunction *b, QV4::CallData *callData); - - static ReturnedValue method_get_parentNode(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_get_childNodes(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_get_firstChild(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_get_lastChild(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_get_previousSibling(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_get_nextSibling(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_get_attributes(const BuiltinFunction *b, QV4::CallData *callData); - - //static ReturnedValue ownerDocument(const BuiltinFunction *b, QV4::CallData *callData); - //static ReturnedValue namespaceURI(const BuiltinFunction *b, QV4::CallData *callData); - //static ReturnedValue prefix(const BuiltinFunction *b, QV4::CallData *callData); - //static ReturnedValue localName(const BuiltinFunction *b, QV4::CallData *callData); - //static ReturnedValue baseURI(const BuiltinFunction *b, QV4::CallData *callData); - //static ReturnedValue textContent(const BuiltinFunction *b, QV4::CallData *callData); + static ReturnedValue method_get_nodeName(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_nodeValue(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_nodeType(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_namespaceUri(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + + static ReturnedValue method_get_parentNode(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_childNodes(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_firstChild(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_lastChild(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_previousSibling(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_nextSibling(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_attributes(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + + //static ReturnedValue ownerDocument(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + //static ReturnedValue namespaceURI(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + //static ReturnedValue prefix(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + //static ReturnedValue localName(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + //static ReturnedValue baseURI(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + //static ReturnedValue textContent(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); static ReturnedValue getProto(ExecutionEngine *v4); @@ -355,10 +355,10 @@ class Attr : public Node { public: // JS API - static ReturnedValue method_name(const BuiltinFunction *b, QV4::CallData *callData); + static ReturnedValue method_name(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); // static void specified(CallContext *); - static ReturnedValue method_value(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_ownerElement(const BuiltinFunction *b, QV4::CallData *callData); + static ReturnedValue method_value(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_ownerElement(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); // static void schemaTypeInfo(CallContext *); // static void isId(CallContext *c); @@ -370,7 +370,7 @@ class CharacterData : public Node { public: // JS API - static ReturnedValue method_length(const BuiltinFunction *b, QV4::CallData *callData); + static ReturnedValue method_length(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); // C++ API static ReturnedValue prototype(ExecutionEngine *v4); @@ -380,8 +380,8 @@ class Text : public CharacterData { public: // JS API - static ReturnedValue method_isElementContentWhitespace(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_wholeText(const BuiltinFunction *b, QV4::CallData *callData); + static ReturnedValue method_isElementContentWhitespace(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_wholeText(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); // C++ API static ReturnedValue prototype(ExecutionEngine *); @@ -398,10 +398,10 @@ class Document : public Node { public: // JS API - static ReturnedValue method_xmlVersion(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_xmlEncoding(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_xmlStandalone(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_documentElement(const BuiltinFunction *b, QV4::CallData *callData); + static ReturnedValue method_xmlVersion(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_xmlEncoding(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_xmlStandalone(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_documentElement(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); // C++ API static ReturnedValue prototype(ExecutionEngine *); @@ -420,10 +420,10 @@ void NodeImpl::release() document->release(); } -ReturnedValue NodePrototype::method_get_nodeName(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue NodePrototype::method_get_nodeName(const FunctionObject *b, const Value *thisObject, const Value *, int) { Scope scope(b); - Scoped r(scope, callData->thisObject.as()); + Scoped r(scope, thisObject->as()); if (!r) THROW_TYPE_ERROR(); @@ -445,10 +445,10 @@ ReturnedValue NodePrototype::method_get_nodeName(const BuiltinFunction *b, QV4:: return Encode(scope.engine->newString(name)); } -ReturnedValue NodePrototype::method_get_nodeValue(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue NodePrototype::method_get_nodeValue(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - Scoped r(scope, callData->thisObject.as()); + Scoped r(scope, thisObject->as()); if (!r) THROW_TYPE_ERROR(); @@ -464,30 +464,30 @@ ReturnedValue NodePrototype::method_get_nodeValue(const BuiltinFunction *b, QV4: return Encode(scope.engine->newString(r->d()->d->data)); } -ReturnedValue NodePrototype::method_get_nodeType(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue NodePrototype::method_get_nodeType(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - Scoped r(scope, callData->thisObject.as()); + Scoped r(scope, thisObject->as()); if (!r) THROW_TYPE_ERROR(); return Encode(r->d()->d->type); } -ReturnedValue NodePrototype::method_get_namespaceUri(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue NodePrototype::method_get_namespaceUri(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - Scoped r(scope, callData->thisObject.as()); + Scoped r(scope, thisObject->as()); if (!r) THROW_TYPE_ERROR(); return Encode(scope.engine->newString(r->d()->d->namespaceUri)); } -ReturnedValue NodePrototype::method_get_parentNode(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue NodePrototype::method_get_parentNode(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - Scoped r(scope, callData->thisObject.as()); + Scoped r(scope, thisObject->as()); if (!r) THROW_TYPE_ERROR(); @@ -497,20 +497,20 @@ ReturnedValue NodePrototype::method_get_parentNode(const BuiltinFunction *b, QV4 return Encode::null(); } -ReturnedValue NodePrototype::method_get_childNodes(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue NodePrototype::method_get_childNodes(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - Scoped r(scope, callData->thisObject.as()); + Scoped r(scope, thisObject->as()); if (!r) THROW_TYPE_ERROR(); return NodeList::create(scope.engine, r->d()->d); } -ReturnedValue NodePrototype::method_get_firstChild(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue NodePrototype::method_get_firstChild(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - Scoped r(scope, callData->thisObject.as()); + Scoped r(scope, thisObject->as()); if (!r) THROW_TYPE_ERROR(); @@ -520,10 +520,10 @@ ReturnedValue NodePrototype::method_get_firstChild(const BuiltinFunction *b, QV4 return Node::create(scope.engine, r->d()->d->children.constFirst()); } -ReturnedValue NodePrototype::method_get_lastChild(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue NodePrototype::method_get_lastChild(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - Scoped r(scope, callData->thisObject.as()); + Scoped r(scope, thisObject->as()); if (!r) THROW_TYPE_ERROR(); @@ -533,10 +533,10 @@ ReturnedValue NodePrototype::method_get_lastChild(const BuiltinFunction *b, QV4: return Node::create(scope.engine, r->d()->d->children.constLast()); } -ReturnedValue NodePrototype::method_get_previousSibling(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue NodePrototype::method_get_previousSibling(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - Scoped r(scope, callData->thisObject.as()); + Scoped r(scope, thisObject->as()); if (!r) THROW_TYPE_ERROR(); @@ -555,10 +555,10 @@ ReturnedValue NodePrototype::method_get_previousSibling(const BuiltinFunction *b return Encode::null(); } -ReturnedValue NodePrototype::method_get_nextSibling(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue NodePrototype::method_get_nextSibling(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - Scoped r(scope, callData->thisObject.as()); + Scoped r(scope, thisObject->as()); if (!r) THROW_TYPE_ERROR(); @@ -577,10 +577,10 @@ ReturnedValue NodePrototype::method_get_nextSibling(const BuiltinFunction *b, QV return Encode::null(); } -ReturnedValue NodePrototype::method_get_attributes(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue NodePrototype::method_get_attributes(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - Scoped r(scope, callData->thisObject.as()); + Scoped r(scope, thisObject->as()); if (!r) THROW_TYPE_ERROR(); @@ -668,40 +668,40 @@ ReturnedValue Attr::prototype(ExecutionEngine *engine) return d->attrPrototype.value(); } -ReturnedValue Attr::method_name(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue Attr::method_name(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - Scoped r(scope, callData->thisObject.as()); + Scoped r(scope, thisObject->as()); if (!r) RETURN_UNDEFINED(); return Encode(scope.engine->newString(r->d()->d->name)); } -ReturnedValue Attr::method_value(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue Attr::method_value(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - Scoped r(scope, callData->thisObject.as()); + Scoped r(scope, thisObject->as()); if (!r) RETURN_UNDEFINED(); return Encode(scope.engine->newString(r->d()->d->data)); } -ReturnedValue Attr::method_ownerElement(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue Attr::method_ownerElement(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - Scoped r(scope, callData->thisObject.as()); + Scoped r(scope, thisObject->as()); if (!r) RETURN_UNDEFINED(); return Node::create(scope.engine, r->d()->d->parent); } -ReturnedValue CharacterData::method_length(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue CharacterData::method_length(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - Scoped r(scope, callData->thisObject.as()); + Scoped r(scope, thisObject->as()); if (!r) RETURN_UNDEFINED(); @@ -724,20 +724,20 @@ ReturnedValue CharacterData::prototype(ExecutionEngine *v4) return d->characterDataPrototype.value(); } -ReturnedValue Text::method_isElementContentWhitespace(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue Text::method_isElementContentWhitespace(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - Scoped r(scope, callData->thisObject.as()); + Scoped r(scope, thisObject->as()); if (!r) RETURN_UNDEFINED(); return Encode(QStringRef(&r->d()->d->data).trimmed().isEmpty()); } -ReturnedValue Text::method_wholeText(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue Text::method_wholeText(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - Scoped r(scope, callData->thisObject.as()); + Scoped r(scope, thisObject->as()); if (!r) RETURN_UNDEFINED(); @@ -967,40 +967,40 @@ ReturnedValue NodeList::create(ExecutionEngine *v4, NodeImpl *data) return (v4->memoryManager->allocObject(data))->asReturnedValue(); } -ReturnedValue Document::method_documentElement(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue Document::method_documentElement(const FunctionObject *b, const Value *thisObject, const Value *, int) { Scope scope(b); - Scoped r(scope, callData->thisObject.as()); + Scoped r(scope, thisObject->as()); if (!r || r->d()->d->type != NodeImpl::Document) RETURN_UNDEFINED(); return Node::create(scope.engine, static_cast(r->d()->d)->root); } -ReturnedValue Document::method_xmlStandalone(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue Document::method_xmlStandalone(const FunctionObject *b, const Value *thisObject, const Value *, int) { Scope scope(b); - Scoped r(scope, callData->thisObject.as()); + Scoped r(scope, thisObject->as()); if (!r || r->d()->d->type != NodeImpl::Document) RETURN_UNDEFINED(); return Encode(static_cast(r->d()->d)->isStandalone); } -ReturnedValue Document::method_xmlVersion(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue Document::method_xmlVersion(const FunctionObject *b, const Value *thisObject, const Value *, int) { Scope scope(b); - Scoped r(scope, callData->thisObject.as()); + Scoped r(scope, thisObject->as()); if (!r || r->d()->d->type != NodeImpl::Document) RETURN_UNDEFINED(); return Encode(scope.engine->newString(static_cast(r->d()->d)->version)); } -ReturnedValue Document::method_xmlEncoding(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue Document::method_xmlEncoding(const FunctionObject *b, const Value *thisObject, const Value *, int) { Scope scope(b); - Scoped r(scope, callData->thisObject.as()); + Scoped r(scope, thisObject->as()); if (!r || r->d()->d->type != NodeImpl::Document) RETURN_UNDEFINED(); @@ -1653,21 +1653,21 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject void setupProto(); - static ReturnedValue method_open(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_setRequestHeader(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_send(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_abort(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_getResponseHeader(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_getAllResponseHeaders(const BuiltinFunction *b, QV4::CallData *callData); - - static ReturnedValue method_get_readyState(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_get_status(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_get_statusText(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_get_responseText(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_get_responseXML(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_get_response(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_get_responseType(const BuiltinFunction *b, QV4::CallData *callData); - static ReturnedValue method_set_responseType(const BuiltinFunction *b, QV4::CallData *callData); + static ReturnedValue method_open(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_setRequestHeader(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_send(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_abort(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getResponseHeader(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getAllResponseHeaders(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + + static ReturnedValue method_get_readyState(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_status(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_statusText(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_responseText(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_responseXML(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_response(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_responseType(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_set_responseType(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); }; } @@ -1729,19 +1729,19 @@ void QQmlXMLHttpRequestCtor::setupProto() // XMLHttpRequest methods -ReturnedValue QQmlXMLHttpRequestCtor::method_open(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue QQmlXMLHttpRequestCtor::method_open(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { Scope scope(b); - Scoped w(scope, callData->thisObject.as()); + Scoped w(scope, thisObject->as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - if (callData->argc() < 2 || callData->argc() > 5) + if (argc < 2 || argc > 5) THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count"); // Argument 0 - Method - QString method = callData->args[0].toQStringNoThrow().toUpper(); + QString method = argv[0].toQStringNoThrow().toUpper(); if (method != QLatin1String("GET") && method != QLatin1String("PUT") && method != QLatin1String("HEAD") && @@ -1753,23 +1753,23 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_open(const BuiltinFunction *b, QV4: THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Unsupported HTTP method type"); // Argument 1 - URL - QUrl url = QUrl(callData->args[1].toQStringNoThrow()); + QUrl url = QUrl(argv[1].toQStringNoThrow()); if (url.isRelative()) url = scope.engine->callingQmlContext()->resolvedUrl(url); bool async = true; // Argument 2 - async (optional) - if (callData->argc() > 2) { - async = callData->args[2].booleanValue(); + if (argc > 2) { + async = argv[2].booleanValue(); } // Argument 3/4 - user/pass (optional) QString username, password; - if (callData->argc() > 3) - username = callData->args[3].toQStringNoThrow(); - if (callData->argc() > 4) - password = callData->args[4].toQStringNoThrow(); + if (argc > 3) + username = argv[3].toQStringNoThrow(); + if (argc > 4) + password = argv[4].toQStringNoThrow(); // Clear the fragment (if any) url.setFragment(QString()); @@ -1781,22 +1781,22 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_open(const BuiltinFunction *b, QV4: return r->open(w, scope.engine->callingQmlContext(), method, url, async ? QQmlXMLHttpRequest::AsynchronousLoad : QQmlXMLHttpRequest::SynchronousLoad); } -ReturnedValue QQmlXMLHttpRequestCtor::method_setRequestHeader(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue QQmlXMLHttpRequestCtor::method_setRequestHeader(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { Scope scope(b); - Scoped w(scope, callData->thisObject.as()); + Scoped w(scope, thisObject->as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - if (callData->argc() != 2) + if (argc != 2) THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count"); if (r->readyState() != QQmlXMLHttpRequest::Opened || r->sendFlag()) THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state"); - QString name = callData->args[0].toQStringNoThrow(); - QString value = callData->args[1].toQStringNoThrow(); + QString name = argv[0].toQStringNoThrow(); + QString value = argv[1].toQStringNoThrow(); // ### Check that name and value are well formed @@ -1828,10 +1828,10 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_setRequestHeader(const BuiltinFunct RETURN_UNDEFINED(); } -ReturnedValue QQmlXMLHttpRequestCtor::method_send(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue QQmlXMLHttpRequestCtor::method_send(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { Scope scope(b); - Scoped w(scope, callData->thisObject.as()); + Scoped w(scope, thisObject->as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; @@ -1841,21 +1841,21 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_send(const BuiltinFunction *b, QV4: THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state"); QByteArray data; - if (callData->argc() > 0) { - if (const ArrayBuffer *buffer = callData->args[0].as()) { + if (argc > 0) { + if (const ArrayBuffer *buffer = argv[0].as()) { data = buffer->asByteArray(); } else { - data = callData->args[0].toQStringNoThrow().toUtf8(); + data = argv[0].toQStringNoThrow().toUtf8(); } } return r->send(w, scope.engine->callingQmlContext(), data); } -ReturnedValue QQmlXMLHttpRequestCtor::method_abort(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue QQmlXMLHttpRequestCtor::method_abort(const FunctionObject *b, const Value *thisObject, const Value *, int) { Scope scope(b); - Scoped w(scope, callData->thisObject.as()); + Scoped w(scope, thisObject->as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; @@ -1863,15 +1863,15 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_abort(const BuiltinFunction *b, QV4 return r->abort(w, scope.engine->callingQmlContext()); } -ReturnedValue QQmlXMLHttpRequestCtor::method_getResponseHeader(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue QQmlXMLHttpRequestCtor::method_getResponseHeader(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { Scope scope(b); - Scoped w(scope, callData->thisObject.as()); + Scoped w(scope, thisObject->as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - if (callData->argc() != 1) + if (argc != 1) THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count"); if (r->readyState() != QQmlXMLHttpRequest::Loading && @@ -1879,18 +1879,18 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_getResponseHeader(const BuiltinFunc r->readyState() != QQmlXMLHttpRequest::HeadersReceived) THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state"); - return Encode(scope.engine->newString(r->header(callData->args[0].toQStringNoThrow()))); + return Encode(scope.engine->newString(r->header(argv[0].toQStringNoThrow()))); } -ReturnedValue QQmlXMLHttpRequestCtor::method_getAllResponseHeaders(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue QQmlXMLHttpRequestCtor::method_getAllResponseHeaders(const FunctionObject *b, const Value *thisObject, const Value *, int argc) { Scope scope(b); - Scoped w(scope, callData->thisObject.as()); + Scoped w(scope, thisObject->as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - if (callData->argc() != 0) + if (argc != 0) THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count"); if (r->readyState() != QQmlXMLHttpRequest::Loading && @@ -1902,10 +1902,10 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_getAllResponseHeaders(const Builtin } // XMLHttpRequest properties -ReturnedValue QQmlXMLHttpRequestCtor::method_get_readyState(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue QQmlXMLHttpRequestCtor::method_get_readyState(const FunctionObject *b, const Value *thisObject, const Value *, int) { Scope scope(b); - Scoped w(scope, callData->thisObject.as()); + Scoped w(scope, thisObject->as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; @@ -1913,10 +1913,10 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_readyState(const BuiltinFunctio return Encode(r->readyState()); } -ReturnedValue QQmlXMLHttpRequestCtor::method_get_status(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue QQmlXMLHttpRequestCtor::method_get_status(const FunctionObject *b, const Value *thisObject, const Value *, int) { Scope scope(b); - Scoped w(scope, callData->thisObject.as()); + Scoped w(scope, thisObject->as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; @@ -1931,10 +1931,10 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_status(const BuiltinFunction *b return Encode(r->replyStatus()); } -ReturnedValue QQmlXMLHttpRequestCtor::method_get_statusText(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue QQmlXMLHttpRequestCtor::method_get_statusText(const FunctionObject *b, const Value *thisObject, const Value *, int) { Scope scope(b); - Scoped w(scope, callData->thisObject.as()); + Scoped w(scope, thisObject->as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; @@ -1949,10 +1949,10 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_statusText(const BuiltinFunctio return Encode(scope.engine->newString(r->replyStatusText())); } -ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseText(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseText(const FunctionObject *b, const Value *thisObject, const Value *, int) { Scope scope(b); - Scoped w(scope, callData->thisObject.as()); + Scoped w(scope, thisObject->as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; @@ -1964,10 +1964,10 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseText(const BuiltinFunct return Encode(scope.engine->newString(r->responseBody())); } -ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseXML(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseXML(const FunctionObject *b, const Value *thisObject, const Value *, int) { Scope scope(b); - Scoped w(scope, callData->thisObject.as()); + Scoped w(scope, thisObject->as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; @@ -1983,10 +1983,10 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseXML(const BuiltinFuncti } } -ReturnedValue QQmlXMLHttpRequestCtor::method_get_response(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue QQmlXMLHttpRequestCtor::method_get_response(const FunctionObject *b, const Value *thisObject, const Value *, int) { Scope scope(b); - Scoped w(scope, callData->thisObject.as()); + Scoped w(scope, thisObject->as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; @@ -2010,29 +2010,29 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_response(const BuiltinFunction } -ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseType(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseType(const FunctionObject *b, const Value *thisObject, const Value *, int) { Scope scope(b); - Scoped w(scope, callData->thisObject.as()); + Scoped w(scope, thisObject->as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; return Encode(scope.engine->newString(r->responseType())); } -ReturnedValue QQmlXMLHttpRequestCtor::method_set_responseType(const BuiltinFunction *b, QV4::CallData *callData) +ReturnedValue QQmlXMLHttpRequestCtor::method_set_responseType(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { Scope scope(b); - Scoped w(scope, callData->thisObject.as()); + Scoped w(scope, thisObject->as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - if (callData->argc() < 1) + if (argc < 1) THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count"); // Argument 0 - response type - r->setResponseType(callData->args[0].toQStringNoThrow()); + r->setResponseType(argv[0].toQStringNoThrow()); return Encode::undefined(); } -- cgit v1.2.3 From c2d0693ca99171ebeb8f35423f29562b0d26c6c0 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 16 Jan 2018 16:34:03 +0100 Subject: Have more bindingBits available inline Many QML items have more than 32 properties, so we ended up malloc'ing the binding bit table on the heap quite often. Extending the inline data to be able to accommodate for up to 64 properties fixes that. Change-Id: I90a42d601a5406ffacf2506f1957b0c2080bbb7b Reviewed-by: Simon Hausmann --- src/qml/qml/qqmldata_p.h | 23 +++++++++++------- src/qml/qml/qqmlengine.cpp | 60 ++++++++++++++++++++-------------------------- 2 files changed, 40 insertions(+), 43 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h index 4848f48766..5794e6f0c5 100644 --- a/src/qml/qml/qqmldata_p.h +++ b/src/qml/qml/qqmldata_p.h @@ -156,18 +156,21 @@ public: quint32 hasInterceptorMetaObject:1; quint32 hasVMEMetaObject:1; quint32 parentFrozen:1; - quint32 dummy:22; + quint32 dummy:6; // When bindingBitsSize < sizeof(ptr), we store the binding bit flags inside // bindingBitsValue. When we need more than sizeof(ptr) bits, we allocated // sufficient space and use bindingBits to point to it. - int bindingBitsSize; + quint32 bindingBitsArraySize : 16; typedef quintptr BindingBitsType; + enum { + BitsPerType = sizeof(BindingBitsType) * 8, + InlineBindingArraySize = 2 + }; union { BindingBitsType *bindingBits; - BindingBitsType bindingBitsValue; + BindingBitsType bindingBitsValue[InlineBindingArraySize]; }; - enum { MaxInlineBits = sizeof(BindingBitsType) * 8 }; struct NotifyList { quint64 connectionMask; @@ -275,6 +278,9 @@ public: return createPropertyCache(engine, object); } + Q_ALWAYS_INLINE static uint offsetForBit(int bit) { return static_cast(bit) / BitsPerType; } + Q_ALWAYS_INLINE static BindingBitsType bitFlagForBit(int bit) { return BindingBitsType(1) << (static_cast(bit) & (BitsPerType - 1)); } + private: // For attachedProperties mutable QQmlDataExtended *extendedData; @@ -286,13 +292,12 @@ private: Q_ALWAYS_INLINE bool hasBitSet(int bit) const { - if (bindingBitsSize <= bit) + uint offset = offsetForBit(bit); + if (bindingBitsArraySize <= offset) return false; - if (bindingBitsSize == MaxInlineBits) - return bindingBitsValue & (BindingBitsType(1) << bit); - else - return bindingBits[bit / MaxInlineBits] & (BindingBitsType(1) << (bit % MaxInlineBits)); + const BindingBitsType *bits = (bindingBitsArraySize == InlineBindingArraySize) ? bindingBitsValue : bindingBits; + return bits[offset] & bitFlagForBit(bit); } }; diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 5350ad38a3..c09c048307 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -110,7 +110,10 @@ Q_DECLARE_METATYPE(QQmlProperty) QT_BEGIN_NAMESPACE typedef QQmlData::BindingBitsType BindingBitsType; -enum { MaxInlineBits = QQmlData::MaxInlineBits }; +enum { + BitsPerType = QQmlData::BitsPerType, + InlineBindingArraySize = QQmlData::InlineBindingArraySize +}; void qmlRegisterBaseTypes(const char *uri, int versionMajor, int versionMinor) { @@ -741,11 +744,12 @@ QQmlData::QQmlData() : ownedByQml1(false), ownMemory(true), indestructible(true), explicitIndestructibleSet(false), hasTaintedV4Object(false), isQueuedForDeletion(false), rootObjectInCreation(false), hasInterceptorMetaObject(false), hasVMEMetaObject(false), parentFrozen(false), - bindingBitsSize(MaxInlineBits), bindingBitsValue(0), notifyList(0), + bindingBitsArraySize(InlineBindingArraySize), notifyList(0), bindings(0), signalHandlers(0), nextContextObject(0), prevContextObject(0), lineNumber(0), columnNumber(0), jsEngineId(0), compilationUnit(0), propertyCache(0), guards(0), extendedData(0) { + memset(bindingBitsValue, 0, sizeof(bindingBitsValue)); init(); } @@ -1792,7 +1796,7 @@ void QQmlData::destroyed(QObject *object) signalHandler = next; } - if (bindingBitsSize > MaxInlineBits) + if (bindingBitsArraySize > InlineBindingArraySize) free(bindingBits); if (propertyCache) @@ -1841,47 +1845,35 @@ void QQmlData::parentChanged(QObject *object, QObject *parent) static void QQmlData_setBit(QQmlData *data, QObject *obj, int bit) { - if (Q_UNLIKELY(data->bindingBitsSize <= bit)) { + uint offset = QQmlData::offsetForBit(bit); + BindingBitsType *bits = (data->bindingBitsArraySize == InlineBindingArraySize) ? data->bindingBitsValue : data->bindingBits; + if (Q_UNLIKELY(data->bindingBitsArraySize <= offset)) { int props = QQmlMetaObject(obj).propertyCount(); Q_ASSERT(bit < 2 * props); - int arraySize = (2 * props + MaxInlineBits - 1) / MaxInlineBits; - Q_ASSERT(arraySize > 1); - - // special handling for 32 here is to make sure we wipe the first byte - // when going from bindingBitsValue to bindingBits, and preserve the old - // set bits so we can restore them after the allocation - int oldArraySize = data->bindingBitsSize > MaxInlineBits ? data->bindingBitsSize / MaxInlineBits : 0; - quintptr oldValue = data->bindingBitsSize == MaxInlineBits ? data->bindingBitsValue : 0; - - data->bindingBits = static_cast(realloc((data->bindingBitsSize == MaxInlineBits) ? 0 : data->bindingBits, - arraySize * sizeof(BindingBitsType))); - - memset(data->bindingBits + oldArraySize, - 0x00, - sizeof(BindingBitsType) * (arraySize - oldArraySize)); + uint arraySize = (2 * static_cast(props) + BitsPerType - 1) / BitsPerType; + Q_ASSERT(arraySize > InlineBindingArraySize && arraySize > data->bindingBitsArraySize); - data->bindingBitsSize = arraySize * MaxInlineBits; + BindingBitsType *newBits = static_cast(malloc(arraySize*sizeof(BindingBitsType))); + memcpy(newBits, bits, data->bindingBitsArraySize * sizeof(BindingBitsType)); + memset(newBits + data->bindingBitsArraySize, 0, sizeof(BindingBitsType) * (arraySize - data->bindingBitsArraySize)); - // reinstate bindingBitsValue after we dropped it - if (oldValue) { - memcpy(data->bindingBits, &oldValue, sizeof(oldValue)); - } + if (data->bindingBitsArraySize > InlineBindingArraySize) + free(bits); + data->bindingBits = newBits; + bits = newBits; + data->bindingBitsArraySize = arraySize; } - - if (data->bindingBitsSize == MaxInlineBits) - data->bindingBitsValue |= BindingBitsType(1) << bit; - else - data->bindingBits[bit / MaxInlineBits] |= (BindingBitsType(1) << (bit % MaxInlineBits)); + Q_ASSERT(offset < data->bindingBitsArraySize); + bits[offset] |= QQmlData::bitFlagForBit(bit); } static void QQmlData_clearBit(QQmlData *data, int bit) { - if (data->bindingBitsSize > bit) { - if (data->bindingBitsSize == MaxInlineBits) - data->bindingBitsValue &= ~(BindingBitsType(1) << (bit % MaxInlineBits)); - else - data->bindingBits[bit / MaxInlineBits] &= ~(BindingBitsType(1) << (bit % MaxInlineBits)); + uint offset = QQmlData::offsetForBit(bit); + if (data->bindingBitsArraySize > offset) { + BindingBitsType *bits = (data->bindingBitsArraySize == InlineBindingArraySize) ? data->bindingBitsValue : data->bindingBits; + bits[offset] &= ~QQmlData::bitFlagForBit(bit); } } -- cgit v1.2.3 From 22e5f2f64369ffbdcb8184c9b35c946a1d20f4e1 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 11 Jan 2018 15:33:28 +0100 Subject: Revert "Allow canceling incubation" This reverts commit ca6b787a01ea289bd5c2a3e4ff3c7442a4ff58fc. This internal API was added as a workaround for Qt Quick Controls 2. It is no longer needed now that Qt Quick Controls 2 are using deferred execution. Task-number: QTBUG-50992 Change-Id: Iaddf22460f091743e1a68acd16813a28f3e82ecb Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlincubator.cpp | 17 ----------------- src/qml/qml/qqmlincubator_p.h | 3 --- src/qml/qml/qqmlobjectcreator.cpp | 15 --------------- src/qml/qml/qqmlobjectcreator_p.h | 1 - src/qml/qml/qqmlvme.cpp | 12 ------------ src/qml/qml/qqmlvme_p.h | 1 - 6 files changed, 49 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlincubator.cpp b/src/qml/qml/qqmlincubator.cpp index 93bb67de20..9855c27375 100644 --- a/src/qml/qml/qqmlincubator.cpp +++ b/src/qml/qml/qqmlincubator.cpp @@ -377,23 +377,6 @@ finishIncubate: } } -void QQmlIncubatorPrivate::cancel(QObject *object, QQmlContext *context) -{ - if (!context) - context = qmlContext(object); - if (!context) - return; - - QQmlContextData *data = QQmlContextData::get(context); - QQmlIncubatorPrivate *p = data->incubator; - if (!p) - return; - - p->vmeGuard.unguard(object); - if (!p->creator.isNull()) - p->creator->cancel(object); -} - /*! Incubate objects for \a msecs, or until there are no more objects to incubate. */ diff --git a/src/qml/qml/qqmlincubator_p.h b/src/qml/qml/qqmlincubator_p.h index 758e0a29f6..676ba1a29a 100644 --- a/src/qml/qml/qqmlincubator_p.h +++ b/src/qml/qml/qqmlincubator_p.h @@ -102,9 +102,6 @@ public: void forceCompletion(QQmlInstantiationInterrupt &i); void incubate(QQmlInstantiationInterrupt &i); - - // used by Qt Quick Controls 2 - Q_QML_PRIVATE_EXPORT static void cancel(QObject *object, QQmlContext *context = 0); }; QT_END_NAMESPACE diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 9c6630190f..dfb733f4cb 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -1349,21 +1349,6 @@ QQmlContextData *QQmlObjectCreator::finalize(QQmlInstantiationInterrupt &interru return sharedState->rootContext; } -void QQmlObjectCreator::cancel(QObject *object) -{ - int last = sharedState->allCreatedObjects.count() - 1; - int i = last; - while (i >= 0) { - if (sharedState->allCreatedObjects.at(i) == object) { - if (i < last) - qSwap(sharedState->allCreatedObjects[i], sharedState->allCreatedObjects[last]); - sharedState->allCreatedObjects.pop(); - break; - } - --i; - } -} - void QQmlObjectCreator::clear() { if (phase == Done || phase == Finalizing || phase == Startup) diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h index e2371cb4f1..4536b2e1af 100644 --- a/src/qml/qml/qqmlobjectcreator_p.h +++ b/src/qml/qml/qqmlobjectcreator_p.h @@ -92,7 +92,6 @@ public: bool populateDeferredProperties(QObject *instance, QQmlData::DeferredData *deferredData); bool populateDeferredBinding(const QQmlProperty &qmlProperty, QQmlData::DeferredData *deferredData, const QV4::CompiledData::Binding *binding); QQmlContextData *finalize(QQmlInstantiationInterrupt &interrupt); - void cancel(QObject *object); void clear(); QQmlComponentAttached **componentAttachment() const { return &sharedState->componentAttached; } diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp index c60f4edc80..72d4ab7e8f 100644 --- a/src/qml/qml/qqmlvme.cpp +++ b/src/qml/qml/qqmlvme.cpp @@ -120,18 +120,6 @@ void QQmlVMEGuard::guard(QQmlObjectCreator *creator) m_contexts[0] = creator->parentContextData(); } -void QQmlVMEGuard::unguard(QObject *object) -{ - for (int ii = 0; ii < m_objectCount; ++ii) { - if (m_objects[ii] == object) { - if (ii < m_objectCount - 1) - ::memmove((void *) m_objects[ii], (void *) m_objects[ii + 1], sizeof(QPointer *)); - delete m_objects[--m_objectCount]; - break; - } - } -} - void QQmlVMEGuard::clear() { delete [] m_objects; diff --git a/src/qml/qml/qqmlvme_p.h b/src/qml/qml/qqmlvme_p.h index 9585b5b6df..99d63380ad 100644 --- a/src/qml/qml/qqmlvme_p.h +++ b/src/qml/qml/qqmlvme_p.h @@ -131,7 +131,6 @@ public: ~QQmlVMEGuard(); void guard(QQmlObjectCreator *); - void unguard(QObject *); void clear(); bool isOK() const; -- cgit v1.2.3 From 859a7b7da05040e33d886b4257e81bd278e0238b Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 17 Jan 2018 09:59:35 +0100 Subject: Prevent a QVector detach Change-Id: Ibda07de7a83cf9a1434532c485583b8b49b0a605 Reviewed-by: Lars Knoll --- src/qml/qml/qqmlobjectcreator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index dfb733f4cb..f85d9ee639 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -879,7 +879,7 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con QQmlPropertyPrivate::removeBinding(_bindingTarget, QQmlPropertyIndex(property->coreIndex())); if (binding->type == QV4::CompiledData::Binding::Type_Script) { - QV4::Function *runtimeFunction = compilationUnit->runtimeFunctions[binding->value.compiledScriptIndex]; + QV4::Function *runtimeFunction = compilationUnit->runtimeFunctions.at(binding->value.compiledScriptIndex); QV4::Scope scope(v4); QV4::Scoped qmlContext(scope, currentQmlContext()); -- cgit v1.2.3 From e4ffad84fecebb3c1fc554b3252fd5d059c0ff38 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 16 Jan 2018 09:29:59 +0100 Subject: Speed up PropertyChange state application Every time we decode a potential binding of a PropertyChanges{} object, we call qmlContext(this) and we go through a full QQmlProperty construction (which involves property name decoding by dots and property lookups), just to determine if we're doing a binding on a property or a signal. QQmlProperty::isSignalProperty() will only return true if the property is valid and if it's a "function" type. The QQmlProperty constructor on the other hand only constructs a valid regular property if it's _not_ a function type and a signal property _has_ to start with "on" followed by an upper case character. We can copy this shortcut out into decodeBinding() to avoid the QQmlProperty construction in the common case of plain property bindings. This is also legit in the scope of group properties, as signal bindings on group properties are not supported (we always use the state's target object for signal lookup, never the group object). In addition, avoid creating a public QQmlContext for the PropertyChange object by allowing for the construction of the QQmlProperty object via the QQmlContextData, as that's the only data structure we really need. These two changes used to be separate, but they need to go together to keep the tests passing, as the property validation and warning issuing is now moved from decodeBinding() into ::actions() itself. Shaves off 1.5% off delegates_item_states.qml Task-number: QTBUG-65708 Change-Id: I32a17d815bd3495a907a51068a971eb7cb69c6ef Reviewed-by: Lars Knoll --- src/qml/qml/qqmlproperty.cpp | 16 ++++++++++++++++ src/qml/qml/qqmlproperty_p.h | 2 ++ 2 files changed, 18 insertions(+) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index 9a138dcf80..b79418761b 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -223,6 +223,22 @@ QQmlProperty::QQmlProperty(QObject *obj, const QString &name, QQmlEngine *engine if (!isValid()) { d->object = 0; d->context = 0; d->engine = 0; } } +QQmlProperty QQmlPropertyPrivate::create(QObject *target, const QString &propertyName, QQmlContextData *context) +{ + QQmlProperty result; + auto d = new QQmlPropertyPrivate; + result.d = d; + d->context = context; + d->engine = context->engine; + d->initProperty(target, propertyName); + if (!result.isValid()) { + d->object = nullptr; + d->context = nullptr; + d->engine = nullptr; + } + return result; +} + QQmlPropertyPrivate::QQmlPropertyPrivate() : context(0), engine(0), object(0), isNameCached(false) { diff --git a/src/qml/qml/qqmlproperty_p.h b/src/qml/qml/qqmlproperty_p.h index 53062a2f13..7a66d8113c 100644 --- a/src/qml/qml/qqmlproperty_p.h +++ b/src/qml/qml/qqmlproperty_p.h @@ -144,6 +144,8 @@ public: static void flushSignal(const QObject *sender, int signal_index); static QVariant resolvedUrlSequence(const QVariant &value, QQmlContextData *context); + static QQmlProperty create(QObject *target, const QString &propertyName, QQmlContextData *context); + }; Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlPropertyPrivate::BindingFlags) -- cgit v1.2.3 From 15a81d9689cad5c957aed09161fdab253b27c130 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 16 Jan 2018 13:47:51 +0100 Subject: Optimize QQmlProperty constructor for the common property case The common case is that QQmlProperty is constructed on the property of an object, not a group property. Therefore we should do the QVector split on the property name by '.' only if a dot exists, and can avoid the allocation and deallocation of the vector. Shaves off ~1.2% off delegates_item_states.qml. Task-number: QTBUG-65708 Change-Id: Iffbde176e616beec0ae0a47216360558adc793ee Reviewed-by: Lars Knoll --- src/qml/qml/qqmlproperty.cpp | 136 ++++++++++++++++++++++--------------------- 1 file changed, 70 insertions(+), 66 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index b79418761b..50d9f13049 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -229,7 +229,7 @@ QQmlProperty QQmlPropertyPrivate::create(QObject *target, const QString &propert auto d = new QQmlPropertyPrivate; result.d = d; d->context = context; - d->engine = context->engine; + d->engine = context ? context->engine : nullptr; d->initProperty(target, propertyName); if (!result.isValid()) { d->object = nullptr; @@ -257,89 +257,93 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name) QQmlTypeNameCache *typeNameCache = context?context->imports:0; - const auto path = name.splitRef(QLatin1Char('.')); - if (path.isEmpty()) return; - QObject *currentObject = obj; - - // Everything up to the last property must be an "object type" property - for (int ii = 0; ii < path.count() - 1; ++ii) { - const QStringRef &pathName = path.at(ii); - - if (typeNameCache) { - QQmlTypeNameCache::Result r = typeNameCache->query(pathName); - if (r.isValid()) { - if (r.type.isValid()) { - QQmlEnginePrivate *enginePrivate = QQmlEnginePrivate::get(engine); - QQmlAttachedPropertiesFunc func = r.type.attachedPropertiesFunction(enginePrivate); - if (!func) return; // Not an attachable type - - currentObject = qmlAttachedPropertiesObjectById(r.type.attachedPropertiesId(enginePrivate), currentObject); - if (!currentObject) return; // Something is broken with the attachable type - } else if (r.importNamespace) { - if ((ii + 1) == path.count()) return; // No type following the namespace - - ++ii; r = typeNameCache->query(path.at(ii), r.importNamespace); - if (!r.type.isValid()) return; // Invalid type in namespace - - QQmlEnginePrivate *enginePrivate = QQmlEnginePrivate::get(engine); - QQmlAttachedPropertiesFunc func = r.type.attachedPropertiesFunction(enginePrivate); - if (!func) return; // Not an attachable type - - currentObject = qmlAttachedPropertiesObjectById(r.type.attachedPropertiesId(enginePrivate), currentObject); - if (!currentObject) return; // Something is broken with the attachable type - - } else if (r.scriptIndex != -1) { - return; // Not a type - } else { - Q_ASSERT(!"Unreachable"); + QVector path; + QStringRef terminal(&name); + + if (name.contains(QLatin1Char('.'))) { + path = name.splitRef(QLatin1Char('.')); + if (path.isEmpty()) return; + + // Everything up to the last property must be an "object type" property + for (int ii = 0; ii < path.count() - 1; ++ii) { + const QStringRef &pathName = path.at(ii); + + if (typeNameCache) { + QQmlTypeNameCache::Result r = typeNameCache->query(pathName); + if (r.isValid()) { + if (r.type.isValid()) { + QQmlEnginePrivate *enginePrivate = QQmlEnginePrivate::get(engine); + QQmlAttachedPropertiesFunc func = r.type.attachedPropertiesFunction(enginePrivate); + if (!func) return; // Not an attachable type + + currentObject = qmlAttachedPropertiesObjectById(r.type.attachedPropertiesId(enginePrivate), currentObject); + if (!currentObject) return; // Something is broken with the attachable type + } else if (r.importNamespace) { + if ((ii + 1) == path.count()) return; // No type following the namespace + + ++ii; r = typeNameCache->query(path.at(ii), r.importNamespace); + if (!r.type.isValid()) return; // Invalid type in namespace + + QQmlEnginePrivate *enginePrivate = QQmlEnginePrivate::get(engine); + QQmlAttachedPropertiesFunc func = r.type.attachedPropertiesFunction(enginePrivate); + if (!func) return; // Not an attachable type + + currentObject = qmlAttachedPropertiesObjectById(r.type.attachedPropertiesId(enginePrivate), currentObject); + if (!currentObject) return; // Something is broken with the attachable type + + } else if (r.scriptIndex != -1) { + return; // Not a type + } else { + Q_ASSERT(!"Unreachable"); + } + continue; } - continue; + } - } + QQmlPropertyData local; + QQmlPropertyData *property = + QQmlPropertyCache::property(engine, currentObject, pathName, context, local); - QQmlPropertyData local; - QQmlPropertyData *property = - QQmlPropertyCache::property(engine, currentObject, pathName, context, local); + if (!property) return; // Not a property + if (property->isFunction()) + return; // Not an object property - if (!property) return; // Not a property - if (property->isFunction()) - return; // Not an object property + if (ii == (path.count() - 2) && QQmlValueTypeFactory::isValueType(property->propType())) { + // We're now at a value type property + const QMetaObject *valueTypeMetaObject = QQmlValueTypeFactory::metaObjectForMetaType(property->propType()); + if (!valueTypeMetaObject) return; // Not a value type - if (ii == (path.count() - 2) && QQmlValueTypeFactory::isValueType(property->propType())) { - // We're now at a value type property - const QMetaObject *valueTypeMetaObject = QQmlValueTypeFactory::metaObjectForMetaType(property->propType()); - if (!valueTypeMetaObject) return; // Not a value type + int idx = valueTypeMetaObject->indexOfProperty(path.last().toUtf8().constData()); + if (idx == -1) return; // Value type property does not exist - int idx = valueTypeMetaObject->indexOfProperty(path.last().toUtf8().constData()); - if (idx == -1) return; // Value type property does not exist + QMetaProperty vtProp = valueTypeMetaObject->property(idx); - QMetaProperty vtProp = valueTypeMetaObject->property(idx); + Q_ASSERT(vtProp.userType() <= 0x0000FFFF); + Q_ASSERT(idx <= 0x0000FFFF); - Q_ASSERT(vtProp.userType() <= 0x0000FFFF); - Q_ASSERT(idx <= 0x0000FFFF); + object = currentObject; + core = *property; + valueTypeData.setFlags(QQmlPropertyData::flagsForProperty(vtProp)); + valueTypeData.setPropType(vtProp.userType()); + valueTypeData.setCoreIndex(idx); - object = currentObject; - core = *property; - valueTypeData.setFlags(QQmlPropertyData::flagsForProperty(vtProp)); - valueTypeData.setPropType(vtProp.userType()); - valueTypeData.setCoreIndex(idx); + return; + } else { + if (!property->isQObject()) + return; // Not an object property - return; - } else { - if (!property->isQObject()) - return; // Not an object property + property->readProperty(currentObject, ¤tObject); + if (!currentObject) return; // No value - property->readProperty(currentObject, ¤tObject); - if (!currentObject) return; // No value + } } + terminal = path.last(); } - const QStringRef &terminal = path.last(); - if (terminal.count() >= 3 && terminal.at(0) == QLatin1Char('o') && terminal.at(1) == QLatin1Char('n') && -- cgit v1.2.3 From 95892bd7b20a881c9a50791d9c1a9309f2f01d28 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 17 Jan 2018 15:54:02 +0100 Subject: Allow for currentQmlContext to be inlined Change-Id: Ic2a98a3a4b4362036222df05a92c0bed633c1d1c Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlobjectcreator.cpp | 7 ++----- src/qml/qml/qqmlobjectcreator_p.h | 11 ++++++++++- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index f85d9ee639..ad9687574f 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -1103,12 +1103,9 @@ void QQmlObjectCreator::registerObjectWithContextById(const QV4::CompiledData::O context->setIdProperty(object->id, instance); } -QV4::Heap::QmlContext *QQmlObjectCreator::currentQmlContext() +void QQmlObjectCreator::createQmlContext() { - if (!_qmlContext->isManaged()) - _qmlContext->setM(QV4::QmlContext::create(v4->rootContext(), context, _scopeObject)); - - return _qmlContext->d(); + _qmlContext->setM(QV4::QmlContext::create(v4->rootContext(), context, _scopeObject)); } QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isContextObject) diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h index 4536b2e1af..82fe22af72 100644 --- a/src/qml/qml/qqmlobjectcreator_p.h +++ b/src/qml/qml/qqmlobjectcreator_p.h @@ -123,7 +123,8 @@ private: void registerObjectWithContextById(const QV4::CompiledData::Object *object, QObject *instance) const; - QV4::Heap::QmlContext *currentQmlContext(); + inline QV4::Heap::QmlContext *currentQmlContext(); + Q_NEVER_INLINE void createQmlContext(); enum Phase { Startup, @@ -173,6 +174,14 @@ private: QRecursionWatcher watcher; }; +QV4::Heap::QmlContext *QQmlObjectCreator::currentQmlContext() +{ + if (Q_UNLIKELY(!_qmlContext->isManaged())) + createQmlContext(); // less common slow path + + return _qmlContext->d(); +} + QT_END_NAMESPACE #endif // QQMLOBJECTCREATOR_P_H -- cgit v1.2.3 From e5b157275d7b924e1a0f39d27958a7ad1eed9cef Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 22 Jan 2018 16:46:03 +0100 Subject: Add support for compiling QML/JS files ahead of time in resources This is bringing over the loading infrastructure from the Qt Quick Compiler that allows embedding qml/js files in resources and compiling them ahead of time. At the moment, the approach of generating one cpp file per qml/js file and the loader stub is needed because the build system does not support dynamic resource generation. In addition, as per QTBUG-60961, we must ensure that the generated data structures are aligned. To retain compatibility this is enabled via CONFIG += qtquickcompiler, but we may need to find a new name (but should keep the old one in any case). Task-number: QTBUG-60961 Change-Id: Ia9839bf98d3af4c50636b6e06815364a9fc7ee57 Reviewed-by: Lars Knoll --- src/qml/qml/qqmlprivate.h | 2 +- src/qml/qml/qqmltypeloader.cpp | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlprivate.h b/src/qml/qml/qqmlprivate.h index eeb5b4c302..7b7e2363e4 100644 --- a/src/qml/qml/qqmlprivate.h +++ b/src/qml/qml/qqmlprivate.h @@ -285,7 +285,7 @@ namespace QQmlPrivate struct CachedQmlUnit { const QV4::CompiledData::Unit *qmlData; QV4::CompilationUnitFactoryFunction createCompilationUnit; - QmlIR::IRLoaderFunction loadIR; + void *unused; }; typedef const CachedQmlUnit *(*QmlUnitCacheLookupFunction)(const QUrl &url); diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 42d82afef4..132c0f64c0 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -2428,15 +2428,10 @@ void QQmlTypeData::dataReceived(const SourceCodeData &data) void QQmlTypeData::initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *unit) { m_document.reset(new QmlIR::Document(isDebugging())); - if (unit->loadIR) { - // old code path for older generated code - unit->loadIR(m_document.data(), unit); - } else { - // new code path - QmlIR::IRLoader loader(unit->qmlData, m_document.data()); - loader.load(); - m_document->javaScriptCompilationUnit.adopt(unit->createCompilationUnit()); - } + QmlIR::IRLoader loader(unit->qmlData, m_document.data()); + loader.load(); + m_document->jsModule.fileName = finalUrlString(); + m_document->javaScriptCompilationUnit.adopt(unit->createCompilationUnit()); continueLoadFromIR(); } -- cgit v1.2.3 From 6ef66a5dfe938a23c67c0aef0d6c7ebc98b8cca8 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 23 Jan 2018 14:14:47 +0100 Subject: Remove private API dependency of qmlcachegen generated code Since the compilation unit does not have a backend anymore, we can create it in QtQml itself instead of in generated stub code. That removes the last dependency to private headers in the generated code. Change-Id: I186fc5bd679476b1a4714e4e3ba0ac00b55676cf Reviewed-by: Lars Knoll --- src/qml/qml/qqmlprivate.h | 5 ++--- src/qml/qml/qqmltypeloader.cpp | 8 +++++--- src/qml/qml/qqmltypeloader_p.h | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlprivate.h b/src/qml/qml/qqmlprivate.h index 7b7e2363e4..b9e9d5e59e 100644 --- a/src/qml/qml/qqmlprivate.h +++ b/src/qml/qml/qqmlprivate.h @@ -69,7 +69,6 @@ namespace CompiledData { struct Unit; struct CompilationUnit; } -typedef CompiledData::CompilationUnit *(*CompilationUnitFactoryFunction)(); } namespace QmlIR { struct Document; @@ -284,8 +283,8 @@ namespace QQmlPrivate struct CachedQmlUnit { const QV4::CompiledData::Unit *qmlData; - QV4::CompilationUnitFactoryFunction createCompilationUnit; - void *unused; + void *unused1; + void *unused2; }; typedef const CachedQmlUnit *(*QmlUnitCacheLookupFunction)(const QUrl &url); diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 132c0f64c0..4a22996a52 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -2431,7 +2431,7 @@ void QQmlTypeData::initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *un QmlIR::IRLoader loader(unit->qmlData, m_document.data()); loader.load(); m_document->jsModule.fileName = finalUrlString(); - m_document->javaScriptCompilationUnit.adopt(unit->createCompilationUnit()); + m_document->javaScriptCompilationUnit.adopt(new QV4::CompiledData::CompilationUnit(unit->qmlData)); continueLoadFromIR(); } @@ -3013,7 +3013,9 @@ void QQmlScriptBlob::dataReceived(const SourceCodeData &data) void QQmlScriptBlob::initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *unit) { - initializeFromCompilationUnit(unit->createCompilationUnit()); + QQmlRefPointer compilationUnit; + compilationUnit.adopt(new QV4::CompiledData::CompilationUnit(unit->qmlData)); + initializeFromCompilationUnit(compilationUnit); } void QQmlScriptBlob::done() @@ -3075,7 +3077,7 @@ void QQmlScriptBlob::scriptImported(QQmlScriptBlob *blob, const QV4::CompiledDat m_scripts << ref; } -void QQmlScriptBlob::initializeFromCompilationUnit(QV4::CompiledData::CompilationUnit *unit) +void QQmlScriptBlob::initializeFromCompilationUnit(const QQmlRefPointer &unit) { Q_ASSERT(!m_scriptData); m_scriptData = new QQmlScriptData(); diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h index 0ec9f9240e..875a681aea 100644 --- a/src/qml/qml/qqmltypeloader_p.h +++ b/src/qml/qml/qqmltypeloader_p.h @@ -575,7 +575,7 @@ protected: private: void scriptImported(QQmlScriptBlob *blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &nameSpace) override; - void initializeFromCompilationUnit(QV4::CompiledData::CompilationUnit *unit); + void initializeFromCompilationUnit(const QQmlRefPointer &unit); QList m_scripts; QQmlScriptData *m_scriptData; -- cgit v1.2.3 From eace041161a03a849d3896af65493b7885cecc04 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 23 Jan 2018 14:30:09 +0100 Subject: Get rid of internal QQmlPrivate::CachedQmlUnit interface part 1 Within QtQml we don't need to use this data structure anymore, we can use its one member directly Change-Id: Id850e12918257c7af3c97bfef41d1e93578842d2 Reviewed-by: Lars Knoll --- src/qml/qml/qqmlmetatype.cpp | 6 +++--- src/qml/qml/qqmlmetatype_p.h | 2 +- src/qml/qml/qqmltypeloader.cpp | 38 +++++++++++++++++++------------------- src/qml/qml/qqmltypeloader_p.h | 14 +++++++------- 4 files changed, 30 insertions(+), 30 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index 88fdb14f4d..40864de366 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -2538,16 +2538,16 @@ QList QQmlMetaType::qmlSingletonTypes() return retn; } -const QQmlPrivate::CachedQmlUnit *QQmlMetaType::findCachedCompilationUnit(const QUrl &uri) +const QV4::CompiledData::Unit *QQmlMetaType::findCachedCompilationUnit(const QUrl &uri) { QMutexLocker lock(metaTypeDataLock()); QQmlMetaTypeData *data = metaTypeData(); for (const auto lookup : qAsConst(data->lookupCachedQmlUnit)) { if (const QQmlPrivate::CachedQmlUnit *unit = lookup(uri)) - return unit; + return unit->qmlData; } - return 0; + return nullptr; } /*! diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h index f381b4a010..cee1070a09 100644 --- a/src/qml/qml/qqmlmetatype_p.h +++ b/src/qml/qml/qqmlmetatype_p.h @@ -133,7 +133,7 @@ public: static QList parentFunctions(); - static const QQmlPrivate::CachedQmlUnit *findCachedCompilationUnit(const QUrl &uri); + static const QV4::CompiledData::Unit *findCachedCompilationUnit(const QUrl &uri); static bool namespaceContainsRegistrations(const QString &, int majorVersion); diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 4a22996a52..fab5cf6c1f 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -156,8 +156,8 @@ public: void loadAsync(QQmlDataBlob *b); void loadWithStaticData(QQmlDataBlob *b, const QByteArray &); void loadWithStaticDataAsync(QQmlDataBlob *b, const QByteArray &); - void loadWithCachedUnit(QQmlDataBlob *b, const QQmlPrivate::CachedQmlUnit *unit); - void loadWithCachedUnitAsync(QQmlDataBlob *b, const QQmlPrivate::CachedQmlUnit *unit); + void loadWithCachedUnit(QQmlDataBlob *b, const QV4::CompiledData::Unit *unit); + void loadWithCachedUnitAsync(QQmlDataBlob *b, const QV4::CompiledData::Unit *unit); void callCompleted(QQmlDataBlob *b); void callDownloadProgressChanged(QQmlDataBlob *b, qreal p); void initializeEngine(QQmlExtensionInterface *, const char *); @@ -168,7 +168,7 @@ protected: private: void loadThread(QQmlDataBlob *b); void loadWithStaticDataThread(QQmlDataBlob *b, const QByteArray &); - void loadWithCachedUnitThread(QQmlDataBlob *b, const QQmlPrivate::CachedQmlUnit *unit); + void loadWithCachedUnitThread(QQmlDataBlob *b, const QV4::CompiledData::Unit *unit); void callCompletedMain(QQmlDataBlob *b); void callDownloadProgressChangedMain(QQmlDataBlob *b, qreal p); void initializeEngineMain(QQmlExtensionInterface *iface, const char *uri); @@ -832,13 +832,13 @@ void QQmlTypeLoaderThread::loadWithStaticDataAsync(QQmlDataBlob *b, const QByteA postMethodToThread(&This::loadWithStaticDataThread, b, d); } -void QQmlTypeLoaderThread::loadWithCachedUnit(QQmlDataBlob *b, const QQmlPrivate::CachedQmlUnit *unit) +void QQmlTypeLoaderThread::loadWithCachedUnit(QQmlDataBlob *b, const QV4::CompiledData::Unit *unit) { b->addref(); callMethodInThread(&This::loadWithCachedUnitThread, b, unit); } -void QQmlTypeLoaderThread::loadWithCachedUnitAsync(QQmlDataBlob *b, const QQmlPrivate::CachedQmlUnit *unit) +void QQmlTypeLoaderThread::loadWithCachedUnitAsync(QQmlDataBlob *b, const QV4::CompiledData::Unit *unit) { b->addref(); postMethodToThread(&This::loadWithCachedUnitThread, b, unit); @@ -884,7 +884,7 @@ void QQmlTypeLoaderThread::loadWithStaticDataThread(QQmlDataBlob *b, const QByte b->release(); } -void QQmlTypeLoaderThread::loadWithCachedUnitThread(QQmlDataBlob *b, const QQmlPrivate::CachedQmlUnit *unit) +void QQmlTypeLoaderThread::loadWithCachedUnitThread(QQmlDataBlob *b, const QV4::CompiledData::Unit *unit) { m_loader->loadWithCachedUnitThread(b, unit); b->release(); @@ -1017,8 +1017,8 @@ struct StaticLoader { }; struct CachedLoader { - const QQmlPrivate::CachedQmlUnit *unit; - CachedLoader(const QQmlPrivate::CachedQmlUnit *unit) : unit(unit) {} + const QV4::CompiledData::Unit *unit; + CachedLoader(const QV4::CompiledData::Unit *unit) : unit(unit) {} void loadThread(QQmlTypeLoader *loader, QQmlDataBlob *blob) const { @@ -1090,7 +1090,7 @@ void QQmlTypeLoader::loadWithStaticData(QQmlDataBlob *blob, const QByteArray &da doLoad(StaticLoader(data), blob, mode); } -void QQmlTypeLoader::loadWithCachedUnit(QQmlDataBlob *blob, const QQmlPrivate::CachedQmlUnit *unit, Mode mode) +void QQmlTypeLoader::loadWithCachedUnit(QQmlDataBlob *blob, const QV4::CompiledData::Unit *unit, Mode mode) { doLoad(CachedLoader(unit), blob, mode); } @@ -1102,7 +1102,7 @@ void QQmlTypeLoader::loadWithStaticDataThread(QQmlDataBlob *blob, const QByteArr setData(blob, data); } -void QQmlTypeLoader::loadWithCachedUnitThread(QQmlDataBlob *blob, const QQmlPrivate::CachedQmlUnit *unit) +void QQmlTypeLoader::loadWithCachedUnitThread(QQmlDataBlob *blob, const QV4::CompiledData::Unit *unit) { ASSERT_LOADTHREAD(); @@ -1289,7 +1289,7 @@ void QQmlTypeLoader::setData(QQmlDataBlob *blob, const QQmlDataBlob::SourceCodeD blob->tryDone(); } -void QQmlTypeLoader::setCachedUnit(QQmlDataBlob *blob, const QQmlPrivate::CachedQmlUnit *unit) +void QQmlTypeLoader::setCachedUnit(QQmlDataBlob *blob, const QV4::CompiledData::Unit *unit) { QML_MEMORY_SCOPE_URL(blob->url()); QQmlCompilingProfiler prof(profiler(), blob); @@ -1666,7 +1666,7 @@ QQmlTypeData *QQmlTypeLoader::getType(const QUrl &url, Mode mode) typeData = new QQmlTypeData(url, this); // TODO: if (compiledData == 0), is it safe to omit this insertion? m_typeCache.insert(url, typeData); - if (const QQmlPrivate::CachedQmlUnit *cachedUnit = QQmlMetaType::findCachedCompilationUnit(typeData->url())) { + if (const QV4::CompiledData::Unit *cachedUnit = QQmlMetaType::findCachedCompilationUnit(typeData->url())) { QQmlTypeLoader::loadWithCachedUnit(typeData, cachedUnit, mode); } else { QQmlTypeLoader::load(typeData, mode); @@ -1723,7 +1723,7 @@ QQmlScriptBlob *QQmlTypeLoader::getScript(const QUrl &url) scriptBlob = new QQmlScriptBlob(url, this); m_scriptCache.insert(url, scriptBlob); - if (const QQmlPrivate::CachedQmlUnit *cachedUnit = QQmlMetaType::findCachedCompilationUnit(scriptBlob->url())) { + if (const QV4::CompiledData::Unit *cachedUnit = QQmlMetaType::findCachedCompilationUnit(scriptBlob->url())) { QQmlTypeLoader::loadWithCachedUnit(scriptBlob, cachedUnit); } else { QQmlTypeLoader::load(scriptBlob); @@ -2425,13 +2425,13 @@ void QQmlTypeData::dataReceived(const SourceCodeData &data) continueLoadFromIR(); } -void QQmlTypeData::initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *unit) +void QQmlTypeData::initializeFromCachedUnit(const QV4::CompiledData::Unit *unit) { m_document.reset(new QmlIR::Document(isDebugging())); - QmlIR::IRLoader loader(unit->qmlData, m_document.data()); + QmlIR::IRLoader loader(unit, m_document.data()); loader.load(); m_document->jsModule.fileName = finalUrlString(); - m_document->javaScriptCompilationUnit.adopt(new QV4::CompiledData::CompilationUnit(unit->qmlData)); + m_document->javaScriptCompilationUnit.adopt(new QV4::CompiledData::CompilationUnit(unit)); continueLoadFromIR(); } @@ -3011,10 +3011,10 @@ void QQmlScriptBlob::dataReceived(const SourceCodeData &data) initializeFromCompilationUnit(unit); } -void QQmlScriptBlob::initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *unit) +void QQmlScriptBlob::initializeFromCachedUnit(const QV4::CompiledData::Unit *unit) { QQmlRefPointer compilationUnit; - compilationUnit.adopt(new QV4::CompiledData::CompilationUnit(unit->qmlData)); + compilationUnit.adopt(new QV4::CompiledData::CompilationUnit(unit)); initializeFromCompilationUnit(compilationUnit); } @@ -3153,7 +3153,7 @@ void QQmlQmldirData::dataReceived(const SourceCodeData &data) } } -void QQmlQmldirData::initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *) +void QQmlQmldirData::initializeFromCachedUnit(const QV4::CompiledData::Unit *) { Q_UNIMPLEMENTED(); } diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h index 875a681aea..d5386e48ed 100644 --- a/src/qml/qml/qqmltypeloader_p.h +++ b/src/qml/qml/qqmltypeloader_p.h @@ -157,7 +157,7 @@ protected: // Callbacks made in load thread virtual void dataReceived(const SourceCodeData &) = 0; - virtual void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit*) = 0; + virtual void initializeFromCachedUnit(const QV4::CompiledData::Unit*) = 0; virtual void done(); #if QT_CONFIG(qml_network) virtual void networkError(QNetworkReply::NetworkError); @@ -316,7 +316,7 @@ public: void load(QQmlDataBlob *, Mode = PreferSynchronous); void loadWithStaticData(QQmlDataBlob *, const QByteArray &, Mode = PreferSynchronous); - void loadWithCachedUnit(QQmlDataBlob *blob, const QQmlPrivate::CachedQmlUnit *unit, Mode mode = PreferSynchronous); + void loadWithCachedUnit(QQmlDataBlob *blob, const QV4::CompiledData::Unit *unit, Mode mode = PreferSynchronous); QQmlEngine *engine() const; void initializeEngine(QQmlExtensionInterface *, const char *); @@ -342,7 +342,7 @@ private: void loadThread(QQmlDataBlob *); void loadWithStaticDataThread(QQmlDataBlob *, const QByteArray &); - void loadWithCachedUnitThread(QQmlDataBlob *blob, const QQmlPrivate::CachedQmlUnit *unit); + void loadWithCachedUnitThread(QQmlDataBlob *blob, const QV4::CompiledData::Unit *unit); #if QT_CONFIG(qml_network) void networkReplyFinished(QNetworkReply *); void networkReplyProgress(QNetworkReply *, qint64, qint64); @@ -353,7 +353,7 @@ private: void setData(QQmlDataBlob *, const QByteArray &); void setData(QQmlDataBlob *, const QString &fileName); void setData(QQmlDataBlob *, const QQmlDataBlob::SourceCodeData &); - void setCachedUnit(QQmlDataBlob *blob, const QQmlPrivate::CachedQmlUnit *unit); + void setCachedUnit(QQmlDataBlob *blob, const QV4::CompiledData::Unit *unit); template struct TypedCallback @@ -455,7 +455,7 @@ protected: void done() override; void completed() override; void dataReceived(const SourceCodeData &) override; - void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *unit) override; + void initializeFromCachedUnit(const QV4::CompiledData::Unit *unit) override; void allDependenciesDone() override; void downloadProgressChanged(qreal) override; @@ -568,7 +568,7 @@ public: protected: void dataReceived(const SourceCodeData &) override; - void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *unit) override; + void initializeFromCachedUnit(const QV4::CompiledData::Unit *unit) override; void done() override; QString stringAt(int index) const override; @@ -599,7 +599,7 @@ public: protected: void dataReceived(const SourceCodeData &) override; - void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit*) override; + void initializeFromCachedUnit(const QV4::CompiledData::Unit *) override; private: QString m_content; -- cgit v1.2.3 From 406ef45aaa3e84eb402a451eb4900afa17d20ea9 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 30 Jan 2018 09:47:06 +0100 Subject: Fix exposure of -1 as enum value in QML exposed C++ singletons When a C++ singleton has an enum with the value -1, we would expose that value correctly when taking the accelerated property access code path in the optimizer, but when going through the slower QQmlTypeWrapper we would return undefined. This turned out to be a silly logic error that assumed that -1 is not a valid value for an enum and instead indicates an enum value not present. [ChangeLog][Qml] Fix -1 as enum value in QML exposed C++ singletons showing up as undefined. Task-number: QTBUG-66067 Change-Id: Ib66dad7a4b59822b2c40ad6bd9af4b72469582e9 Reviewed-by: Lars Knoll Reviewed-by: Michael Brasser --- src/qml/qml/qqmltypewrapper.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp index d4e1910a72..0fae76066d 100644 --- a/src/qml/qml/qqmltypewrapper.cpp +++ b/src/qml/qml/qqmltypewrapper.cpp @@ -133,11 +133,11 @@ ReturnedValue QmlTypeWrapper::create(QV4::ExecutionEngine *engine, QObject *o, Q } static int enumForSingleton(QV4::ExecutionEngine *v4, String *name, QObject *qobjectSingleton, - const QQmlType &type) + const QQmlType &type, bool *ok) { - bool ok; - int value = type.enumValue(QQmlEnginePrivate::get(v4->qmlEngine()), name, &ok); - if (ok) + Q_ASSERT(ok != nullptr); + int value = type.enumValue(QQmlEnginePrivate::get(v4->qmlEngine()), name, ok); + if (*ok) return value; // ### Optimize @@ -145,10 +145,11 @@ static int enumForSingleton(QV4::ExecutionEngine *v4, String *name, QObject *qob const QMetaObject *metaObject = qobjectSingleton->metaObject(); for (int ii = metaObject->enumeratorCount() - 1; ii >= 0; --ii) { QMetaEnum e = metaObject->enumerator(ii); - value = e.keyToValue(enumName.constData(), &ok); - if (ok) + value = e.keyToValue(enumName.constData(), ok); + if (*ok) return value; } + *ok = false; return -1; } @@ -191,8 +192,9 @@ ReturnedValue QmlTypeWrapper::get(const Managed *m, String *name, bool *hasPrope // check for enum value const bool includeEnums = w->d()->mode == Heap::QmlTypeWrapper::IncludeEnums; if (includeEnums && name->startsWithUpper()) { - const int value = enumForSingleton(v4, name, qobjectSingleton, type); - if (value != -1) + bool ok = false; + const int value = enumForSingleton(v4, name, qobjectSingleton, type, &ok); + if (ok) return QV4::Primitive::fromInt32(value).asReturnedValue(); } @@ -204,8 +206,8 @@ ReturnedValue QmlTypeWrapper::get(const Managed *m, String *name, bool *hasPrope // Warn when attempting to access a lowercased enum value, singleton case if (!ok && includeEnums && !name->startsWithUpper()) { - const int value = enumForSingleton(v4, name, qobjectSingleton, type); - if (value != -1) + enumForSingleton(v4, name, qobjectSingleton, type, &ok); + if (ok) return throwLowercaseEnumError(v4, name, type); } -- cgit v1.2.3 From 1e350a8c98d9c98823dde83a6745d2f26a9c0785 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 24 Jan 2018 17:23:03 +0100 Subject: Disallow registration of types beginning with lowercase letters Allowing types with lowercase names causes ambiguity, as can be seen in QTBUG-43567 and the comment in IRBuilder::visit(), which explains that "the grammar can't distinguish between two different definitions" whose only difference is casing of the first letter. - Prevent registration (return -1 with e.g. qmlRegisterType()) when a type name doesn't begin with an uppercase letter. - Document the uppercase type name rule in more places. Change-Id: I4e522c65990f418eaafa45a256e3cb07a3e01ba4 Reviewed-by: Shawn Rutledge --- src/qml/qml/qqmlmetatype.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index 3a0d5c3daf..89f3ced2d6 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -1405,6 +1405,12 @@ QString registrationTypeString(QQmlType::RegistrationType typeType) bool checkRegistration(QQmlType::RegistrationType typeType, QQmlMetaTypeData *data, const char *uri, const QString &typeName, int majorVersion = -1) { if (!typeName.isEmpty()) { + if (typeName.at(0).isLower()) { + QString failure(QCoreApplication::translate("qmlRegisterType", "Invalid QML %1 name \"%2\"; type names must begin with an uppercase letter")); + data->typeRegistrationFailures.append(failure.arg(registrationTypeString(typeType)).arg(typeName)); + return false; + } + int typeNameLen = typeName.length(); for (int ii = 0; ii < typeNameLen; ++ii) { if (!(typeName.at(ii).isLetterOrNumber() || typeName.at(ii) == '_')) { @@ -1650,6 +1656,9 @@ int QQmlPrivate::qmlregister(RegistrationType type, void *data) else return -1; + if (!dtype.isValid()) + return -1; + QMutexLocker lock(metaTypeDataLock()); QQmlMetaTypeData *typeData = metaTypeData(); typeData->undeletableTypes.insert(dtype); -- cgit v1.2.3 From 8c0501855787986365519da12e9e580b30fb26af Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 29 Jan 2018 11:42:40 +0100 Subject: Fix dead lock / race in QML type loader when importing plugins When importing modules - in the QML loader thread - with plugins we keep globally track of the Qt plugins that we have loaded that contain QML modules, to ensure that we don't call the engine-independent registerTypes() function on the plugin multiple times. After registerTypes() we may also call initializeEngine() on the plugin for the engine-specific initialization, which - as a QQmlEngine is provided as parameter - must happen in the gui thread. For that we issue a thread-blocking call that waits until the gui thread has woken up and processed the event/call. During that time the global plugin lock is held by that QML loader thread. If meanwhile the gui thread instantiates a second QQmlEngine and attempts to issue a synchronous type compilation (using QQmlComponent::CompilationMode::PreferSynchronous), then gui thread is blocking and waiting for its own QML loader thread to complete the type compilation, which may involve processing an import that requires loading a plugin. Now this second QML loader thread is blocked by trying to acquire the global plugin registry lock (qmlEnginePluginsWithRegisteredTypes()->mutex) in qqmlimports.cpp. Now the first QML loader thread is blocked because the gui thread is not processing the call events for the first engine. The gui thread is blocked waiting for the second QML loader thread, which in turn is stuck trying to acquire the lock held by the first QML loader thread. The provided test case triggers this scenario, although through a slightly different way. It's not possible to wait in the gui thread for the plugin lock to be held in a loader thread via the registerTypes callback, as that also acquires the QQmlMetaType lock that will interfere with the test-case. However the same plugin lock issue appears when the first QML engine is located in a different thread altogether. In that case the dispatch to the engine thread /works/, but it won't be the gui thread but instead the secondary helper thread of the test case that will sit in our initializeEngine() callback. This bug was spotted in production customer code with backtraces pointing into the three locations described above: One QML loader thread blocking on a call to the gui thread, the gui thread blocking on a second QML loader thread and that one blocking on acquisition of the plugin lock held by the first. Fortunately it is not necessary to hold on to the global plugin lock when doing the engine specific initialization. That allows the second QML loader thread to complete its work and finally resume the GUI thread's event loop. Change-Id: If757b3fc9b473f42b266427e55d7a1572b937515 Reviewed-by: Ulf Hermann --- src/qml/qml/qqmlimport.cpp | 150 +++++++++++++++++++++++++-------------------- 1 file changed, 84 insertions(+), 66 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index c8d17c4b8e..f43ffb4c3c 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -2056,29 +2056,38 @@ bool QQmlImportDatabase::importStaticPlugin(QObject *instance, const QString &ba // Dynamic plugins are differentiated by their filepath. For static plugins we // don't have that information so we use their address as key instead. const QString uniquePluginID = QString::asprintf("%p", instance); - StringRegisteredPluginMap *plugins = qmlEnginePluginsWithRegisteredTypes(); - QMutexLocker lock(&plugins->mutex); + { + StringRegisteredPluginMap *plugins = qmlEnginePluginsWithRegisteredTypes(); + QMutexLocker lock(&plugins->mutex); - // Plugin types are global across all engines and should only be - // registered once. But each engine still needs to be initialized. - bool typesRegistered = plugins->contains(uniquePluginID); - bool engineInitialized = initializedPlugins.contains(uniquePluginID); + // Plugin types are global across all engines and should only be + // registered once. But each engine still needs to be initialized. + bool typesRegistered = plugins->contains(uniquePluginID); - if (typesRegistered) { - Q_ASSERT_X(plugins->value(uniquePluginID).uri == uri, - "QQmlImportDatabase::importStaticPlugin", - "Internal error: Static plugin imported previously with different uri"); - } else { - RegisteredPlugin plugin; - plugin.uri = uri; - plugin.loader = 0; - plugins->insert(uniquePluginID, plugin); + if (typesRegistered) { + Q_ASSERT_X(plugins->value(uniquePluginID).uri == uri, + "QQmlImportDatabase::importStaticPlugin", + "Internal error: Static plugin imported previously with different uri"); + } else { + RegisteredPlugin plugin; + plugin.uri = uri; + plugin.loader = 0; + plugins->insert(uniquePluginID, plugin); - if (!registerPluginTypes(instance, basePath, uri, typeNamespace, vmaj, errors)) - return false; + if (!registerPluginTypes(instance, basePath, uri, typeNamespace, vmaj, errors)) + return false; + } + + // Release the lock on plugins early as we're done with the global part. Releasing the lock + // also allows other QML loader threads to acquire the lock while this thread is blocking + // in the initializeEngine call to the gui thread (which in turn may be busy waiting for + // other QML loader threads and thus not process the initializeEngine call). } - if (!engineInitialized) { + // The plugin's per-engine initialization does not need lock protection, as this function is + // only called from the engine specific loader thread and importDynamicPlugin as well as + // importStaticPlugin are the only places of access. + if (!initializedPlugins.contains(uniquePluginID)) { initializedPlugins.insert(uniquePluginID); if (QQmlExtensionInterface *eiface = qobject_cast(instance)) { @@ -2100,68 +2109,77 @@ bool QQmlImportDatabase::importDynamicPlugin(const QString &filePath, const QStr QFileInfo fileInfo(filePath); const QString absoluteFilePath = fileInfo.absoluteFilePath(); + QObject *instance = nullptr; bool engineInitialized = initializedPlugins.contains(absoluteFilePath); - StringRegisteredPluginMap *plugins = qmlEnginePluginsWithRegisteredTypes(); - QMutexLocker lock(&plugins->mutex); - bool typesRegistered = plugins->contains(absoluteFilePath); - - if (typesRegistered) { - Q_ASSERT_X(plugins->value(absoluteFilePath).uri == uri, - "QQmlImportDatabase::importDynamicPlugin", - "Internal error: Plugin imported previously with different uri"); - } - - if (!engineInitialized || !typesRegistered) { - if (!QQml_isFileCaseCorrect(absoluteFilePath)) { - if (errors) { - QQmlError error; - error.setDescription(tr("File name case mismatch for \"%1\"").arg(absoluteFilePath)); - errors->prepend(error); - } - return false; + { + StringRegisteredPluginMap *plugins = qmlEnginePluginsWithRegisteredTypes(); + QMutexLocker lock(&plugins->mutex); + bool typesRegistered = plugins->contains(absoluteFilePath); + + if (typesRegistered) { + Q_ASSERT_X(plugins->value(absoluteFilePath).uri == uri, + "QQmlImportDatabase::importDynamicPlugin", + "Internal error: Plugin imported previously with different uri"); } - QPluginLoader* loader = 0; - if (!typesRegistered) { - loader = new QPluginLoader(absoluteFilePath); - - if (!loader->load()) { + if (!engineInitialized || !typesRegistered) { + if (!QQml_isFileCaseCorrect(absoluteFilePath)) { if (errors) { QQmlError error; - error.setDescription(loader->errorString()); + error.setDescription(tr("File name case mismatch for \"%1\"").arg(absoluteFilePath)); errors->prepend(error); } - delete loader; return false; } - } else { - loader = plugins->value(absoluteFilePath).loader; - } - QObject *instance = loader->instance(); + QPluginLoader* loader = 0; + if (!typesRegistered) { + loader = new QPluginLoader(absoluteFilePath); - if (!typesRegistered) { - RegisteredPlugin plugin; - plugin.uri = uri; - plugin.loader = loader; - plugins->insert(absoluteFilePath, plugin); + if (!loader->load()) { + if (errors) { + QQmlError error; + error.setDescription(loader->errorString()); + errors->prepend(error); + } + delete loader; + return false; + } + } else { + loader = plugins->value(absoluteFilePath).loader; + } - // Continue with shared code path for dynamic and static plugins: - if (!registerPluginTypes(instance, fileInfo.absolutePath(), uri, typeNamespace, vmaj, errors)) - return false; + instance = loader->instance(); + + if (!typesRegistered) { + RegisteredPlugin plugin; + plugin.uri = uri; + plugin.loader = loader; + plugins->insert(absoluteFilePath, plugin); + + // Continue with shared code path for dynamic and static plugins: + if (!registerPluginTypes(instance, fileInfo.absolutePath(), uri, typeNamespace, vmaj, errors)) + return false; + } } - if (!engineInitialized) { - // things on the engine (eg. adding new global objects) have to be done for every - // engine. - // XXX protect against double initialization - initializedPlugins.insert(absoluteFilePath); - - if (QQmlExtensionInterface *eiface = qobject_cast(instance)) { - QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine); - ep->typeLoader.initializeEngine(eiface, uri.toUtf8().constData()); - } - } + // Release the lock on plugins early as we're done with the global part. Releasing the lock + // also allows other QML loader threads to acquire the lock while this thread is blocking + // in the initializeEngine call to the gui thread (which in turn may be busy waiting for + // other QML loader threads and thus not process the initializeEngine call). + } + + + if (!engineInitialized) { + // The plugin's per-engine initialization does not need lock protection, as this function is + // only called from the engine specific loader thread and importDynamicPlugin as well as + // importStaticPlugin are the only places of access. + initializedPlugins.insert(absoluteFilePath); + + if (QQmlExtensionInterface *eiface = qobject_cast(instance)) { + QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine); + ep->typeLoader.initializeEngine(eiface, uri.toUtf8().constData()); + } } return true; -- cgit v1.2.3 From f7ffed94c1540e015794a8d6d4910e8ca87c15e1 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 31 Jan 2018 12:29:42 +0100 Subject: Fix memory leak with value types Commit 3b14e2ffdd8eb4b7f7f4508768b75f2acc399370 replaced the QQmlRefPointer with a raw QQmlPropertyCache pointer and added a V4_NEEDS_DESTROY tag. However unfortunately the destroy() method in the heap class does not decrease the reference count. Change-Id: I90a8c56cd638592b67aae7041fbb57c879c4146c Reviewed-by: Lars Knoll --- src/qml/qml/qqmlvaluetypewrapper.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index 41bb85c351..b2b49f7909 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -96,6 +96,8 @@ void Heap::QQmlValueTypeWrapper::destroy() valueType->metaType.destruct(gadgetPtr); ::operator delete(gadgetPtr); } + if (_propertyCache) + _propertyCache->release(); Object::destroy(); } -- cgit v1.2.3 From 65606ea1559572d66ee8bfac77e87f3e8f447c3e Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 19 Dec 2017 11:14:27 +0100 Subject: Remove double indirection between QJSEngine and QV4::ExecutionEngine As QJSEngine's handle() method is internal, we can redefine it to return a pointer to an ExecutionEngine. That makes many things easier. Change-Id: Ie3df99e0bad5f00ad4fe73182896cd135fa82994 Reviewed-by: Lars Knoll --- src/qml/qml/qqmlbinding.cpp | 23 ++++++++++++----------- src/qml/qml/qqmlboundsignal.cpp | 18 ++++++++++-------- src/qml/qml/qqmlcomponent.cpp | 3 +-- src/qml/qml/qqmlcontext.cpp | 2 +- src/qml/qml/qqmldelayedcallqueue_p.h | 1 - src/qml/qml/qqmlengine.cpp | 2 +- src/qml/qml/qqmlengine_p.h | 14 ++++++-------- src/qml/qml/qqmlexpression.cpp | 7 ++++--- src/qml/qml/qqmljavascriptexpression.cpp | 8 ++++---- src/qml/qml/qqmlobjectcreator.cpp | 4 ++-- src/qml/qml/qqmltypeloader.cpp | 12 +++++------- src/qml/qml/qqmlvmemetaobject.cpp | 10 ++++++---- src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 6 ++---- src/qml/qml/v8/qv8engine.cpp | 12 ++---------- src/qml/qml/v8/qv8engine_p.h | 6 ++---- 15 files changed, 58 insertions(+), 70 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index 11a1e6edee..a968aa908d 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -84,7 +84,7 @@ QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QQmlScr b->QQmlJavaScriptExpression::setContext(QQmlContextData::get(ctxt ? ctxt : scriptPrivate->context)); b->setScopeObject(obj ? obj : scriptPrivate->scope); - QV4::ExecutionEngine *v4 = QQmlEnginePrivate::get(b->context()->engine)->v4engine(); + QV4::ExecutionEngine *v4 = b->context()->engine->handle(); if (runtimeFunction) { QV4::Scope scope(v4); QV4::Scoped qmlContext(scope, QV4::QmlContext::create(v4->rootContext(), ctxtdata, b->scopeObject())); @@ -158,13 +158,13 @@ void QQmlBinding::update(QQmlPropertyData::WriteFlags flags) DeleteWatcher watcher(this); - QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context()->engine); - QV4::Scope scope(ep->v4engine()); + QQmlEngine *engine = context()->engine; + QV4::Scope scope(engine->handle()); if (canUseAccessor()) flags.setFlag(QQmlPropertyData::BypassInterceptor); - QQmlBindingProfiler prof(ep->profiler, function()); + QQmlBindingProfiler prof(QQmlEnginePrivate::get(engine)->profiler, function()); doUpdate(watcher, flags, scope); if (!watcher.wasDeleted()) @@ -351,7 +351,7 @@ Q_NEVER_INLINE bool QQmlBinding::slowWrite(const QQmlPropertyData &core, bool isUndefined, QQmlPropertyData::WriteFlags flags) { QQmlEngine *engine = context()->engine; - QV8Engine *v8engine = QQmlEnginePrivate::getV8Engine(engine); + QV4::ExecutionEngine *v4engine = engine->handle(); int type = valueTypeData.isValid() ? valueTypeData.propType() : core.propType(); @@ -362,13 +362,13 @@ Q_NEVER_INLINE bool QQmlBinding::slowWrite(const QQmlPropertyData &core, if (isUndefined) { } else if (core.isQList()) { - value = QV8Engine::getV4(v8engine)->toVariant(result, qMetaTypeId >()); + value = v4engine->toVariant(result, qMetaTypeId >()); } else if (result.isNull() && core.isQObject()) { value = QVariant::fromValue((QObject *)0); } else if (core.propType() == qMetaTypeId >()) { - value = QQmlPropertyPrivate::resolvedUrlSequence(QV8Engine::getV4(v8engine)->toVariant(result, qMetaTypeId >()), context()); + value = QQmlPropertyPrivate::resolvedUrlSequence(v4engine->toVariant(result, qMetaTypeId >()), context()); } else if (!isVarProperty && type != qMetaTypeId()) { - value = QV8Engine::getV4(v8engine)->toVariant(result, type); + value = v4engine->toVariant(result, type); } if (hasError()) { @@ -397,7 +397,7 @@ Q_NEVER_INLINE bool QQmlBinding::slowWrite(const QQmlPropertyData &core, return false; } QQmlPropertyPrivate::writeValueProperty(m_target.data(), core, valueTypeData, QVariant::fromValue( - QJSValue(QV8Engine::getV4(v8engine), result.asReturnedValue())), + QJSValue(v4engine, result.asReturnedValue())), context(), flags); } else if (isUndefined) { const QLatin1String typeName(QMetaType::typeName(type) @@ -455,12 +455,13 @@ Q_NEVER_INLINE bool QQmlBinding::slowWrite(const QQmlPropertyData &core, QVariant QQmlBinding::evaluate() { - QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context()->engine); + QQmlEngine *engine = context()->engine; + QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine); ep->referenceScarceResources(); bool isUndefined = false; - QV4::Scope scope(ep->v4engine()); + QV4::Scope scope(engine->handle()); QV4::ScopedValue result(scope, QQmlJavaScriptExpression::evaluate(&isUndefined)); ep->dereferenceScarceResources(); diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index 1d7a37fc99..501184b630 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -74,8 +74,7 @@ QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, { init(ctxt, scope); - QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine()); - QV4::ExecutionEngine *v4 = ep->v4engine(); + QV4::ExecutionEngine *v4 = engine()->handle(); QString function; @@ -123,7 +122,7 @@ QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, // It's important to call init first, because m_index gets remapped in case of cloned signals. init(ctxt, scope); - QV4::ExecutionEngine *engine = QQmlEnginePrivate::getV4Engine(ctxt->engine); + QV4::ExecutionEngine *engine = ctxt->engine->handle(); QList signalParameters = QMetaObjectPrivate::signal(m_target->metaObject(), m_index).parameterNames(); if (!signalParameters.isEmpty()) { @@ -182,8 +181,10 @@ void QQmlBoundSignalExpression::evaluate(void **a) if (!expressionFunctionValid()) return; - QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine()); - QV4::Scope scope(ep->v4engine()); + QQmlEngine *qmlengine = engine(); + QQmlEnginePrivate *ep = QQmlEnginePrivate::get(qmlengine); + QV4::ExecutionEngine *v4 = qmlengine->handle(); + QV4::Scope scope(v4); ep->referenceScarceResources(); // "hold" scarce resources in memory during evaluation. @@ -215,7 +216,7 @@ void QQmlBoundSignalExpression::evaluate(void **a) if (!*reinterpret_cast(a[ii + 1])) jsCall->args[ii] = QV4::Primitive::nullValue(); else - jsCall->args[ii] = QV4::QObjectWrapper::wrap(ep->v4engine(), *reinterpret_cast(a[ii + 1])); + jsCall->args[ii] = QV4::QObjectWrapper::wrap(v4, *reinterpret_cast(a[ii + 1])); } else { jsCall->args[ii] = scope.engine->fromVariant(QVariant(type, a[ii + 1])); } @@ -233,8 +234,9 @@ void QQmlBoundSignalExpression::evaluate(const QList &args) if (!expressionFunctionValid()) return; - QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine()); - QV4::Scope scope(ep->v4engine()); + QQmlEngine *qmlengine = engine(); + QQmlEnginePrivate *ep = QQmlEnginePrivate::get(qmlengine); + QV4::Scope scope(qmlengine->handle()); ep->referenceScarceResources(); // "hold" scarce resources in memory during evaluation. diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index e3dc3be81e..b175223e13 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1436,8 +1436,7 @@ void QQmlComponent::incubateObject(QQmlV4Function *args) // XXX used by QSGLoader void QQmlComponentPrivate::initializeObjectWithInitialProperties(QV4::QmlContext *qmlContext, const QV4::Value &valuemap, QObject *toCreate) { - QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine); - QV4::ExecutionEngine *v4engine = QV8Engine::getV4(ep->v8engine()); + QV4::ExecutionEngine *v4engine = engine->handle(); QV4::Scope scope(v4engine); QV4::ScopedValue object(scope, QV4::QObjectWrapper::wrap(v4engine, toCreate)); diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp index 9d2e37a2ab..aa1c83d74c 100644 --- a/src/qml/qml/qqmlcontext.cpp +++ b/src/qml/qml/qqmlcontext.cpp @@ -837,7 +837,7 @@ const QV4::IdentifierHash &QQmlContextData::propertyNames() const if (typeCompilationUnit) propertyNameCache = typeCompilationUnit->namedObjectsPerComponent(componentObjectIndex); else - propertyNameCache = QV4::IdentifierHash(QV8Engine::getV4(engine)); + propertyNameCache = QV4::IdentifierHash(engine->handle()); } return propertyNameCache; } diff --git a/src/qml/qml/qqmldelayedcallqueue_p.h b/src/qml/qml/qqmldelayedcallqueue_p.h index b3d361581d..47e211829c 100644 --- a/src/qml/qml/qqmldelayedcallqueue_p.h +++ b/src/qml/qml/qqmldelayedcallqueue_p.h @@ -60,7 +60,6 @@ QT_BEGIN_NAMESPACE -class QV8Engine; class QQmlDelayedCallQueue : public QObject { Q_OBJECT diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index a66bcaa9bd..d93aa6b9b6 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -2080,7 +2080,7 @@ void QQmlEnginePrivate::cleanupScarceResources() // note that the actual SRD is owned by the JS engine, // so we cannot delete the SRD; but we can free the // memory used by the variant in the SRD. - QV4::ExecutionEngine *engine = QV8Engine::getV4(v8engine()); + QV4::ExecutionEngine *engine = v4engine(); while (QV4::ExecutionEngine::ScarceResourceData *sr = engine->scarceResources.first()) { sr->data = QVariant(); engine->scarceResources.remove(sr); diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h index 74e232fd84..f12409ed9a 100644 --- a/src/qml/qml/qqmlengine_p.h +++ b/src/qml/qml/qqmlengine_p.h @@ -150,8 +150,8 @@ public: QQmlDelayedError *erroredBindings; int inProgressCreations; - QV8Engine *v8engine() const { return q_func()->handle(); } - QV4::ExecutionEngine *v4engine() const { return QV8Engine::getV4(q_func()->handle()); } + QV8Engine *v8engine() const { return q_func()->handle()->v8Engine; } + QV4::ExecutionEngine *v4engine() const { return q_func()->handle(); } QQuickWorkerScriptEngine *getWorkerScriptEngine(); QQuickWorkerScriptEngine *workerScriptEngine; @@ -295,7 +295,7 @@ inline void QQmlEnginePrivate::dereferenceScarceResources() // expression must have completed. We can safely release the // scarce resources. if (Q_LIKELY(scarceResourcesRefCount == 0)) { - QV4::ExecutionEngine *engine = QV8Engine::getV4(v8engine()); + QV4::ExecutionEngine *engine = v4engine(); if (Q_UNLIKELY(!engine->scarceResources.isEmpty())) { cleanupScarceResources(); } @@ -385,14 +385,14 @@ QV8Engine *QQmlEnginePrivate::getV8Engine(QQmlEngine *e) { Q_ASSERT(e); - return e->d_func()->v8engine(); + return e->handle()->v8Engine; } QV4::ExecutionEngine *QQmlEnginePrivate::getV4Engine(QQmlEngine *e) { Q_ASSERT(e); - return e->d_func()->v4engine(); + return e->handle(); } QQmlEnginePrivate *QQmlEnginePrivate::get(QQmlEngine *e) @@ -428,9 +428,7 @@ QQmlEngine *QQmlEnginePrivate::get(QQmlEnginePrivate *p) QQmlEnginePrivate *QQmlEnginePrivate::get(QV4::ExecutionEngine *e) { - if (!e->v8Engine) - return 0; - QQmlEngine *qmlEngine = e->v8Engine->engine(); + QQmlEngine *qmlEngine = e->qmlEngine(); if (!qmlEngine) return 0; return get(qmlEngine); diff --git a/src/qml/qml/qqmlexpression.cpp b/src/qml/qml/qqmlexpression.cpp index 35dbaccbbe..3ba0afc7bd 100644 --- a/src/qml/qml/qqmlexpression.cpp +++ b/src/qml/qml/qqmlexpression.cpp @@ -74,7 +74,7 @@ void QQmlExpressionPrivate::init(QQmlContextData *ctxt, const QString &expr, QOb void QQmlExpressionPrivate::init(QQmlContextData *ctxt, QV4::Function *runtimeFunction, QObject *me) { expressionFunctionValid = true; - QV4::ExecutionEngine *engine = QQmlEnginePrivate::getV4Engine(ctxt->engine); + QV4::ExecutionEngine *engine = ctxt->engine->handle(); QV4::Scope scope(engine); QV4::Scoped qmlContext(scope, QV4::QmlContext::create(engine->rootContext(), ctxt, me)); setupFunction(qmlContext, runtimeFunction); @@ -266,13 +266,14 @@ QVariant QQmlExpressionPrivate::value(bool *isUndefined) return QVariant(); } - QQmlEnginePrivate *ep = QQmlEnginePrivate::get(q->engine()); + QQmlEngine *engine = q->engine(); + QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine); QVariant rv; ep->referenceScarceResources(); // "hold" scarce resources in memory during evaluation. { - QV4::Scope scope(QV8Engine::getV4(ep->v8engine())); + QV4::Scope scope(engine->handle()); QV4::ScopedValue result(scope, v4value(isUndefined)); if (!hasError()) rv = scope.engine->toVariant(result, -1); diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index 006611e089..cd35ab93c6 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -183,7 +183,7 @@ void QQmlJavaScriptExpression::refresh() QV4::ReturnedValue QQmlJavaScriptExpression::evaluate(bool *isUndefined) { - QV4::ExecutionEngine *v4 = QV8Engine::getV4(m_context->engine); + QV4::ExecutionEngine *v4 = m_context->engine->handle(); QV4::Scope scope(v4); QV4::JSCallData jsCall(scope); @@ -217,7 +217,7 @@ QV4::ReturnedValue QQmlJavaScriptExpression::evaluate(QV4::CallData *callData, b if (notifyOnValueChanged()) capture.guards.copyAndClearPrepend(activeGuards); - QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine()); + QV4::ExecutionEngine *v4 = m_context->engine->handle(); callData->thisObject = v4->globalObject; if (scopeObject()) { QV4::ReturnedValue scope = QV4::QObjectWrapper::wrap(v4, scopeObject()); @@ -414,7 +414,7 @@ QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scopeObje QQmlEngine *engine = ctxt->engine; QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine); - QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine()); + QV4::ExecutionEngine *v4 = engine->handle(); QV4::Scope scope(v4); QV4::Scoped qmlContext(scope, QV4::QmlContext::create(v4->rootContext(), ctxt, scopeObject)); @@ -444,7 +444,7 @@ void QQmlJavaScriptExpression::createQmlBinding(QQmlContextData *ctxt, QObject * QQmlEngine *engine = ctxt->engine; QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine); - QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine()); + QV4::ExecutionEngine *v4 = engine->handle(); QV4::Scope scope(v4); QV4::Scoped qmlContext(scope, QV4::QmlContext::create(v4->rootContext(), ctxt, qmlScope)); diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 8d17ae3233..1c3e24fe02 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -114,7 +114,7 @@ void QQmlObjectCreator::init(QQmlContextData *providedParentContext) { parentContext = providedParentContext; engine = parentContext->engine; - v4 = QV8Engine::getV4(engine); + v4 = engine->handle(); if (compilationUnit && !compilationUnit->engine) compilationUnit->linkToEngine(v4); @@ -1024,7 +1024,7 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con } else if (property->propType() == QMetaType::QVariant) { if (property->isVarProperty()) { QV4::Scope scope(v4); - QV4::ScopedValue wrappedObject(scope, QV4::QObjectWrapper::wrap(QV8Engine::getV4(engine), createdSubObject)); + QV4::ScopedValue wrappedObject(scope, QV4::QObjectWrapper::wrap(engine->handle(), createdSubObject)); _vmeMetaObject->setVMEProperty(property->coreIndex(), wrappedObject); } else { QVariant value = QVariant::fromValue(createdSubObject); diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index fab5cf6c1f..2afcf1da3e 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -1524,7 +1524,7 @@ void QQmlTypeLoader::Blob::dependencyComplete(QQmlDataBlob *blob) bool QQmlTypeLoader::Blob::isDebugging() const { - return QV8Engine::getV4(typeLoader()->engine())->debugger() != 0; + return typeLoader()->engine()->handle()->debugger() != 0; } bool QQmlTypeLoader::Blob::qmldirDataAvailable(QQmlQmldirData *data, QList *errors) @@ -2097,7 +2097,7 @@ bool QQmlTypeData::tryLoadFromDiskCache() if (isDebugging()) return false; - QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(typeLoader()->engine()); + QV4::ExecutionEngine *v4 = typeLoader()->engine()->handle(); if (!v4) return false; @@ -2440,7 +2440,7 @@ bool QQmlTypeData::loadFromSource() m_document.reset(new QmlIR::Document(isDebugging())); m_document->jsModule.sourceTimeStamp = m_backupSourceCode.sourceTimeStamp(); QQmlEngine *qmlEngine = typeLoader()->engine(); - QmlIR::IRBuilder compiler(QV8Engine::get(qmlEngine)->illegalNames()); + QmlIR::IRBuilder compiler(qmlEngine->handle()->v8Engine->illegalNames()); QString sourceError; const QString source = m_backupSourceCode.readAll(&sourceError); @@ -2828,9 +2828,7 @@ void QQmlScriptData::initialize(QQmlEngine *engine) Q_ASSERT(engine); Q_ASSERT(!hasEngine()); - QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine); - QV8Engine *v8engine = ep->v8engine(); - QV4::ExecutionEngine *v4 = QV8Engine::getV4(v8engine); + QV4::ExecutionEngine *v4 = engine->handle(); m_program = new QV4::Script(v4, 0, m_precompiledScript); @@ -2846,7 +2844,7 @@ QV4::ReturnedValue QQmlScriptData::scriptValueForContext(QQmlContextData *parent Q_ASSERT(parentCtxt && parentCtxt->engine); QQmlEnginePrivate *ep = QQmlEnginePrivate::get(parentCtxt->engine); - QV4::ExecutionEngine *v4 = QV8Engine::getV4(parentCtxt->engine); + QV4::ExecutionEngine *v4 = parentCtxt->engine->handle(); QV4::Scope scope(v4); bool shared = m_precompiledScript->data->flags & QV4::CompiledData::Unit::IsSharedLibrary; diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp index 281d64ac79..73cb20dc7f 100644 --- a/src/qml/qml/qqmlvmemetaobject.cpp +++ b/src/qml/qml/qqmlvmemetaobject.cpp @@ -926,12 +926,14 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void * id -= plainSignals; if (id < methodCount) { - if (!ctxt->engine) + QQmlEngine *engine = ctxt->engine; + if (!engine) return -1; // We can't run the method - QQmlEnginePrivate *ep = QQmlEnginePrivate::get(ctxt->engine); + QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine); + QV4::ExecutionEngine *v4 = engine->handle(); ep->referenceScarceResources(); // "hold" scarce resources in memory during evaluation. - QV4::Scope scope(ep->v4engine()); + QV4::Scope scope(v4); QV4::ScopedFunctionObject function(scope, method(id)); @@ -951,7 +953,7 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void * const unsigned int parameterCount = function->formalParameterCount(); QV4::JSCallData jsCallData(scope, parameterCount); - *jsCallData->thisObject = ep->v8engine()->global(); + *jsCallData->thisObject = v4->global(); for (uint ii = 0; ii < parameterCount; ++ii) jsCallData->args[ii] = scope.engine->fromVariant(*(QVariant *)a[ii + 1]); diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index f2b396ad00..44ad174f37 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1116,8 +1116,7 @@ ReturnedValue QtObject::method_createQmlObject(const FunctionObject *b, const Va } }; - QV8Engine *v8engine = scope.engine->v8Engine; - QQmlEngine *engine = v8engine->engine(); + QQmlEngine *engine = scope.engine->qmlEngine(); QQmlContextData *context = scope.engine->callingQmlContext(); Q_ASSERT(context); @@ -1244,8 +1243,7 @@ ReturnedValue QtObject::method_createComponent(const FunctionObject *b, const Va if (argc < 1 || argc > 3) THROW_GENERIC_ERROR("Qt.createComponent(): Invalid arguments"); - QV8Engine *v8engine = scope.engine->v8Engine; - QQmlEngine *engine = v8engine->engine(); + QQmlEngine *engine = scope.engine->qmlEngine(); QQmlContextData *context = scope.engine->callingQmlContext(); Q_ASSERT(context); diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp index 2947f7870a..2bf623f144 100644 --- a/src/qml/qml/v8/qv8engine.cpp +++ b/src/qml/qml/v8/qv8engine.cpp @@ -123,9 +123,10 @@ static void restoreJSValue(QDataStream &stream, void *data) } } -QV8Engine::QV8Engine(QJSEngine* qq) +QV8Engine::QV8Engine(QJSEngine *qq, QV4::ExecutionEngine *v4) : q(qq) , m_engine(0) + , m_v4Engine(v4) , m_xmlHttpRequestData(0) { #ifdef Q_PROCESSOR_X86_32 @@ -146,8 +147,6 @@ QV8Engine::QV8Engine(QJSEngine* qq) QMetaType::registerConverter(convertJSValueToVariantType); QMetaType::registerStreamOperators(qMetaTypeId(), saveJSValue, restoreJSValue); - m_v4Engine = new QV4::ExecutionEngine; - m_v4Engine->v8Engine = this; m_delayedCallQueue.init(m_v4Engine); QV4::QObjectWrapper::initializeBindings(m_v4Engine); @@ -162,8 +161,6 @@ QV8Engine::~QV8Engine() qt_rem_qmlxmlhttprequest(m_v4Engine, m_xmlHttpRequestData); m_xmlHttpRequestData = 0; #endif - - delete m_v4Engine; } #if QT_CONFIG(qml_network) @@ -288,11 +285,6 @@ void QV8Engine::setEngine(QQmlEngine *engine) initQmlGlobalObject(); } -QV4::ReturnedValue QV8Engine::global() -{ - return m_v4Engine->globalObject->asReturnedValue(); -} - void QV8Engine::startTimer(const QString &timerName) { if (!m_time.isValid()) diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h index 98b182147c..eb2b8b474c 100644 --- a/src/qml/qml/v8/qv8engine_p.h +++ b/src/qml/qml/v8/qv8engine_p.h @@ -153,12 +153,11 @@ class Q_QML_PRIVATE_EXPORT QV8Engine { friend class QJSEngine; public: - static QV8Engine* get(QJSEngine* q) { Q_ASSERT(q); return q->handle(); } // static QJSEngine* get(QV8Engine* d) { Q_ASSERT(d); return d->q; } - static QV4::ExecutionEngine *getV4(QJSEngine *q) { return q->handle()->m_v4Engine; } + static QV4::ExecutionEngine *getV4(QJSEngine *q) { return q->handle(); } static QV4::ExecutionEngine *getV4(QV8Engine *d) { return d->m_v4Engine; } - QV8Engine(QJSEngine* qq); + QV8Engine(QJSEngine* qq, QV4::ExecutionEngine *v4); virtual ~QV8Engine(); // This enum should be in sync with QQmlEngine::ObjectOwnership @@ -172,7 +171,6 @@ public: void setEngine(QQmlEngine *engine); QQmlEngine *engine() { return m_engine; } QJSEngine *publicEngine() { return q; } - QV4::ReturnedValue global(); QQmlDelayedCallQueue *delayedCallQueue() { return &m_delayedCallQueue; } void *xmlHttpRequestData() const { return m_xmlHttpRequestData; } -- cgit v1.2.3 From 61a32b78db418936ca7987ff859f9e62f84cbd06 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 2 Feb 2018 09:32:17 +0100 Subject: Lift restriction for type registrations in QML module plugins During the registerTypes() callback in a QML module plugin we only allow types to be registered that match the module URI specified in the qmldir. We can observe in QtQuickControls 2 that sometimes we need to register types outside of the namespace of the module itself. QQC2 is in QtQuick.Controls but the module has internal types that are in QtQuick.Controls.impl. Types are intended to be registered once in the virtual registerTypes() function. However as we don't allow for the registration of .impl to happen in registerTypes(), QQC2 works around this by registering the types in initializeEngine(), during which the namespace restriction is not in place. This workaround means that every time an application creates a QQuickView (and thus new QML engine) and loads a QML file that imports QQC2, we end up calling initializeEngine(), as opposed to registerTypes() that is called only one single time in the application process. As a consequence each time this happens we and up calling qmlRegisterTypes() with the same times and leak memory this way, as qmlRegisterType*() is supposed to register a new type and return a new type id that can be passed to qmlUnregisterType. To solve this this patch lifts the restriction on namespaces for registered types during registerTypes(). The real world case of QQC2 shows that the restriction is limiting and also easy to work around. With the restriction lifted QQC2 can now register all types once in registerTypes() instead. [ChangeLog][QtQml][Important Behavior Changes] QML module plugins used to be limited to type registrations in the primary module namespace in the virtual registerTypes() function. Module authors worked around this limitation by placing necessary internal type registrations into initializeEngine() that may cause memory leaks. Therefore this restriction has been moved and types in any (non-protected) namespaces can be registered in the registerTypes() function. Change-Id: I5baf9718a0b0a591f6eb6d7e2dc83e13b204800d Reviewed-by: J-P Nurmi Reviewed-by: Mitch Curtis --- src/qml/qml/qqmlmetatype.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index 40864de366..b324386bf5 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -1579,15 +1579,7 @@ bool checkRegistration(QQmlType::RegistrationType typeType, QQmlMetaTypeData *da if (uri && !typeName.isEmpty()) { QString nameSpace = QString::fromUtf8(uri); - if (!data->typeRegistrationNamespace.isEmpty()) { - // We can only install types into the registered namespace - if (nameSpace != data->typeRegistrationNamespace) { - QString failure(QCoreApplication::translate("qmlRegisterType", - "Cannot install %1 '%2' into unregistered namespace '%3'")); - data->typeRegistrationFailures.append(failure.arg(registrationTypeString(typeType)).arg(typeName).arg(nameSpace)); - return false; - } - } else if (data->typeRegistrationNamespace != nameSpace) { + if (data->typeRegistrationNamespace.isEmpty() && !nameSpace.isEmpty()) { // Is the target namespace protected against further registrations? if (data->protectedNamespaces.contains(nameSpace)) { QString failure(QCoreApplication::translate("qmlRegisterType", -- cgit v1.2.3 From 5b0a98fa16330f220d3fbf67e9a55c8632d30129 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 5 Feb 2018 14:18:18 +0100 Subject: Clean up manual refcounting of compilation units Replace manual use in QQmlData and QQmlData::DeferredData with QQmlRefPointer. Due to forward declaration trouble this required declaring a non-inline constructor/destructor for QQmlData and DeferedData and disabling copying, so that not every C++ compilation unit including qqmldata_p.h needs to instantiate the QQmlRefPointer destructor and thus know whether QV4::CompiledData::CompilationUnit has release(), etc. The out-of-line declarations however should not have any negative impact as the only call sites are within qqmlengine.cpp, too. Change-Id: I2e8295cb0d7f876a5d7d18765dbac285184e6c99 Reviewed-by: Lars Knoll --- src/qml/qml/qqmldata_p.h | 10 ++++++++-- src/qml/qml/qqmlengine.cpp | 21 ++++++++++++++------- src/qml/qml/qqmlobjectcreator.cpp | 3 --- src/qml/qml/qqmlobjectcreator_p.h | 2 +- 4 files changed, 23 insertions(+), 13 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h index 5794e6f0c5..17d145f939 100644 --- a/src/qml/qml/qqmldata_p.h +++ b/src/qml/qml/qqmldata_p.h @@ -56,6 +56,7 @@ #include #include #include +#include #include #include @@ -116,6 +117,7 @@ class Q_QML_PRIVATE_EXPORT QQmlData : public QAbstractDeclarativeData { public: QQmlData(); + ~QQmlData(); static inline void init() { static bool initialized = false; @@ -219,12 +221,15 @@ public: quint32 jsEngineId; // id of the engine that created the jsWrapper struct DeferredData { + DeferredData(); + ~DeferredData(); unsigned int deferredIdx; QMultiHash bindings; - QV4::CompiledData::CompilationUnit *compilationUnit;//Not always the same as the other compilation unit + QQmlRefPointer compilationUnit;//Not always the same as the other compilation unit QQmlContextData *context;//Could be either context or outerContext + Q_DISABLE_COPY(DeferredData); }; - QV4::CompiledData::CompilationUnit *compilationUnit; + QQmlRefPointer compilationUnit; QVector deferredData; void deferData(int objectIndex, QV4::CompiledData::CompilationUnit *, QQmlContextData *); @@ -299,6 +304,7 @@ private: const BindingBitsType *bits = (bindingBitsArraySize == InlineBindingArraySize) ? bindingBitsValue : bindingBits; return bits[offset] & bitFlagForBit(bit); } + Q_DISABLE_COPY(QQmlData); }; bool QQmlData::wasDeleted(const QObject *object) diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index c09c048307..7dac0b3c8d 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -746,13 +746,17 @@ QQmlData::QQmlData() hasInterceptorMetaObject(false), hasVMEMetaObject(false), parentFrozen(false), bindingBitsArraySize(InlineBindingArraySize), notifyList(0), bindings(0), signalHandlers(0), nextContextObject(0), prevContextObject(0), - lineNumber(0), columnNumber(0), jsEngineId(0), compilationUnit(0), + lineNumber(0), columnNumber(0), jsEngineId(0), propertyCache(0), guards(0), extendedData(0) { memset(bindingBitsValue, 0, sizeof(bindingBitsValue)); init(); } +QQmlData::~QQmlData() +{ +} + void QQmlData::destroyed(QAbstractDeclarativeData *d, QObject *o) { QQmlData *ddata = static_cast(d); @@ -924,6 +928,14 @@ void QQmlData::flushPendingBindingImpl(QQmlPropertyIndex index) QQmlPropertyData::DontRemoveBinding); } +QQmlData::DeferredData::DeferredData() +{ +} + +QQmlData::DeferredData::~DeferredData() +{ +} + bool QQmlEnginePrivate::baseModulesUninitialized = true; void QQmlEnginePrivate::init() { @@ -1651,7 +1663,6 @@ void QQmlData::deferData(int objectIndex, QV4::CompiledData::CompilationUnit *co QQmlData::DeferredData *deferData = new QQmlData::DeferredData; deferData->deferredIdx = objectIndex; deferData->compilationUnit = compilationUnit; - deferData->compilationUnit->addref(); deferData->context = context; const QV4::CompiledData::Object *compiledObject = compilationUnit->objectAt(objectIndex); @@ -1673,7 +1684,6 @@ void QQmlData::releaseDeferredData() while (it != deferredData.end()) { DeferredData *deferData = *it; if (deferData->bindings.isEmpty()) { - deferData->compilationUnit->release(); delete deferData; it = deferredData.erase(it); } else { @@ -1751,10 +1761,7 @@ void QQmlData::destroyed(QObject *object) if (bindings && !bindings->ref.deref()) delete bindings; - if (compilationUnit) { - compilationUnit->release(); - compilationUnit = 0; - } + compilationUnit = nullptr; releaseDeferredData(); diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index ad9687574f..78d732d02c 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -203,10 +203,7 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlI if (instance) { QQmlData *ddata = QQmlData::get(instance); Q_ASSERT(ddata); - if (ddata->compilationUnit) - ddata->compilationUnit->release(); ddata->compilationUnit = compilationUnit; - ddata->compilationUnit->addref(); } if (topLevelCreator) diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h index 82fe22af72..21ee30acd0 100644 --- a/src/qml/qml/qqmlobjectcreator_p.h +++ b/src/qml/qml/qqmlobjectcreator_p.h @@ -137,7 +137,7 @@ private: QQmlEngine *engine; QV4::ExecutionEngine *v4; - QV4::CompiledData::CompilationUnit *compilationUnit; + QQmlRefPointer compilationUnit; const QV4::CompiledData::Unit *qmlUnit; QQmlGuardedContextData parentContext; QQmlContextData *context; -- cgit v1.2.3 From c6b3c69e014f846a142c2429cd2d675c75b74245 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 5 Feb 2018 14:49:46 +0100 Subject: Fix memory leak with deferred properties This is a regression introduced with commit 3b6eeee177b64eebe240d51be0c7bb5f031471d8 in the 5.9 branch. When constructing an object with deferred properties and not running qmlExecuteDeferred, then the deferred data would never get deleted because the bindings list remains non-empty and we would leak the deferred data as well as the entire compilation unit behind it. This happens for example when declaring when instantiating a QML file with states: states: [ State { ... }, State { ... }, ... } Unless every state is entered, its deferred changes property is never applied (via qmlExecuteDeferred) and thus the defer data is leaked. Task-number: QTBUG-66189 Change-Id: I1b2119c601d1e0ab4e37f53d4cf2f569586ee883 Reviewed-by: J-P Nurmi Reviewed-by: Lars Knoll --- src/qml/qml/qqmlengine.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 7dac0b3c8d..f4656bafd2 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -1763,7 +1763,8 @@ void QQmlData::destroyed(QObject *object) compilationUnit = nullptr; - releaseDeferredData(); + qDeleteAll(deferredData); + deferredData.clear(); QQmlBoundSignal *signalHandler = signalHandlers; while (signalHandler) { -- cgit v1.2.3 From 9fbb5d485f429da022c58948937105dd9206130e Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Tue, 23 Jan 2018 12:20:52 +0100 Subject: Remove unnecesary checks CID 186959 (#1 of 1): Macro compares unsigned to 0 (NO_EFFECT) unsigned_compare: This greater-than-or-equal-to-zero comparison of an unsigned value is always true. rev >= 0. CID 186960 (#2 of 2): Operands don't affect result (CONSTANT_EXPRESSION_RESULT) result_independent_of_operands: rev <= 255 /* std::numeric_limits::max() */ is always true regardless of the values of its operands. This occurs as the logical first operand of ?:. Coverity-Id: 186959 Coverity-Id: 186960 Change-Id: Iaadadb89de1c8732b2756da8fda397632b6b7d93 Reviewed-by: Thomas Hartmann --- src/qml/qml/qqmlpropertycache_p.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h index e032d4f4c7..11b7c04c52 100644 --- a/src/qml/qml/qqmlpropertycache_p.h +++ b/src/qml/qml/qqmlpropertycache_p.h @@ -221,7 +221,6 @@ public: quint8 revision() const { return _revision; } void setRevision(quint8 rev) { - Q_ASSERT(rev >= std::numeric_limits::min()); Q_ASSERT(rev <= std::numeric_limits::max()); _revision = quint8(rev); } @@ -247,7 +246,6 @@ public: quint8 typeMinorVersion() const { return _typeMinorVersion; } void setTypeMinorVersion(quint8 rev) { - Q_ASSERT(rev >= std::numeric_limits::min()); Q_ASSERT(rev <= std::numeric_limits::max()); _typeMinorVersion = quint8(rev); } -- cgit v1.2.3 From d4ff2907162e20e2288357c428b0df88f7396f92 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 8 Feb 2018 16:43:08 +0100 Subject: Fix memory leak with JS imports Strictly speaking this is a regression introduced with commit e22b624d9ab1f36021adb9cdbfa9b37054282bb8, making the QQmlContextData objects reference counted, especially from the V4 QML context wrapper objects. That change (correct as it is) introduced an accidental circular dependency in the simple scenario of importing a .js file in a .qml file: Each time the type in the .qml file is instantiated, we create a dedicated QQmlContextData for the .js file. If the .js file has no imports itself, that new context will get the same ctx->importedScripts JS array as the QML context of the .qml file. That is a strong reference via QV4::PersistentValue. That array in turn contains the QV4::QmlContextWrapper that belongs to the imported script, which in turn holds a strong reference (via refcount) to the script's context. This patch breaks the circular reference when we perform context invalidation, as the least intrusive measure. For the auto-test to work, we must also clear the qmlContext persistent of the QV4::Script that's used to evaluate the .js file. In subsequent imports that persistent will be initialized to new values, so it will only hold a strong reference to the last import, but strictly speaking that is still a leak - hence also part of this fix. Change-Id: I3e543c946e5e683425072dc3df7e49ca0e0c0215 Task-number: QTBUG-66189 Reviewed-by: Lars Knoll --- src/qml/qml/qqmlcontext.cpp | 2 ++ src/qml/qml/qqmltypeloader.cpp | 1 + 2 files changed, 3 insertions(+) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp index 59e2c83a63..0c431b1260 100644 --- a/src/qml/qml/qqmlcontext.cpp +++ b/src/qml/qml/qqmlcontext.cpp @@ -579,6 +579,8 @@ void QQmlContextData::invalidate() prevChild = 0; } + importedScripts.clear(); + engine = 0; parent = 0; } diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 19e57fbdba..5318375af7 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -2917,6 +2917,7 @@ QV4::ReturnedValue QQmlScriptData::scriptValueForContext(QQmlContextData *parent m_program->qmlContext.set(scope.engine, qmlContext); m_program->run(); + m_program->qmlContext.clear(); if (scope.engine->hasException) { QQmlError error = scope.engine->catchExceptionAsQmlError(); if (error.isValid()) -- cgit v1.2.3 From 47cd9da96371ccd495f6caabe1c6853258210ebb Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 5 Feb 2018 11:21:32 +0100 Subject: doc: Fix qdoc warnings for templates and statics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Several \fn commands needed template parameters added, and several static functions that were not accessible were documented but should not have been documented. The template texts were added and the qdoc comments of the static functions were changed to non-qdoc comments. Change-Id: Icc44e243fbec2023865f47b7c73dc15d241d5b4d Reviewed-by: Topi Reiniö --- src/qml/qml/qqmlcontext.cpp | 1 + src/qml/qml/qqmlimport.cpp | 6 +++--- src/qml/qml/qqmllist.cpp | 10 +++++----- 3 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp index e6e2be91f6..de43108312 100644 --- a/src/qml/qml/qqmlcontext.cpp +++ b/src/qml/qml/qqmlcontext.cpp @@ -365,6 +365,7 @@ void QQmlContext::setContextProperties(const QVector &properties) \since 5.11 \class QQmlContext::PropertyPair + \inmodule QtQml This struct contains a property name and a property value. It is used as a parameter for the \c setContextProperties function. diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index 8b0bd9d6ec..f2757c34be 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -981,7 +981,7 @@ QQmlImportNamespace *QQmlImportsPrivate::findQualifiedNamespace(const QHashedStr return 0; } -/*! +/* Returns the list of possible versioned URI combinations. For example, if \a uri is QtQml.Models, \a vmaj is 2, and \a vmin is 0, this method returns the following: [QtQml.Models.2.0, QtQml.2.0.Models, QtQml.Models.2, QtQml.2.Models, QtQml.Models] @@ -1017,7 +1017,7 @@ static QVector makePlugins() return plugins; } -/*! +/* Get all static plugins that are QML plugins and has a meta data URI that matches with one of \a versionUris, which is a list of all possible versioned URI combinations - see versionUriList() above. @@ -1059,7 +1059,7 @@ static inline QString msgCannotLoadPlugin(const QString &uri, const QString &why } #endif -/*! +/* Import an extension defined by a qmldir file. \a qmldirFilePath is a raw file path. diff --git a/src/qml/qml/qqmllist.cpp b/src/qml/qml/qqmllist.cpp index 71be2e82a3..9bfdd3da35 100644 --- a/src/qml/qml/qqmllist.cpp +++ b/src/qml/qml/qqmllist.cpp @@ -374,12 +374,12 @@ The \l {Qt Quick 1} version of this class is named QDeclarativeListProperty. */ /*! -\fn QQmlListProperty::QQmlListProperty() +\fn template QQmlListProperty::QQmlListProperty() \internal */ /*! -\fn QQmlListProperty::QQmlListProperty(QObject *object, QList &list) +\fn template QQmlListProperty::QQmlListProperty(QObject *object, QList &list) Convenience constructor for making a QQmlListProperty value from an existing QList \a list. The \a list reference must remain valid for as long as \a object @@ -391,7 +391,7 @@ can be very useful while prototyping. */ /*! -\fn QQmlListProperty::QQmlListProperty(QObject *object, void *data, +\fn template QQmlListProperty::QQmlListProperty(QObject *object, void *data, CountFunction count, AtFunction at) Construct a readonly QQmlListProperty from a set of operation functions @@ -401,7 +401,7 @@ remains valid while \a object exists. */ /*! -\fn QQmlListProperty::QQmlListProperty(QObject *object, void *data, AppendFunction append, +\fn template QQmlListProperty::QQmlListProperty(QObject *object, void *data, AppendFunction append, CountFunction count, AtFunction at, ClearFunction clear) @@ -432,7 +432,7 @@ Return the number of elements in the list \a property. */ /*! -\fn bool QQmlListProperty::operator==(const QQmlListProperty &other) const +\fn template bool QQmlListProperty::operator==(const QQmlListProperty &other) const Returns true if this QQmlListProperty is equal to \a other, otherwise false. */ -- cgit v1.2.3 From b704faaa45d3e3ca8bc7ce11aeb1e533a9563a0f Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Tue, 13 Feb 2018 13:21:06 +0100 Subject: Fix typos Change-Id: I8afc27444e5c92b7c6aed3ff987dffb135bdfe46 Reviewed-by: Leena Miettinen --- src/qml/qml/qqmlerror.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlerror.cpp b/src/qml/qml/qqmlerror.cpp index 64f008cd32..1b264b025c 100644 --- a/src/qml/qml/qqmlerror.cpp +++ b/src/qml/qml/qqmlerror.cpp @@ -268,7 +268,7 @@ QtMsgType QQmlError::messageType() const \since 5.9 Sets the \a messageType for this message. The message type determines which - QDebug handlers are responsible for recieving the message. + QDebug handlers are responsible for receiving the message. */ void QQmlError::setMessageType(QtMsgType messageType) { -- cgit v1.2.3 From 2659c308792967322564b5088e0e21bb371e0283 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 21 Feb 2018 17:09:50 +0100 Subject: Allow setting values in value type group properties in "on" assignments Assigning to a group property inside a property value source or interceptor as part of an "on assignment" is perfectly valid. That is because while "color" is a value type property, the on assignment means we're actually setting easing.type (in the example and test) on the property value source, not the color, and that one is a QObject. The same goes for interceptors. Change-Id: I505a658977a578894d6dfb00bf5c65b41e42b12f Task-number: QTBUG-56600 Reviewed-by: Michael Brasser --- src/qml/qml/qqmlvmemetaobject_p.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlvmemetaobject_p.h b/src/qml/qml/qqmlvmemetaobject_p.h index 27e638ceb4..7881240452 100644 --- a/src/qml/qml/qqmlvmemetaobject_p.h +++ b/src/qml/qml/qqmlvmemetaobject_p.h @@ -117,6 +117,8 @@ public: return false; } + // use by tst_qqmllanguage + QQmlPropertyValueInterceptor *firstInterceptor() const { return interceptors; } protected: int metaCall(QObject *o, QMetaObject::Call c, int id, void **a) override; bool intercept(QMetaObject::Call c, int id, void **a); -- cgit v1.2.3 From 485e183062043b39c0b6ec57caee7032dfffc5b0 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 19 Feb 2018 15:10:10 +0100 Subject: doc: Correct mostly linking errors This update corrects many qdoc warnings, mostly of the "Can't link to..." variety, but there were also a few qdoc comments added. As of this update, the qdoc warning count is 46 in QtDeclarative. Change-Id: Icf2d34c7ce7010ebfd9b474feacfe8af42f3fd5f Reviewed-by: Martin Smith --- src/qml/qml/qqmlcontext.cpp | 2 +- src/qml/qml/qqmlextensionplugin.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp index 0b0132fab7..82b8d06dc4 100644 --- a/src/qml/qml/qqmlcontext.cpp +++ b/src/qml/qml/qqmlcontext.cpp @@ -370,7 +370,7 @@ void QQmlContext::setContextProperties(const QVector &properties) This struct contains a property name and a property value. It is used as a parameter for the \c setContextProperties function. - \sa QQQmlContext::setContextProperties() + \sa QQmlContext::setContextProperties() */ /*! diff --git a/src/qml/qml/qqmlextensionplugin.cpp b/src/qml/qml/qqmlextensionplugin.cpp index b0e6a24616..818ff7c34f 100644 --- a/src/qml/qml/qqmlextensionplugin.cpp +++ b/src/qml/qml/qqmlextensionplugin.cpp @@ -121,7 +121,9 @@ void QQmlExtensionPlugin::initializeEngine(QQmlEngine *engine, const char *uri) \class QQmlExtensionInterface \internal \inmodule QtQml +*/ +/*! \class QQmlTypesExtensionInterface \internal \inmodule QtQml -- cgit v1.2.3 From 499ec43937e926e4f2fa57a9baa455fcb3862262 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 21 Feb 2018 10:41:54 +0100 Subject: use nullptr consistently (clang-tidy) From now on we prefer nullptr instead of 0 to clarify cases where we are assigning or testing a pointer rather than a numeric zero. Also, replaced cases where 0 was passed as Qt::KeyboardModifiers with Qt::NoModifier (clang-tidy replaced them with nullptr, which waas wrong, so it was just as well to make the tests more readable rather than to revert those lines). Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d Reviewed-by: Simon Hausmann --- src/qml/qml/ftw/qbitfield_p.h | 4 +- src/qml/qml/ftw/qfieldlist_p.h | 22 +++--- src/qml/qml/ftw/qfinitestack_p.h | 6 +- src/qml/qml/ftw/qhashedstring_p.h | 50 ++++++------- src/qml/qml/ftw/qintrusivelist_p.h | 20 ++--- src/qml/qml/ftw/qpodvector_p.h | 4 +- src/qml/qml/ftw/qqmlrefcount_p.h | 2 +- src/qml/qml/ftw/qqmlthread.cpp | 14 ++-- src/qml/qml/ftw/qqmlthread_p.h | 2 +- src/qml/qml/ftw/qrecursionwatcher_p.h | 4 +- src/qml/qml/ftw/qrecyclepool_p.h | 4 +- src/qml/qml/qqml.h | 2 +- src/qml/qml/qqmlabstractbinding.cpp | 4 +- src/qml/qml/qqmlapplicationengine.cpp | 2 +- src/qml/qml/qqmlbinding.cpp | 16 ++-- src/qml/qml/qqmlboundsignal.cpp | 14 ++-- src/qml/qml/qqmlboundsignal_p.h | 4 +- src/qml/qml/qqmlboundsignalexpressionpointer_p.h | 2 +- src/qml/qml/qqmlcleanup.cpp | 8 +- src/qml/qml/qqmlcleanup_p.h | 2 +- src/qml/qml/qqmlcomponent.cpp | 32 ++++---- src/qml/qml/qqmlcomponent_p.h | 2 +- src/qml/qml/qqmlcomponentattached_p.h | 4 +- src/qml/qml/qqmlcontext.cpp | 74 +++++++++---------- src/qml/qml/qqmlcontext_p.h | 22 +++--- src/qml/qml/qqmlcustomparser.cpp | 4 +- src/qml/qml/qqmlcustomparser_p.h | 4 +- src/qml/qml/qqmldata_p.h | 14 ++-- src/qml/qml/qqmldelayedcallqueue.cpp | 2 +- src/qml/qml/qqmlengine.cpp | 94 ++++++++++++------------ src/qml/qml/qqmlengine_p.h | 10 +-- src/qml/qml/qqmlerror.cpp | 12 +-- src/qml/qml/qqmlexpression.cpp | 10 +-- src/qml/qml/qqmlexpression_p.h | 4 +- src/qml/qml/qqmlfile.cpp | 10 +-- src/qml/qml/qqmlfileselector.cpp | 6 +- src/qml/qml/qqmlglobal.cpp | 18 ++--- src/qml/qml/qqmlglobal_p.h | 4 +- src/qml/qml/qqmlguard_p.h | 12 +-- src/qml/qml/qqmlimport.cpp | 24 +++--- src/qml/qml/qqmlimport_p.h | 8 +- src/qml/qml/qqmlincubator.cpp | 40 +++++----- src/qml/qml/qqmlinfo.cpp | 2 +- src/qml/qml/qqmljavascriptexpression.cpp | 26 +++---- src/qml/qml/qqmljavascriptexpression_p.h | 22 +++--- src/qml/qml/qqmllist.cpp | 18 ++--- src/qml/qml/qqmllistwrapper.cpp | 4 +- src/qml/qml/qqmllocale.cpp | 34 ++++----- src/qml/qml/qqmllocale_p.h | 2 +- src/qml/qml/qqmlloggingcategory_p.h | 2 +- src/qml/qml/qqmlmetatype.cpp | 88 +++++++++++----------- src/qml/qml/qqmlmetatype_p.h | 6 +- src/qml/qml/qqmlnotifier.cpp | 6 +- src/qml/qml/qqmlnotifier_p.h | 18 ++--- src/qml/qml/qqmlobjectcreator.cpp | 88 +++++++++++----------- src/qml/qml/qqmlobjectcreator_p.h | 6 +- src/qml/qml/qqmlopenmetaobject.cpp | 20 ++--- src/qml/qml/qqmlopenmetaobject_p.h | 2 +- src/qml/qml/qqmlparserstatus.cpp | 4 +- src/qml/qml/qqmlplatform_p.h | 2 +- src/qml/qml/qqmlprivate.h | 4 +- src/qml/qml/qqmlproperty.cpp | 64 ++++++++-------- src/qml/qml/qqmlproperty_p.h | 6 +- src/qml/qml/qqmlpropertycache.cpp | 72 +++++++++--------- src/qml/qml/qqmlpropertycache_p.h | 24 +++--- src/qml/qml/qqmlpropertyvalueinterceptor.cpp | 2 +- src/qml/qml/qqmlproxymetaobject.cpp | 6 +- src/qml/qml/qqmlscriptstring_p.h | 2 +- src/qml/qml/qqmlstringconverters_p.h | 18 ++--- src/qml/qml/qqmltypeloader.cpp | 42 +++++------ src/qml/qml/qqmltypeloader_p.h | 6 +- src/qml/qml/qqmltypenamecache.cpp | 20 ++--- src/qml/qml/qqmltypenamecache_p.h | 6 +- src/qml/qml/qqmltypewrapper.cpp | 2 +- src/qml/qml/qqmlvaluetype.cpp | 14 ++-- src/qml/qml/qqmlvaluetype_p.h | 8 +- src/qml/qml/qqmlvaluetypeproxybinding.cpp | 6 +- src/qml/qml/qqmlvaluetypewrapper.cpp | 32 ++++---- src/qml/qml/qqmlvme.cpp | 6 +- src/qml/qml/qqmlvme_p.h | 6 +- src/qml/qml/qqmlvmemetaobject.cpp | 42 +++++------ src/qml/qml/qqmlvmemetaobject_p.h | 8 +- src/qml/qml/qqmlxmlhttprequest.cpp | 78 ++++++++++---------- src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 24 +++--- src/qml/qml/v8/qv8engine.cpp | 6 +- src/qml/qml/v8/qv8engine_p.h | 2 +- 86 files changed, 726 insertions(+), 726 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/ftw/qbitfield_p.h b/src/qml/qml/ftw/qbitfield_p.h index 8f35842249..92017580d6 100644 --- a/src/qml/qml/ftw/qbitfield_p.h +++ b/src/qml/qml/ftw/qbitfield_p.h @@ -77,12 +77,12 @@ private: }; QBitField::QBitField() -: bits(0), ownData(0), data(0) +: bits(0), ownData(nullptr), data(nullptr) { } QBitField::QBitField(const quint32 *bitData, int bitCount) -: bits((quint32)bitCount), ownData(0), data(bitData) +: bits((quint32)bitCount), ownData(nullptr), data(bitData) { } diff --git a/src/qml/qml/ftw/qfieldlist_p.h b/src/qml/qml/ftw/qfieldlist_p.h index d83d708b5e..2bf07fb20d 100644 --- a/src/qml/qml/ftw/qfieldlist_p.h +++ b/src/qml/qml/ftw/qfieldlist_p.h @@ -141,7 +141,7 @@ N *QForwardFieldList::takeFirst() N *value = *_first; if (value) { _first = next(value); - value->*nextMember = 0; + value->*nextMember = nullptr; } return value; } @@ -149,7 +149,7 @@ N *QForwardFieldList::takeFirst() template void QForwardFieldList::prepend(N *v) { - Q_ASSERT(v->*nextMember == 0); + Q_ASSERT(v->*nextMember == nullptr); v->*nextMember = *_first; _first = v; } @@ -229,7 +229,7 @@ void QForwardFieldList::setFlag2Value(bool v) template QFieldList::QFieldList() -: _first(0), _last(0), _flag(0), _count(0) +: _first(nullptr), _last(nullptr), _flag(0), _count(0) { } @@ -246,10 +246,10 @@ N *QFieldList::takeFirst() if (value) { _first = next(value); if (_last == value) { - Q_ASSERT(_first == 0); - _last = 0; + Q_ASSERT(_first == nullptr); + _last = nullptr; } - value->*nextMember = 0; + value->*nextMember = nullptr; --_count; } return value; @@ -258,7 +258,7 @@ N *QFieldList::takeFirst() template void QFieldList::append(N *v) { - Q_ASSERT(v->*nextMember == 0); + Q_ASSERT(v->*nextMember == nullptr); if (isEmpty()) { _first = v; _last = v; @@ -272,7 +272,7 @@ void QFieldList::append(N *v) template void QFieldList::prepend(N *v) { - Q_ASSERT(v->*nextMember == 0); + Q_ASSERT(v->*nextMember == nullptr); if (isEmpty()) { _first = v; _last = v; @@ -375,7 +375,7 @@ void QFieldList::copyAndClear(QFieldList &o) _first = o._first; _last = o._last; _count = o._count; - o._first = o._last = 0; + o._first = o._last = nullptr; o._count = 0; } @@ -391,8 +391,8 @@ void QFieldList::copyAndClearAppend(QForwardFieldList void QFieldList::copyAndClearPrepend(QForwardFieldList &o) { - _first = 0; - _last = 0; + _first = nullptr; + _last = nullptr; _count = 0; while (N *n = o.takeFirst()) prepend(n); } diff --git a/src/qml/qml/ftw/qfinitestack_p.h b/src/qml/qml/ftw/qfinitestack_p.h index f1f1a551d5..9a74199137 100644 --- a/src/qml/qml/ftw/qfinitestack_p.h +++ b/src/qml/qml/ftw/qfinitestack_p.h @@ -81,7 +81,7 @@ private: template QFiniteStack::QFiniteStack() -: _array(0), _alloc(0), _size(0) +: _array(nullptr), _alloc(0), _size(0) { } @@ -156,7 +156,7 @@ T &QFiniteStack::operator[](int index) template void QFiniteStack::allocate(int size) { - Q_ASSERT(_array == 0); + Q_ASSERT(_array == nullptr); Q_ASSERT(_alloc == 0); Q_ASSERT(_size == 0); @@ -177,7 +177,7 @@ void QFiniteStack::deallocate() free(_array); - _array = 0; + _array = nullptr; _alloc = 0; _size = 0; } diff --git a/src/qml/qml/ftw/qhashedstring_p.h b/src/qml/qml/ftw/qhashedstring_p.h index 956805d696..bd2c9fbdb7 100644 --- a/src/qml/qml/ftw/qhashedstring_p.h +++ b/src/qml/qml/ftw/qhashedstring_p.h @@ -179,7 +179,7 @@ class Q_AUTOTEST_EXPORT QStringHashNode { public: QStringHashNode() - : length(0), hash(0), symbolId(0), ckey(0) + : length(0), hash(0), symbolId(0), ckey(nullptr) { } @@ -277,7 +277,7 @@ class Q_AUTOTEST_EXPORT QStringHashData { public: QStringHashData() - : buckets(0), numBuckets(0), size(0), numBits(0) + : buckets(nullptr), numBuckets(0), size(0), numBits(0) #ifdef QSTRINGHASH_LINK_DEBUG , linkCount(0) #endif @@ -292,7 +292,7 @@ public: #endif struct IteratorData { - IteratorData() : n(0), p(0) {} + IteratorData() : n(nullptr), p(nullptr) {} QStringHashNode *n; void *p; }; @@ -362,14 +362,14 @@ public: T value; }; struct NewedNode : public Node { - NewedNode(const QHashedString &key, const T &value) : Node(key, value), nextNewed(0) {} - NewedNode(const QHashedCStringRef &key, const T &value) : Node(key, value), nextNewed(0) {} - NewedNode(const Node &o) : Node(o), nextNewed(0) {} + NewedNode(const QHashedString &key, const T &value) : Node(key, value), nextNewed(nullptr) {} + NewedNode(const QHashedCStringRef &key, const T &value) : Node(key, value), nextNewed(nullptr) {} + NewedNode(const Node &o) : Node(o), nextNewed(nullptr) {} NewedNode *nextNewed; }; struct ReservedNodePool { - ReservedNodePool() : count(0), used(0), nodes(0) {} + ReservedNodePool() : count(0), used(0), nodes(nullptr) {} ~ReservedNodePool() { delete [] nodes; } int count; int used; @@ -475,13 +475,13 @@ public: template QStringHash::QStringHash() -: newedNodes(0), nodePool(0), link(0) +: newedNodes(nullptr), nodePool(nullptr), link(nullptr) { } template QStringHash::QStringHash(const QStringHash &other) -: newedNodes(0), nodePool(0), link(0) +: newedNodes(nullptr), nodePool(nullptr), link(nullptr) { data.numBits = other.data.numBits; data.size = other.data.size; @@ -579,14 +579,14 @@ void QStringHash::clear() if (nodePool) delete nodePool; delete [] data.buckets; - data.buckets = 0; + data.buckets = nullptr; data.numBuckets = 0; data.numBits = 0; data.size = 0; - newedNodes = 0; - nodePool = 0; - link = 0; + newedNodes = nullptr; + nodePool = nullptr; + link = nullptr; } template @@ -716,16 +716,16 @@ QStringHash::iterateNext(const QStringHashData::IteratorData &d) node < (This->nodePool->nodes + This->nodePool->used)) { node--; if (node < This->nodePool->nodes) - node = 0; + node = nullptr; } else { NewedNode *nn = (NewedNode *)node; node = nn->nextNewed; - if (node == 0 && This->nodePool && This->nodePool->used) + if (node == nullptr && This->nodePool && This->nodePool->used) node = This->nodePool->nodes + This->nodePool->used - 1; } - if (node == 0 && This->link) + if (node == nullptr && This->link) return This->link->iterateFirst(); QStringHashData::IteratorData rv; @@ -737,13 +737,13 @@ QStringHash::iterateNext(const QStringHashData::IteratorData &d) template QStringHashData::IteratorData QStringHash::iterateFirst() const { - Node *n = 0; + Node *n = nullptr; if (newedNodes) n = newedNodes; else if (nodePool && nodePool->used) n = nodePool->nodes + nodePool->used - 1; - if (n == 0 && link) + if (n == nullptr && link) return link->iterateFirst(); QStringHashData::IteratorData rv; @@ -822,7 +822,7 @@ void QStringHash::insert(const K &key, const T &value) { // If this is a linked hash, we can't rely on owning the node, so we always // create a new one. - Node *n = link?0:findNode(key); + Node *n = link?nullptr:findNode(key); if (n) n->value = value; else createNode(key, value); } @@ -837,7 +837,7 @@ template template typename QStringHash::Node *QStringHash::findNode(const K &key) const { - QStringHashNode *node = data.numBuckets?data.buckets[hashOf(key) % data.numBuckets]:0; + QStringHashNode *node = data.numBuckets?data.buckets[hashOf(key) % data.numBuckets]:nullptr; typename HashedForm::Type hashedKey(hashedString(key)); while (node && !node->equals(hashedKey)) @@ -851,7 +851,7 @@ template T *QStringHash::value(const K &key) const { Node *n = findNode(key); - return n?&n->value:0; + return n?&n->value:nullptr; } template @@ -865,14 +865,14 @@ template T *QStringHash::value(const QV4::String *string) const { Node *n = findNode(string); - return n?&n->value:0; + return n?&n->value:nullptr; } template template bool QStringHash::contains(const K &key) const { - return 0 != value(key); + return nullptr != value(key); } template @@ -1089,7 +1089,7 @@ quint32 QHashedString::existingHash() const } QHashedStringRef::QHashedStringRef() -: m_data(0), m_length(0), m_hash(0) +: m_data(nullptr), m_length(0), m_hash(0) { } @@ -1236,7 +1236,7 @@ quint32 QHashedStringRef::hash() const } QHashedCStringRef::QHashedCStringRef() -: m_data(0), m_length(0), m_hash(0) +: m_data(nullptr), m_length(0), m_hash(0) { } diff --git a/src/qml/qml/ftw/qintrusivelist_p.h b/src/qml/qml/ftw/qintrusivelist_p.h index 3d749e697e..c3b16f5b8c 100644 --- a/src/qml/qml/ftw/qintrusivelist_p.h +++ b/src/qml/qml/ftw/qintrusivelist_p.h @@ -113,7 +113,7 @@ public: template QIntrusiveList::iterator::iterator() -: _value(0) +: _value(nullptr) { } @@ -165,7 +165,7 @@ typename QIntrusiveList::iterator &QIntrusiveList::iterato template QIntrusiveList::QIntrusiveList() -: __first(0) +: __first(nullptr) { } @@ -178,7 +178,7 @@ QIntrusiveList::~QIntrusiveList() template bool QIntrusiveList::isEmpty() const { - return __first == 0; + return __first == nullptr; } template @@ -215,14 +215,14 @@ bool QIntrusiveList::contains(N *n) const template N *QIntrusiveList::first() const { - return __first?nodeToN(__first):0; + return __first?nodeToN(__first):nullptr; } template N *QIntrusiveList::next(N *current) { QIntrusiveListNode *nextnode = (current->*member)._next; - N *nextstruct = nextnode?nodeToN(nextnode):0; + N *nextstruct = nextnode?nodeToN(nextnode):nullptr; return nextstruct; } @@ -241,11 +241,11 @@ typename QIntrusiveList::iterator QIntrusiveList::end() template N *QIntrusiveList::nodeToN(QIntrusiveListNode *node) { - return (N *)((char *)node - ((char *)&(((N *)0)->*member) - (char *)0)); + return (N *)((char *)node - ((char *)&(((N *)nullptr)->*member) - (char *)nullptr)); } QIntrusiveListNode::QIntrusiveListNode() -: _next(0), _prev(0) +: _next(nullptr), _prev(nullptr) { } @@ -258,13 +258,13 @@ void QIntrusiveListNode::remove() { if (_prev) *_prev = _next; if (_next) _next->_prev = _prev; - _prev = 0; - _next = 0; + _prev = nullptr; + _next = nullptr; } bool QIntrusiveListNode::isInList() const { - return _prev != 0; + return _prev != nullptr; } QT_END_NAMESPACE diff --git a/src/qml/qml/ftw/qpodvector_p.h b/src/qml/qml/ftw/qpodvector_p.h index cafe3367de..d0e4f89741 100644 --- a/src/qml/qml/ftw/qpodvector_p.h +++ b/src/qml/qml/ftw/qpodvector_p.h @@ -61,7 +61,7 @@ class QPODVector { public: QPODVector() - : m_count(0), m_capacity(0), m_data(0) {} + : m_count(0), m_capacity(0), m_data(nullptr) {} ~QPODVector() { if (m_data) ::free(m_data); } const T &at(int idx) const { @@ -154,7 +154,7 @@ public: other.m_data = m_data; m_count = 0; m_capacity = 0; - m_data = 0; + m_data = nullptr; } QPODVector &operator<<(const T &v) { append(v); return *this; } diff --git a/src/qml/qml/ftw/qqmlrefcount_p.h b/src/qml/qml/ftw/qqmlrefcount_p.h index 225e18156c..3cfb345b30 100644 --- a/src/qml/qml/ftw/qqmlrefcount_p.h +++ b/src/qml/qml/ftw/qqmlrefcount_p.h @@ -137,7 +137,7 @@ void QQmlRefCount::destroy() template QQmlRefPointer::QQmlRefPointer() -: o(0) +: o(nullptr) { } diff --git a/src/qml/qml/ftw/qqmlthread.cpp b/src/qml/qml/ftw/qqmlthread.cpp index cae7088840..78b477b472 100644 --- a/src/qml/qml/ftw/qqmlthread.cpp +++ b/src/qml/qml/ftw/qqmlthread.cpp @@ -123,7 +123,7 @@ bool QQmlThreadPrivate::MainObject::event(QEvent *e) QQmlThreadPrivate::QQmlThreadPrivate(QQmlThread *q) : q(q), m_threadProcessing(false), m_mainProcessing(false), m_shutdown(false), - m_mainThreadWaiting(false), mainSync(0), m_mainObject(this) + m_mainThreadWaiting(false), mainSync(nullptr), m_mainObject(this) { setObjectName(QStringLiteral("QQmlThread")); } @@ -155,7 +155,7 @@ void QQmlThreadPrivate::mainEvent() m_mainProcessing = true; while (!mainList.isEmpty() || mainSync) { - bool isSync = mainSync != 0; + bool isSync = mainSync != nullptr; QQmlThread::Message *message = isSync?mainSync:mainList.takeFirst(); unlock(); @@ -165,7 +165,7 @@ void QQmlThreadPrivate::mainEvent() lock(); if (isSync) { - mainSync = 0; + mainSync = nullptr; wakeOne(); } } @@ -328,7 +328,7 @@ void QQmlThread::internalCallMethodInThread(Message *message) message->call(this); delete message; lock(); - d->mainSync = 0; + d->mainSync = nullptr; wakeOne(); } else { d->wait(); @@ -345,7 +345,7 @@ void QQmlThread::internalCallMethodInMain(Message *message) d->lock(); - Q_ASSERT(d->mainSync == 0); + Q_ASSERT(d->mainSync == nullptr); d->mainSync = message; if (d->m_mainThreadWaiting) { @@ -359,7 +359,7 @@ void QQmlThread::internalCallMethodInMain(Message *message) while (d->mainSync) { if (d->m_shutdown) { delete d->mainSync; - d->mainSync = 0; + d->mainSync = nullptr; break; } d->wait(); @@ -405,7 +405,7 @@ void QQmlThread::waitForNextMessage() message->call(this); delete message; lock(); - d->mainSync = 0; + d->mainSync = nullptr; wakeOne(); } else { d->wait(); diff --git a/src/qml/qml/ftw/qqmlthread_p.h b/src/qml/qml/ftw/qqmlthread_p.h index 295235e255..0ed12a2972 100644 --- a/src/qml/qml/ftw/qqmlthread_p.h +++ b/src/qml/qml/ftw/qqmlthread_p.h @@ -124,7 +124,7 @@ private: friend class QQmlThreadPrivate; struct Message { - Message() : next(0) {} + Message() : next(nullptr) {} virtual ~Message() {} Message *next; virtual void call(QQmlThread *) = 0; diff --git a/src/qml/qml/ftw/qrecursionwatcher_p.h b/src/qml/qml/ftw/qrecursionwatcher_p.h index 99228b9583..56b714f922 100644 --- a/src/qml/qml/ftw/qrecursionwatcher_p.h +++ b/src/qml/qml/ftw/qrecursionwatcher_p.h @@ -74,7 +74,7 @@ private: }; QRecursionNode::QRecursionNode() -: _r(0) +: _r(nullptr) { } @@ -89,7 +89,7 @@ QRecursionWatcher::QRecursionWatcher(T *t) template QRecursionWatcher::~QRecursionWatcher() { - if ((_t->*Node)._r == &_r) (_t->*Node)._r = 0; + if ((_t->*Node)._r == &_r) (_t->*Node)._r = nullptr; } template diff --git a/src/qml/qml/ftw/qrecyclepool_p.h b/src/qml/qml/ftw/qrecyclepool_p.h index 42a2f13729..39f4f88512 100644 --- a/src/qml/qml/ftw/qrecyclepool_p.h +++ b/src/qml/qml/ftw/qrecyclepool_p.h @@ -61,7 +61,7 @@ class QRecyclePoolPrivate public: QRecyclePoolPrivate() : recyclePoolHold(true), outstandingItems(0), cookie(QRECYCLEPOOLCOOKIE), - currentPage(0), nextAllocated(0) + currentPage(nullptr), nextAllocated(nullptr) { } @@ -178,7 +178,7 @@ void QRecyclePoolPrivate::releaseIfPossible() template T *QRecyclePoolPrivate::allocate() { - PoolType *rv = 0; + PoolType *rv = nullptr; if (nextAllocated) { rv = nextAllocated; nextAllocated = rv->nextAllocated; diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h index 219df264be..213f23cd98 100644 --- a/src/qml/qml/qqml.h +++ b/src/qml/qml/qqml.h @@ -354,7 +354,7 @@ int qmlRegisterRevision(const char *uri, int versionMajor, int versionMinor) sizeof(T), QQmlPrivate::createInto, QString(), - uri, versionMajor, versionMinor, 0, &T::staticMetaObject, + uri, versionMajor, versionMinor, nullptr, &T::staticMetaObject, QQmlPrivate::attachedPropertiesFunc(), QQmlPrivate::attachedPropertiesMetaObject(), diff --git a/src/qml/qml/qqmlabstractbinding.cpp b/src/qml/qml/qqmlabstractbinding.cpp index b1c320afd4..42891c1a8e 100644 --- a/src/qml/qml/qqmlabstractbinding.cpp +++ b/src/qml/qml/qqmlabstractbinding.cpp @@ -83,7 +83,7 @@ void QQmlAbstractBinding::addToObject() // Value type // Find the value type proxy (if there is one) - QQmlValueTypeProxyBinding *proxy = 0; + QQmlValueTypeProxyBinding *proxy = nullptr; if (data->hasBindingBit(coreIndex)) { QQmlAbstractBinding *b = data->bindings; while (b && (b->targetPropertyIndex().coreIndex() != coreIndex || @@ -137,7 +137,7 @@ void QQmlAbstractBinding::removeFromObject() QQmlAbstractBinding::Ptr next; next = nextBinding(); - setNextBinding(0); + setNextBinding(nullptr); int coreIndex = targetPropertyIndex().coreIndex(); if (targetPropertyIndex().hasValueTypeIndex()) { diff --git a/src/qml/qml/qqmlapplicationengine.cpp b/src/qml/qml/qqmlapplicationengine.cpp index faab8bf926..a0517e4558 100644 --- a/src/qml/qml/qqmlapplicationengine.cpp +++ b/src/qml/qml/qqmlapplicationengine.cpp @@ -128,7 +128,7 @@ void QQmlApplicationEnginePrivate::finishLoad(QQmlComponent *c) case QQmlComponent::Error: qWarning() << "QQmlApplicationEngine failed to load component"; qWarning() << qPrintable(c->errorString()); - q->objectCreated(0, c->url()); + q->objectCreated(nullptr, c->url()); break; case QQmlComponent::Ready: { auto newObj = c->create(); diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index a968aa908d..ca3bff43a4 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -70,7 +70,7 @@ QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QQmlScr return b; QString url; - QV4::Function *runtimeFunction = 0; + QV4::Function *runtimeFunction = nullptr; QQmlContextData *ctxtdata = QQmlContextData::get(scriptPrivate->context); QQmlEnginePrivate *engine = QQmlEnginePrivate::get(scriptPrivate->context->engine()); @@ -150,7 +150,7 @@ void QQmlBinding::update(QQmlPropertyData::WriteFlags flags) QQmlPropertyData vtd; getPropertyData(&d, &vtd); Q_ASSERT(d); - QQmlProperty p = QQmlPropertyPrivate::restore(targetObject(), *d, &vtd, 0); + QQmlProperty p = QQmlPropertyPrivate::restore(targetObject(), *d, &vtd, nullptr); QQmlAbstractBinding::printBindingLoopError(p); return; } @@ -364,7 +364,7 @@ Q_NEVER_INLINE bool QQmlBinding::slowWrite(const QQmlPropertyData &core, } else if (core.isQList()) { value = v4engine->toVariant(result, qMetaTypeId >()); } else if (result.isNull() && core.isQObject()) { - value = QVariant::fromValue((QObject *)0); + value = QVariant::fromValue((QObject *)nullptr); } else if (core.propType() == qMetaTypeId >()) { value = QQmlPropertyPrivate::resolvedUrlSequence(v4engine->toVariant(result, qMetaTypeId >()), context()); } else if (!isVarProperty && type != qMetaTypeId()) { @@ -386,7 +386,7 @@ Q_NEVER_INLINE bool QQmlBinding::slowWrite(const QQmlPropertyData &core, Q_ASSERT(vmemo); vmemo->setVMEProperty(core.coreIndex(), result); } else if (isUndefined && core.isResettable()) { - void *args[] = { 0 }; + void *args[] = { nullptr }; QMetaObject::metacall(m_target.data(), QMetaObject::ResetProperty, core.coreIndex(), args); } else if (isUndefined && type == qMetaTypeId()) { QQmlPropertyPrivate::writeValueProperty(m_target.data(), core, valueTypeData, QVariant(), context(), flags); @@ -417,8 +417,8 @@ Q_NEVER_INLINE bool QQmlBinding::slowWrite(const QQmlPropertyData &core, if (watcher.wasDeleted()) return true; - const char *valueType = 0; - const char *propertyType = 0; + const char *valueType = nullptr; + const char *propertyType = nullptr; const int userType = value.userType(); if (userType == QMetaType::QObjectStar) { @@ -530,7 +530,7 @@ void QQmlBinding::setTarget(QObject *object, const QQmlPropertyData &core, const int aValueTypeIndex; if (!vme->aliasTarget(coreIndex, &object, &coreIndex, &aValueTypeIndex)) { - m_target = 0; + m_target = nullptr; m_targetIndex = QQmlPropertyIndex(); return; } @@ -539,7 +539,7 @@ void QQmlBinding::setTarget(QObject *object, const QQmlPropertyData &core, const QQmlData *data = QQmlData::get(object, false); if (!data || !data->propertyCache) { - m_target = 0; + m_target = nullptr; m_targetIndex = QQmlPropertyIndex(); return; } diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index 501184b630..060706ac50 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -191,7 +191,7 @@ void QQmlBoundSignalExpression::evaluate(void **a) QQmlMetaObject::ArgTypeStorage storage; //TODO: lookup via signal index rather than method index as an optimization int methodIndex = QMetaObjectPrivate::signal(m_target->metaObject(), m_index).methodIndex(); - int *argsTypes = QQmlMetaObject(m_target).methodParameterTypes(methodIndex, &storage, 0); + int *argsTypes = QQmlMetaObject(m_target).methodParameterTypes(methodIndex, &storage, nullptr); int argCount = argsTypes ? *argsTypes : 0; QV4::JSCallData jsCall(scope, argCount); @@ -222,7 +222,7 @@ void QQmlBoundSignalExpression::evaluate(void **a) } } - QQmlJavaScriptExpression::evaluate(jsCall.callData(), 0); + QQmlJavaScriptExpression::evaluate(jsCall.callData(), nullptr); ep->dereferenceScarceResources(); // "release" scarce resources if top-level expression evaluation is complete. } @@ -245,7 +245,7 @@ void QQmlBoundSignalExpression::evaluate(const QList &args) jsCall->args[ii] = scope.engine->fromVariant(args[ii]); } - QQmlJavaScriptExpression::evaluate(jsCall.callData(), 0); + QQmlJavaScriptExpression::evaluate(jsCall.callData(), nullptr); ep->dereferenceScarceResources(); // "release" scarce resources if top-level expression evaluation is complete. } @@ -260,8 +260,8 @@ void QQmlBoundSignalExpression::evaluate(const QList &args) QQmlBoundSignal::QQmlBoundSignal(QObject *target, int signal, QObject *owner, QQmlEngine *engine) : QQmlNotifierEndpoint(QQmlNotifierEndpoint::QQmlBoundSignal), - m_prevSignal(0), m_nextSignal(0), - m_enabled(true), m_expression(0) + m_prevSignal(nullptr), m_nextSignal(nullptr), + m_enabled(true), m_expression(nullptr) { addToObject(owner); @@ -298,8 +298,8 @@ void QQmlBoundSignal::removeFromObject() if (m_prevSignal) { *m_prevSignal = m_nextSignal; if (m_nextSignal) m_nextSignal->m_prevSignal = m_prevSignal; - m_prevSignal = 0; - m_nextSignal = 0; + m_prevSignal = nullptr; + m_nextSignal = nullptr; } } diff --git a/src/qml/qml/qqmlboundsignal_p.h b/src/qml/qml/qqmlboundsignal_p.h index 3a0b8aed59..d3e584fd13 100644 --- a/src/qml/qml/qqmlboundsignal_p.h +++ b/src/qml/qml/qqmlboundsignal_p.h @@ -89,14 +89,14 @@ public: QString expression() const; QObject *target() const { return m_target; } - QQmlEngine *engine() const { return context() ? context()->engine : 0; } + QQmlEngine *engine() const { return context() ? context()->engine : nullptr; } private: ~QQmlBoundSignalExpression(); void init(QQmlContextData *ctxt, QObject *scope); - bool expressionFunctionValid() const { return function() != 0; } + bool expressionFunctionValid() const { return function() != nullptr; } int m_index; QObject *m_target; diff --git a/src/qml/qml/qqmlboundsignalexpressionpointer_p.h b/src/qml/qml/qqmlboundsignalexpressionpointer_p.h index de651315f8..685e0160a3 100644 --- a/src/qml/qml/qqmlboundsignalexpressionpointer_p.h +++ b/src/qml/qml/qqmlboundsignalexpressionpointer_p.h @@ -58,7 +58,7 @@ class QQmlBoundSignalExpression; class Q_QML_PRIVATE_EXPORT QQmlBoundSignalExpressionPointer { public: - inline QQmlBoundSignalExpressionPointer() : o(0) {} + inline QQmlBoundSignalExpressionPointer() : o(nullptr) {} QQmlBoundSignalExpressionPointer(QQmlBoundSignalExpression *); QQmlBoundSignalExpressionPointer(const QQmlBoundSignalExpressionPointer &); ~QQmlBoundSignalExpressionPointer(); diff --git a/src/qml/qml/qqmlcleanup.cpp b/src/qml/qml/qqmlcleanup.cpp index 708537a303..0d57ef5fe8 100644 --- a/src/qml/qml/qqmlcleanup.cpp +++ b/src/qml/qml/qqmlcleanup.cpp @@ -58,7 +58,7 @@ called by QQmlEngine just before it destroys the context. Create a QQmlCleanup that is not associated with any engine. */ QQmlCleanup::QQmlCleanup() -: prev(0), next(0), engine(0) +: prev(nullptr), next(nullptr), engine(nullptr) { } @@ -66,7 +66,7 @@ QQmlCleanup::QQmlCleanup() Create a QQmlCleanup for \a engine */ QQmlCleanup::QQmlCleanup(QQmlEngine *engine) -: prev(0), next(0), engine(0) +: prev(nullptr), next(nullptr), engine(nullptr) { if (!engine) return; @@ -109,8 +109,8 @@ QQmlCleanup::~QQmlCleanup() if (prev) *prev = next; if (next) next->prev = prev; - prev = 0; - next = 0; + prev = nullptr; + next = nullptr; } QT_END_NAMESPACE diff --git a/src/qml/qml/qqmlcleanup_p.h b/src/qml/qml/qqmlcleanup_p.h index a1db656477..0e15c28b9d 100644 --- a/src/qml/qml/qqmlcleanup_p.h +++ b/src/qml/qml/qqmlcleanup_p.h @@ -64,7 +64,7 @@ public: QQmlCleanup(QQmlEngine *); virtual ~QQmlCleanup(); - bool hasEngine() const { return prev != 0; } + bool hasEngine() const { return prev != nullptr; } void addToEngine(QQmlEngine *); protected: virtual void clear() = 0; diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 481507946d..061f3b54a5 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -315,7 +315,7 @@ void QQmlComponentPrivate::typeDataReady(QQmlTypeData *) Q_ASSERT(typeData); fromTypeData(typeData); - typeData = 0; + typeData = nullptr; progress = 1.0; emit q->statusChanged(q->status()); @@ -349,7 +349,7 @@ void QQmlComponentPrivate::clear() if (typeData) { typeData->unregisterCallback(this); typeData->release(); - typeData = 0; + typeData = nullptr; } compilationUnit = nullptr; @@ -820,27 +820,27 @@ QQmlComponentPrivate::beginCreate(QQmlContextData *context) Q_Q(QQmlComponent); if (!context) { qWarning("QQmlComponent: Cannot create a component in a null context"); - return 0; + return nullptr; } if (!context->isValid()) { qWarning("QQmlComponent: Cannot create a component in an invalid context"); - return 0; + return nullptr; } if (context->engine != engine) { qWarning("QQmlComponent: Must create component in context from the same QQmlEngine"); - return 0; + return nullptr; } if (state.completePending) { qWarning("QQmlComponent: Cannot create new component instance before completing the previous"); - return 0; + return nullptr; } if (!q->isReady()) { qWarning("QQmlComponent: Component is not ready"); - return 0; + return nullptr; } // Do not create infinite recursion in object creation @@ -848,7 +848,7 @@ QQmlComponentPrivate::beginCreate(QQmlContextData *context) if (++creationDepth.localData() >= maxCreationDepth) { qWarning("QQmlComponent: Component creation is recursing - aborting"); --creationDepth.localData(); - return 0; + return nullptr; } Q_ASSERT(creationDepth.localData() >= 1); depthIncreased = true; @@ -860,7 +860,7 @@ QQmlComponentPrivate::beginCreate(QQmlContextData *context) state.completePending = true; enginePriv->referenceScarceResources(); - QObject *rv = 0; + QObject *rv = nullptr; state.creator.reset(new QQmlObjectCreator(context, compilationUnit, creationContext)); rv = state.creator->create(start); if (!rv) @@ -965,7 +965,7 @@ void QQmlComponentPrivate::completeCreate() } QQmlComponentAttached::QQmlComponentAttached(QObject *parent) -: QObject(parent), prev(0), next(0) +: QObject(parent), prev(nullptr), next(nullptr) { } @@ -973,8 +973,8 @@ QQmlComponentAttached::~QQmlComponentAttached() { if (prev) *prev = next; if (next) next->prev = prev; - prev = 0; - next = 0; + prev = nullptr; + next = nullptr; } /*! @@ -1269,7 +1269,7 @@ void QQmlComponent::createObject(QQmlV4Function *args) Q_ASSERT(d->engine); Q_ASSERT(args); - QObject *parent = 0; + QObject *parent = nullptr; QV4::ExecutionEngine *v4 = args->v4engine(); QV4::Scope scope(v4); QV4::ScopedValue valuemap(scope, QV4::Primitive::undefinedValue()); @@ -1386,7 +1386,7 @@ void QQmlComponent::incubateObject(QQmlV4Function *args) QV4::ExecutionEngine *v4 = args->v4engine(); QV4::Scope scope(v4); - QObject *parent = 0; + QObject *parent = nullptr; QV4::ScopedValue valuemap(scope, QV4::Primitive::undefinedValue()); QQmlIncubator::IncubationMode mode = QQmlIncubator::Asynchronous; @@ -1457,8 +1457,8 @@ QQmlComponentExtension::QQmlComponentExtension(QV4::ExecutionEngine *v4) QV4::ScopedObject proto(scope, v4->newObject()); proto->defineAccessorProperty(QStringLiteral("onStatusChanged"), QV4::QmlIncubatorObject::method_get_statusChanged, QV4::QmlIncubatorObject::method_set_statusChanged); - proto->defineAccessorProperty(QStringLiteral("status"), QV4::QmlIncubatorObject::method_get_status, 0); - proto->defineAccessorProperty(QStringLiteral("object"), QV4::QmlIncubatorObject::method_get_object, 0); + proto->defineAccessorProperty(QStringLiteral("status"), QV4::QmlIncubatorObject::method_get_status, nullptr); + proto->defineAccessorProperty(QStringLiteral("object"), QV4::QmlIncubatorObject::method_get_object, nullptr); proto->defineDefaultProperty(QStringLiteral("forceCompletion"), QV4::QmlIncubatorObject::method_forceCompletion); incubationProto.set(v4, proto); diff --git a/src/qml/qml/qqmlcomponent_p.h b/src/qml/qml/qqmlcomponent_p.h index 8a58a1ada0..2a8d36f317 100644 --- a/src/qml/qml/qqmlcomponent_p.h +++ b/src/qml/qml/qqmlcomponent_p.h @@ -79,7 +79,7 @@ class Q_QML_PRIVATE_EXPORT QQmlComponentPrivate : public QObjectPrivate, public public: QQmlComponentPrivate() - : typeData(0), progress(0.), start(-1), engine(0), creationContext(0), depthIncreased(false) {} + : typeData(nullptr), progress(0.), start(-1), engine(nullptr), creationContext(nullptr), depthIncreased(false) {} void loadUrl(const QUrl &newUrl, QQmlComponent::CompilationMode mode = QQmlComponent::PreferSynchronous); diff --git a/src/qml/qml/qqmlcomponentattached_p.h b/src/qml/qml/qqmlcomponentattached_p.h index 8236aac1af..e3bca18857 100644 --- a/src/qml/qml/qqmlcomponentattached_p.h +++ b/src/qml/qml/qqmlcomponentattached_p.h @@ -62,7 +62,7 @@ class Q_QML_PRIVATE_EXPORT QQmlComponentAttached : public QObject { Q_OBJECT public: - QQmlComponentAttached(QObject *parent = 0); + QQmlComponentAttached(QObject *parent = nullptr); ~QQmlComponentAttached(); void add(QQmlComponentAttached **a) { @@ -72,7 +72,7 @@ public: void rem() { if (next) next->prev = prev; *prev = next; - next = 0; prev = 0; + next = nullptr; prev = nullptr; } QQmlComponentAttached **prev; QQmlComponentAttached *next; diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp index 82b8d06dc4..6e43bc735f 100644 --- a/src/qml/qml/qqmlcontext.cpp +++ b/src/qml/qml/qqmlcontext.cpp @@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE QQmlContextPrivate::QQmlContextPrivate() -: data(0), notifyIndex(-1) +: data(nullptr), notifyIndex(-1) { } @@ -177,7 +177,7 @@ QQmlContext::QQmlContext(QQmlEngine *engine, QObject *parent) d->data = new QQmlContextData(this); ++d->data->refCount; - d->data->setParent(engine?QQmlContextData::get(engine->rootContext()):0); + d->data->setParent(engine?QQmlContextData::get(engine->rootContext()):nullptr); } /*! @@ -191,14 +191,14 @@ QQmlContext::QQmlContext(QQmlContext *parentContext, QObject *parent) d->data = new QQmlContextData(this); ++d->data->refCount; - d->data->setParent(parentContext?QQmlContextData::get(parentContext):0); + d->data->setParent(parentContext?QQmlContextData::get(parentContext):nullptr); } /*! \internal */ QQmlContext::QQmlContext(QQmlContextData *data) -: QObject(*(new QQmlContextPrivate), 0) +: QObject(*(new QQmlContextPrivate), nullptr) { Q_D(QQmlContext); d->data = data; @@ -216,7 +216,7 @@ QQmlContext::~QQmlContext() { Q_D(QQmlContext); - d->data->publicContext = 0; + d->data->publicContext = nullptr; if (!--d->data->refCount) d->data->destroy(); } @@ -250,7 +250,7 @@ QQmlEngine *QQmlContext::engine() const QQmlContext *QQmlContext::parentContext() const { Q_D(const QQmlContext); - return d->data->parent?d->data->parent->asQQmlContext():0; + return d->data->parent?d->data->parent->asQQmlContext():nullptr; } /*! @@ -315,7 +315,7 @@ void QQmlContext::setContextProperty(const QString &name, const QVariant &value) data->refreshExpressions(); } else { d->propertyValues[idx] = value; - QMetaObject::activate(this, d->notifyIndex, idx, 0); + QMetaObject::activate(this, d->notifyIndex, idx, nullptr); } } @@ -349,8 +349,8 @@ void QQmlContext::setContextProperties(const QVector &properties) QQmlJavaScriptExpression *expressions = data->expressions; QQmlContextData *childContexts = data->childContexts; - data->expressions = 0; - data->childContexts = 0; + data->expressions = nullptr; + data->childContexts = nullptr; for (auto property : properties) setContextProperty(property.name, property.value); @@ -521,7 +521,7 @@ QObject *QQmlContextPrivate::context_at(QQmlListProperty *prop, int ind int contextProperty = (int)(quintptr)prop->data; if (d->propertyValues.at(contextProperty).userType() != qMetaTypeId >()) { - return 0; + return nullptr; } else { return ((const QList *)d->propertyValues.at(contextProperty).constData())->at(index); } @@ -534,12 +534,12 @@ QQmlContextData::QQmlContextData() } QQmlContextData::QQmlContextData(QQmlContext *ctxt) - : engine(0), isInternal(false), isJSContext(false), + : engine(nullptr), isInternal(false), isJSContext(false), isPragmaLibraryContext(false), unresolvedNames(false), hasEmittedDestruction(false), isRootObjectInCreation(false), - publicContext(ctxt), incubator(0), componentObjectIndex(-1), - contextObject(0), nextChild(0), prevChild(0), - expressions(0), contextObjects(0), idValues(0), idValueCount(0), - componentAttached(0) + publicContext(ctxt), incubator(nullptr), componentObjectIndex(-1), + contextObject(nullptr), nextChild(nullptr), prevChild(nullptr), + expressions(nullptr), contextObjects(nullptr), idValues(nullptr), idValueCount(0), + componentAttached(nullptr) { } @@ -556,8 +556,8 @@ void QQmlContextData::emitDestruction() componentAttached = a->next; if (componentAttached) componentAttached->prev = &componentAttached; - a->next = 0; - a->prev = 0; + a->next = nullptr; + a->prev = nullptr; emit a->destruction(); } @@ -583,14 +583,14 @@ void QQmlContextData::invalidate() if (prevChild) { *prevChild = nextChild; if (nextChild) nextChild->prevChild = prevChild; - nextChild = 0; - prevChild = 0; + nextChild = nullptr; + prevChild = nullptr; } importedScripts.clear(); - engine = 0; - parent = 0; + engine = nullptr; + parent = nullptr; } void QQmlContextData::clearContext() @@ -601,20 +601,20 @@ void QQmlContextData::clearContext() while (expression) { QQmlJavaScriptExpression *nextExpression = expression->m_nextExpression; - expression->m_prevExpression = 0; - expression->m_nextExpression = 0; + expression->m_prevExpression = nullptr; + expression->m_nextExpression = nullptr; - expression->setContext(0); + expression->setContext(nullptr); expression = nextExpression; } - expressions = 0; + expressions = nullptr; } void QQmlContextData::destroy() { Q_ASSERT(refCount == 0); - linkedContext = 0; + linkedContext = nullptr; // avoid recursion ++refCount; @@ -629,26 +629,26 @@ void QQmlContextData::destroy() QQmlData *co = contextObjects; contextObjects = contextObjects->nextContextObject; - co->context = 0; - co->outerContext = 0; - co->nextContextObject = 0; - co->prevContextObject = 0; + co->context = nullptr; + co->outerContext = nullptr; + co->nextContextObject = nullptr; + co->prevContextObject = nullptr; } Q_ASSERT(refCount == 1); QQmlGuardedContextData *contextGuard = contextGuards; while (contextGuard) { QQmlGuardedContextData *next = contextGuard->m_next; - contextGuard->m_next = 0; - contextGuard->m_prev = 0; - contextGuard->m_contextData = 0; + contextGuard->m_next = nullptr; + contextGuard->m_prev = nullptr; + contextGuard->m_contextData = nullptr; contextGuard = next; } - contextGuards = 0; + contextGuards = nullptr; Q_ASSERT(refCount == 1); delete [] idValues; - idValues = 0; + idValues = nullptr; Q_ASSERT(refCount == 1); if (publicContext) { @@ -746,7 +746,7 @@ void QQmlContextData::refreshExpressionsRecursive(bool isGlobal) // *structure* (not values) changes. void QQmlContextData::refreshExpressions() { - bool isGlobal = (parent == 0); + bool isGlobal = (parent == nullptr); // For efficiency, we try and minimize the number of guards we have to create if (expressions_to_run(this, isGlobal) && childContexts) { @@ -772,7 +772,7 @@ void QQmlContextData::addObject(QObject *o) { QQmlData *data = QQmlData::get(o, true); - Q_ASSERT(data->context == 0); + Q_ASSERT(data->context == nullptr); data->context = this; data->outerContext = this; diff --git a/src/qml/qml/qqmlcontext_p.h b/src/qml/qml/qqmlcontext_p.h index 8939c810fe..ff36d6c9a8 100644 --- a/src/qml/qml/qqmlcontext_p.h +++ b/src/qml/qml/qqmlcontext_p.h @@ -178,7 +178,7 @@ public: QQmlRefPointer imports; // My children - QQmlContextData *childContexts = 0; + QQmlContextData *childContexts = nullptr; // My peers in parent's childContexts list QQmlContextData *nextChild; @@ -191,7 +191,7 @@ public: QQmlData *contextObjects; // Doubly-linked list of context guards (XXX merge with contextObjects) - QQmlGuardedContextData *contextGuards = 0; + QQmlGuardedContextData *contextGuards = nullptr; // id guards struct ContextGuard : public QQmlGuard @@ -261,9 +261,9 @@ private: inline void clear(); - QQmlContextData *m_contextData = 0; - QQmlGuardedContextData *m_next = 0; - QQmlGuardedContextData **m_prev = 0; + QQmlContextData *m_contextData = nullptr; + QQmlGuardedContextData *m_next = nullptr; + QQmlGuardedContextData **m_prev = nullptr; }; @@ -287,14 +287,14 @@ void QQmlGuardedContextData::clear() if (m_prev) { *m_prev = m_next; if (m_next) m_next->m_prev = m_prev; - m_contextData = 0; - m_next = 0; - m_prev = 0; + m_contextData = nullptr; + m_next = nullptr; + m_prev = nullptr; } } QQmlContextDataRef::QQmlContextDataRef() - : m_contextData(0) + : m_contextData(nullptr) { } @@ -338,7 +338,7 @@ void QQmlContextDataRef::clear() { if (m_contextData && !--m_contextData->refCount) m_contextData->destroy(); - m_contextData = 0; + m_contextData = nullptr; } QQmlContextDataRef & @@ -356,7 +356,7 @@ QQmlContextDataRef::operator=(const QQmlContextDataRef &other) } QQmlContextData::ContextGuard::ContextGuard() -: context(0) +: context(nullptr) { } diff --git a/src/qml/qml/qqmlcustomparser.cpp b/src/qml/qml/qqmlcustomparser.cpp index cc6e75a39c..5cf87f5264 100644 --- a/src/qml/qml/qqmlcustomparser.cpp +++ b/src/qml/qml/qqmlcustomparser.cpp @@ -138,7 +138,7 @@ int QQmlCustomParser::evaluateEnum(const QByteArray& script, bool *ok) const QQmlType type; if (imports.isT1()) { - imports.asT1()->resolveType(scope, &type, 0, 0, 0); + imports.asT1()->resolveType(scope, &type, nullptr, nullptr, nullptr); } else { QQmlTypeNameCache::Result result = imports.asT2()->query(scope); if (result.isValid()) @@ -178,7 +178,7 @@ const QMetaObject *QQmlCustomParser::resolveType(const QString& name) const if (!imports.isT1()) return nullptr; QQmlType qmltype; - if (!imports.asT1()->resolveType(name, &qmltype, 0, 0, 0)) + if (!imports.asT1()->resolveType(name, &qmltype, nullptr, nullptr, nullptr)) return nullptr; return qmltype.metaObject(); } diff --git a/src/qml/qml/qqmlcustomparser_p.h b/src/qml/qml/qqmlcustomparser_p.h index 5eb409990d..2a0f805014 100644 --- a/src/qml/qml/qqmlcustomparser_p.h +++ b/src/qml/qml/qqmlcustomparser_p.h @@ -74,8 +74,8 @@ public: }; Q_DECLARE_FLAGS(Flags, Flag) - QQmlCustomParser() : engine(0), validator(0), m_flags(NoFlag) {} - QQmlCustomParser(Flags f) : engine(0), validator(0), m_flags(f) {} + QQmlCustomParser() : engine(nullptr), validator(nullptr), m_flags(NoFlag) {} + QQmlCustomParser(Flags f) : engine(nullptr), validator(nullptr), m_flags(f) {} virtual ~QQmlCustomParser() {} void clearErrors(); diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h index 17d145f939..20b96d2c4b 100644 --- a/src/qml/qml/qqmldata_p.h +++ b/src/qml/qml/qqmldata_p.h @@ -195,9 +195,9 @@ public: void disconnectNotifiers(); // The context that created the C++ object - QQmlContextData *context = 0; + QQmlContextData *context = nullptr; // The outermost context in which this object lives - QQmlContextData *outerContext = 0; + QQmlContextData *outerContext = nullptr; QQmlContextDataRef ownContext; QQmlAbstractBinding *bindings; @@ -247,13 +247,13 @@ public: // to be avoided because QObjectPrivate::currentChildBeingDeleted is in use. if (priv->isDeletingChildren || priv->wasDeleted) { Q_ASSERT(!create); - return 0; + return nullptr; } else if (priv->declarativeData) { return static_cast(priv->declarativeData); } else if (create) { return createQQmlData(priv); } else { - return 0; + return nullptr; } } @@ -264,7 +264,7 @@ public: return false; } - bool hasExtendedData() const { return extendedData != 0; } + bool hasExtendedData() const { return extendedData != nullptr; } QHash *attachedProperties() const; static inline bool wasDeleted(const QObject *); @@ -325,7 +325,7 @@ QQmlNotifierEndpoint *QQmlData::notify(int index) Q_ASSERT(index <= 0xFFFF); if (!notifyList || !(notifyList->connectionMask & (1ULL << quint64(index % 64)))) { - return 0; + return nullptr; } else if (index < notifyList->notifiesSize) { return notifyList->notifies[index]; } else if (index <= notifyList->maximumTodoIndex) { @@ -335,7 +335,7 @@ QQmlNotifierEndpoint *QQmlData::notify(int index) if (index < notifyList->notifiesSize) { return notifyList->notifies[index]; } else { - return 0; + return nullptr; } } diff --git a/src/qml/qml/qqmldelayedcallqueue.cpp b/src/qml/qml/qqmldelayedcallqueue.cpp index 268f91c8ba..5bcf5cd586 100644 --- a/src/qml/qml/qqmldelayedcallqueue.cpp +++ b/src/qml/qml/qqmldelayedcallqueue.cpp @@ -89,7 +89,7 @@ void QQmlDelayedCallQueue::DelayedFunctionCall::execute(QV4::ExecutionEngine *en // QQmlDelayedCallQueue::QQmlDelayedCallQueue() - : QObject(0), m_engine(0), m_callbackOutstanding(false) + : QObject(nullptr), m_engine(nullptr), m_callbackOutstanding(false) { } diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 02e206284b..4054d2f0be 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -669,19 +669,19 @@ the same object as is returned from the Qt.include() call. // Qt.include() is implemented in qv4include.cpp QQmlEnginePrivate::QQmlEnginePrivate(QQmlEngine *e) -: propertyCapture(0), rootContext(0), +: propertyCapture(nullptr), rootContext(nullptr), #if QT_CONFIG(qml_debug) - profiler(0), + profiler(nullptr), #endif outputWarningsToMsgLog(true), - cleanup(0), erroredBindings(0), inProgressCreations(0), - workerScriptEngine(0), - activeObjectCreator(0), + cleanup(nullptr), erroredBindings(nullptr), inProgressCreations(0), + workerScriptEngine(nullptr), + activeObjectCreator(nullptr), #if QT_CONFIG(qml_network) - networkAccessManager(0), networkAccessManagerFactory(0), + networkAccessManager(nullptr), networkAccessManagerFactory(nullptr), #endif - urlInterceptor(0), scarceResourcesRefCount(0), importDatabase(e), typeLoader(e), - uniqueId(1), incubatorCount(0), incubationController(0) + urlInterceptor(nullptr), scarceResourcesRefCount(0), importDatabase(e), typeLoader(e), + uniqueId(1), incubatorCount(0), incubationController(nullptr) { } @@ -694,15 +694,15 @@ QQmlEnginePrivate::~QQmlEnginePrivate() QQmlCleanup *c = cleanup; cleanup = c->next; if (cleanup) cleanup->prev = &cleanup; - c->next = 0; - c->prev = 0; + c->next = nullptr; + c->prev = nullptr; c->clear(); } doDeleteInEngineThread(); - if (incubationController) incubationController->d = 0; - incubationController = 0; + if (incubationController) incubationController->d = nullptr; + incubationController = nullptr; QQmlMetaType::freeUnusedTypesAndCaches(); @@ -731,8 +731,8 @@ void QQmlPrivate::qdeclarativeelement_destructor(QObject *o) d->ownContext->invalidate(); if (d->ownContext->contextObject == o) d->ownContext->contextObject = nullptr; - d->ownContext = 0; - d->context = 0; + d->ownContext = nullptr; + d->context = nullptr; } // Mark this object as in the process of deletion to @@ -750,10 +750,10 @@ QQmlData::QQmlData() : ownedByQml1(false), ownMemory(true), indestructible(true), explicitIndestructibleSet(false), hasTaintedV4Object(false), isQueuedForDeletion(false), rootObjectInCreation(false), hasInterceptorMetaObject(false), hasVMEMetaObject(false), parentFrozen(false), - bindingBitsArraySize(InlineBindingArraySize), notifyList(0), - bindings(0), signalHandlers(0), nextContextObject(0), prevContextObject(0), + bindingBitsArraySize(InlineBindingArraySize), notifyList(nullptr), + bindings(nullptr), signalHandlers(nullptr), nextContextObject(nullptr), prevContextObject(nullptr), lineNumber(0), columnNumber(0), jsEngineId(0), - propertyCache(0), guards(0), extendedData(0) + propertyCache(nullptr), guards(nullptr), extendedData(nullptr) { memset(bindingBitsValue, 0, sizeof(bindingBitsValue)); init(); @@ -826,7 +826,7 @@ void QQmlData::signalEmitted(QAbstractDeclarativeData *, QObject *object, int in void **args = (void **) malloc((parameterTypes.count() + 1) *sizeof(void *)); types[0] = 0; // return type - args[0] = 0; // return value + args[0] = nullptr; // return value for (int ii = 0; ii < parameterTypes.count(); ++ii) { const QByteArray &typeName = parameterTypes.at(ii); @@ -847,7 +847,7 @@ void QQmlData::signalEmitted(QAbstractDeclarativeData *, QObject *object, int in args[ii + 1] = QMetaType::create(types[ii + 1], a[ii + 1]); } - QMetaCallEvent *ev = new QMetaCallEvent(m.methodIndex(), 0, 0, object, index, + QMetaCallEvent *ev = new QMetaCallEvent(m.methodIndex(), 0, nullptr, object, index, parameterTypes.count() + 1, types, args); QQmlThreadNotifierProxyObject *mpo = new QQmlThreadNotifierProxyObject; @@ -910,8 +910,8 @@ void QQmlData::setQueuedForDeletion(QObject *object) ddata->context->emitDestruction(); if (ddata->ownContext->contextObject == object) ddata->ownContext->contextObject = nullptr; - ddata->ownContext = 0; - ddata->context = 0; + ddata->ownContext = nullptr; + ddata->context = nullptr; } ddata->isQueuedForDeletion = true; } @@ -1062,7 +1062,7 @@ QQmlEngine::~QQmlEngine() currType.singletonInstanceInfo()->destroy(this); delete d->rootContext; - d->rootContext = 0; + d->rootContext = nullptr; } /*! \fn void QQmlEngine::quit() @@ -1175,7 +1175,7 @@ void QQmlEnginePrivate::registerFinalizeCallback(QObject *obj, int index) if (activeObjectCreator) { activeObjectCreator->finalizeCallbacks()->append(qMakePair(QPointer(obj), index)); } else { - void *args[] = { 0 }; + void *args[] = { nullptr }; QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod, index, args); } } @@ -1392,13 +1392,13 @@ void QQmlEngine::retranslate() QQmlContext *QQmlEngine::contextForObject(const QObject *object) { if(!object) - return 0; + return nullptr; QQmlData *data = QQmlData::get(object); if (data && data->outerContext) return data->outerContext->asQQmlContext(); - return 0; + return nullptr; } /*! @@ -1546,7 +1546,7 @@ QQmlEngine *qmlEngine(const QObject *obj) { QQmlData *data = QQmlData::get(obj, false); if (!data || !data->context) - return 0; + return nullptr; return data->context->engine; } @@ -1554,7 +1554,7 @@ QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool cre { QQmlData *data = QQmlData::get(object, create); if (!data) - return 0; // Attached properties are only on objects created by QML, unless explicitly requested (create==true) + return nullptr; // Attached properties are only on objects created by QML, unless explicitly requested (create==true) QObject *rv = data->hasExtendedData()?data->attachedProperties()->value(id):0; if (rv || !create) @@ -1563,7 +1563,7 @@ QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool cre QQmlEnginePrivate *engine = QQmlEnginePrivate::get(data->context); QQmlAttachedPropertiesFunc pf = QQmlMetaType::attachedPropertiesFuncById(engine, id); if (!pf) - return 0; + return nullptr; rv = pf(const_cast(object)); @@ -1577,12 +1577,12 @@ QObject *qmlAttachedPropertiesObject(int *idCache, const QObject *object, const QMetaObject *attachedMetaObject, bool create) { if (*idCache == -1) { - QQmlEngine *engine = object ? qmlEngine(object) : 0; - *idCache = QQmlMetaType::attachedPropertiesFuncId(engine ? QQmlEnginePrivate::get(engine) : 0, attachedMetaObject); + QQmlEngine *engine = object ? qmlEngine(object) : nullptr; + *idCache = QQmlMetaType::attachedPropertiesFuncId(engine ? QQmlEnginePrivate::get(engine) : nullptr, attachedMetaObject); } if (*idCache == -1 || !object) - return 0; + return nullptr; return qmlAttachedPropertiesObjectById(*idCache, object, create); } @@ -1642,7 +1642,7 @@ void QQmlData::NotifyList::layout(QQmlNotifierEndpoint *endpoint) { // Add a temporary sentinel at beginning of list. This will be overwritten // when the end point is inserted into the notifies further down. - endpoint->prev = 0; + endpoint->prev = nullptr; while (endpoint->next) { Q_ASSERT(reinterpret_cast(endpoint->next->prev) == endpoint); @@ -1688,7 +1688,7 @@ void QQmlData::NotifyList::layout() } maximumTodoIndex = 0; - todo = 0; + todo = nullptr; } void QQmlData::deferData(int objectIndex, QV4::CompiledData::CompilationUnit *compilationUnit, QQmlContextData *context) @@ -1732,8 +1732,8 @@ void QQmlData::addNotify(int index, QQmlNotifierEndpoint *endpoint) notifyList->connectionMask = 0; notifyList->maximumTodoIndex = 0; notifyList->notifiesSize = 0; - notifyList->todo = 0; - notifyList->notifies = 0; + notifyList->todo = nullptr; + notifyList->notifies = nullptr; } Q_ASSERT(!endpoint->isConnected()); @@ -1769,7 +1769,7 @@ void QQmlData::disconnectNotifiers() } free(notifyList->notifies); free(notifyList); - notifyList = 0; + notifyList = nullptr; } } @@ -1831,8 +1831,8 @@ void QQmlData::destroyed(QObject *object) } QQmlBoundSignal *next = signalHandler->m_nextSignal; - signalHandler->m_prevSignal = 0; - signalHandler->m_nextSignal = 0; + signalHandler->m_prevSignal = nullptr; + signalHandler->m_nextSignal = nullptr; delete signalHandler; signalHandler = next; } @@ -1843,11 +1843,11 @@ void QQmlData::destroyed(QObject *object) if (propertyCache) propertyCache->release(); - ownContext = 0; + ownContext = nullptr; while (guards) { QQmlGuard *guard = static_cast *>(guards); - *guard = (QObject *)0; + *guard = (QObject *)nullptr; guard->objectDestroyed(object); } @@ -1985,23 +1985,23 @@ static void dumpwarning(const QQmlError &error) switch (error.messageType()) { case QtDebugMsg: QMessageLogger(error.url().toString().toLatin1().constData(), - error.line(), 0).debug().nospace() + error.line(), nullptr).debug().nospace() << qPrintable(error.toString()); break; case QtInfoMsg: QMessageLogger(error.url().toString().toLatin1().constData(), - error.line(), 0).info().nospace() + error.line(), nullptr).info().nospace() << qPrintable(error.toString()); break; case QtWarningMsg: case QtFatalMsg: // fatal does not support streaming, and furthermore, is actually fatal. Probably not desirable for QML. QMessageLogger(error.url().toString().toLatin1().constData(), - error.line(), 0).warning().nospace() + error.line(), nullptr).warning().nospace() << qPrintable(error.toString()); break; case QtCriticalMsg: QMessageLogger(error.url().toString().toLatin1().constData(), - error.line(), 0).critical().nospace() + error.line(), nullptr).critical().nospace() << qPrintable(error.toString()); break; } @@ -2338,7 +2338,7 @@ QQmlPropertyCache *QQmlEnginePrivate::propertyCacheForType(int t) } else { QQmlType type = QQmlMetaType::qmlType(t); locker.unlock(); - return type.isValid() ? cache(type.metaObject()) : 0; + return type.isValid() ? cache(type.metaObject()) : nullptr; } } @@ -2353,9 +2353,9 @@ QQmlPropertyCache *QQmlEnginePrivate::rawPropertyCacheForType(int t, int minorVe locker.unlock(); if (minorVersion >= 0) - return type.isValid() ? cache(type, minorVersion) : 0; + return type.isValid() ? cache(type, minorVersion) : nullptr; else - return type.isValid() ? cache(type.baseMetaObject()) : 0; + return type.isValid() ? cache(type.baseMetaObject()) : nullptr; } } diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h index f12409ed9a..2dfbd42e57 100644 --- a/src/qml/qml/qqmlengine_p.h +++ b/src/qml/qml/qqmlengine_p.h @@ -213,7 +213,7 @@ public: // These methods may be called from the loader thread bool isQObject(int); - QObject *toQObject(const QVariant &, bool *ok = 0) const; + QObject *toQObject(const QVariant &, bool *ok = nullptr) const; QQmlMetaType::TypeCategory typeCategory(int) const; bool isList(int) const; int listType(int) const; @@ -265,7 +265,7 @@ private: static bool s_designerMode; // These members is protected by the full QQmlEnginePrivate::mutex mutex - struct Deletable { Deletable():next(0) {} virtual ~Deletable() {} Deletable *next; }; + struct Deletable { Deletable():next(nullptr) {} virtual ~Deletable() {} Deletable *next; }; QFieldList toDeleteInEngineThread; void doDeleteInEngineThread(); @@ -411,12 +411,12 @@ const QQmlEnginePrivate *QQmlEnginePrivate::get(const QQmlEngine *e) QQmlEnginePrivate *QQmlEnginePrivate::get(QQmlContext *c) { - return (c && c->engine()) ? QQmlEnginePrivate::get(c->engine()) : 0; + return (c && c->engine()) ? QQmlEnginePrivate::get(c->engine()) : nullptr; } QQmlEnginePrivate *QQmlEnginePrivate::get(QQmlContextData *c) { - return (c && c->engine) ? QQmlEnginePrivate::get(c->engine) : 0; + return (c && c->engine) ? QQmlEnginePrivate::get(c->engine) : nullptr; } QQmlEngine *QQmlEnginePrivate::get(QQmlEnginePrivate *p) @@ -430,7 +430,7 @@ QQmlEnginePrivate *QQmlEnginePrivate::get(QV4::ExecutionEngine *e) { QQmlEngine *qmlEngine = e->qmlEngine(); if (!qmlEngine) - return 0; + return nullptr; return get(qmlEngine); } diff --git a/src/qml/qml/qqmlerror.cpp b/src/qml/qml/qqmlerror.cpp index 1b264b025c..fc5b186b29 100644 --- a/src/qml/qml/qqmlerror.cpp +++ b/src/qml/qml/qqmlerror.cpp @@ -99,7 +99,7 @@ QQmlErrorPrivate::QQmlErrorPrivate() Creates an empty error object. */ QQmlError::QQmlError() -: d(0) +: d(nullptr) { } @@ -107,7 +107,7 @@ QQmlError::QQmlError() Creates a copy of \a other. */ QQmlError::QQmlError(const QQmlError &other) -: d(0) +: d(nullptr) { *this = other; } @@ -119,7 +119,7 @@ QQmlError &QQmlError::operator=(const QQmlError &other) { if (!other.d) { delete d; - d = 0; + d = nullptr; } else { if (!d) d = new QQmlErrorPrivate; @@ -138,7 +138,7 @@ QQmlError &QQmlError::operator=(const QQmlError &other) */ QQmlError::~QQmlError() { - delete d; d = 0; + delete d; d = nullptr; } /*! @@ -146,7 +146,7 @@ QQmlError::~QQmlError() */ bool QQmlError::isValid() const { - return d != 0; + return d != nullptr; } /*! @@ -239,7 +239,7 @@ QObject *QQmlError::object() const { if (d) return d->object; - return 0; + return nullptr; } /*! diff --git a/src/qml/qml/qqmlexpression.cpp b/src/qml/qml/qqmlexpression.cpp index 3ba0afc7bd..59cc9bb09f 100644 --- a/src/qml/qml/qqmlexpression.cpp +++ b/src/qml/qml/qqmlexpression.cpp @@ -121,7 +121,7 @@ void QQmlExpressionPrivate::init(QQmlContextData *ctxt, QV4::Function *runtimeFu null expression object and its value will always be an invalid QVariant. */ QQmlExpression::QQmlExpression() -: QObject(*new QQmlExpressionPrivate, 0) +: QObject(*new QQmlExpressionPrivate, nullptr) { } @@ -147,7 +147,7 @@ QQmlExpression::QQmlExpression(const QQmlScriptString &script, QQmlContext *ctxt QQmlContextData *evalCtxtData = QQmlContextData::get(ctxt ? ctxt : scriptPrivate->context); QObject *scopeObject = scope ? scope : scriptPrivate->scope; - QV4::Function *runtimeFunction = 0; + QV4::Function *runtimeFunction = nullptr; if (scriptPrivate->context) { QQmlContextData *ctxtdata = QQmlContextData::get(scriptPrivate->context); @@ -191,7 +191,7 @@ QQmlExpression::QQmlExpression(QQmlContext *ctxt, */ QQmlExpression::QQmlExpression(QQmlContextData *ctxt, QObject *scope, const QString &expression) -: QObject(*new QQmlExpressionPrivate, 0) +: QObject(*new QQmlExpressionPrivate, nullptr) { Q_D(QQmlExpression); d->init(ctxt, expression, scope); @@ -211,7 +211,7 @@ QQmlExpression::~QQmlExpression() QQmlEngine *QQmlExpression::engine() const { Q_D(const QQmlExpression); - return d->context()?d->context()->engine:0; + return d->context()?d->context()->engine:nullptr; } /*! @@ -222,7 +222,7 @@ QQmlContext *QQmlExpression::context() const { Q_D(const QQmlExpression); QQmlContextData *data = d->context(); - return data?data->asQQmlContext():0; + return data?data->asQQmlContext():nullptr; } /*! diff --git a/src/qml/qml/qqmlexpression_p.h b/src/qml/qml/qqmlexpression_p.h index a94ca0fc2d..55059575e1 100644 --- a/src/qml/qml/qqmlexpression_p.h +++ b/src/qml/qml/qqmlexpression_p.h @@ -73,9 +73,9 @@ public: void init(QQmlContextData *, const QString &, QObject *); void init(QQmlContextData *, QV4::Function *runtimeFunction, QObject *); - QVariant value(bool *isUndefined = 0); + QVariant value(bool *isUndefined = nullptr); - QV4::ReturnedValue v4value(bool *isUndefined = 0); + QV4::ReturnedValue v4value(bool *isUndefined = nullptr); static inline QQmlExpressionPrivate *get(QQmlExpression *expr); static inline QQmlExpression *get(QQmlExpressionPrivate *expr); diff --git a/src/qml/qml/qqmlfile.cpp b/src/qml/qml/qqmlfile.cpp index 93c3e8e00c..99031e1e74 100644 --- a/src/qml/qml/qqmlfile.cpp +++ b/src/qml/qml/qqmlfile.cpp @@ -131,7 +131,7 @@ int QQmlFileNetworkReply::replyFinishedIndex = -1; int QQmlFileNetworkReply::replyDownloadProgressIndex = -1; QQmlFileNetworkReply::QQmlFileNetworkReply(QQmlEngine *e, QQmlFilePrivate *p, const QUrl &url) -: m_engine(e), m_p(p), m_redirectCount(0), m_reply(0) +: m_engine(e), m_p(p), m_redirectCount(0), m_reply(nullptr) { if (finishedIndex == -1) { finishedIndex = QMetaMethod::fromSignal(&QQmlFileNetworkReply::finished).methodIndex(); @@ -194,9 +194,9 @@ void QQmlFileNetworkReply::networkFinished() } m_reply->deleteLater(); - m_reply = 0; + m_reply = nullptr; - m_p->reply = 0; + m_p->reply = nullptr; emit finished(); delete this; } @@ -210,7 +210,7 @@ void QQmlFileNetworkReply::networkDownloadProgress(qint64 a, qint64 b) QQmlFilePrivate::QQmlFilePrivate() : error(None) #if QT_CONFIG(qml_network) -, reply(0) +, reply(nullptr) #endif { } @@ -237,7 +237,7 @@ QQmlFile::~QQmlFile() delete d->reply; #endif delete d; - d = 0; + d = nullptr; } bool QQmlFile::isNull() const diff --git a/src/qml/qml/qqmlfileselector.cpp b/src/qml/qml/qqmlfileselector.cpp index be6216d3ff..8666144096 100644 --- a/src/qml/qml/qqmlfileselector.cpp +++ b/src/qml/qml/qqmlfileselector.cpp @@ -115,8 +115,8 @@ QQmlFileSelector::~QQmlFileSelector() { Q_D(QQmlFileSelector); if (d->engine && QQmlFileSelector::get(d->engine) == this) { - d->engine->setUrlInterceptor(0); - d->engine = 0; + d->engine->setUrlInterceptor(nullptr); + d->engine = nullptr; } interceptorInstances()->remove(d->myInstance.data()); } @@ -200,7 +200,7 @@ QQmlFileSelector* QQmlFileSelector::get(QQmlEngine* engine) QQmlAbstractUrlInterceptor* current = engine->urlInterceptor(); if (current && interceptorInstances()->contains(current)) return interceptorInstances()->value(current); - return 0; + return nullptr; } /*! diff --git a/src/qml/qml/qqmlglobal.cpp b/src/qml/qml/qqmlglobal.cpp index 6418812bae..1d60c518c4 100644 --- a/src/qml/qml/qqmlglobal.cpp +++ b/src/qml/qml/qqmlglobal.cpp @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE QQmlValueTypeProvider::QQmlValueTypeProvider() - : next(0) + : next(nullptr) { } @@ -65,7 +65,7 @@ const QMetaObject *QQmlValueTypeProvider::metaObjectForMetaType(int type) return mo; } while ((p = p->next)); - return 0; + return nullptr; } bool QQmlValueTypeProvider::initValueType(int type, QVariant& dst) @@ -218,7 +218,7 @@ bool QQmlValueTypeProvider::writeValueType(int type, const void *src, QVariant& return false; } -const QMetaObject *QQmlValueTypeProvider::getMetaObjectForMetaType(int) { return 0; } +const QMetaObject *QQmlValueTypeProvider::getMetaObjectForMetaType(int) { return nullptr; } bool QQmlValueTypeProvider::init(int, QVariant&) { return false; } bool QQmlValueTypeProvider::create(int, int, const void *[], QVariant *) { return false; } bool QQmlValueTypeProvider::createFromString(int, const QString &, void *, size_t) { return false; } @@ -232,11 +232,11 @@ bool QQmlValueTypeProvider::read(const QVariant&, void *, int) { return false; } bool QQmlValueTypeProvider::write(int, const void *, QVariant&) { return false; } Q_GLOBAL_STATIC(QQmlValueTypeProvider, nullValueTypeProvider) -static QQmlValueTypeProvider *valueTypeProvider = 0; +static QQmlValueTypeProvider *valueTypeProvider = nullptr; static QQmlValueTypeProvider **getValueTypeProvider(void) { - if (valueTypeProvider == 0) { + if (valueTypeProvider == nullptr) { valueTypeProvider = nullValueTypeProvider; } @@ -294,7 +294,7 @@ QVariant QQmlColorProvider::lighter(const QVariant &, qreal) { return QVariant() QVariant QQmlColorProvider::darker(const QVariant &, qreal) { return QVariant(); } QVariant QQmlColorProvider::tint(const QVariant &, const QVariant &) { return QVariant(); } -static QQmlColorProvider *colorProvider = 0; +static QQmlColorProvider *colorProvider = nullptr; Q_QML_PRIVATE_EXPORT QQmlColorProvider *QQml_setColorProvider(QQmlColorProvider *newProvider) { @@ -305,7 +305,7 @@ Q_QML_PRIVATE_EXPORT QQmlColorProvider *QQml_setColorProvider(QQmlColorProvider static QQmlColorProvider **getColorProvider(void) { - if (colorProvider == 0) { + if (colorProvider == nullptr) { qWarning() << "Warning: QQml_colorProvider: no color provider has been set!"; static QQmlColorProvider nullColorProvider; colorProvider = &nullColorProvider; @@ -345,7 +345,7 @@ QObject *QQmlGuiProvider::styleHints() QString QQmlGuiProvider::pluginName() const { return QString(); } -static QQmlGuiProvider *guiProvider = 0; +static QQmlGuiProvider *guiProvider = nullptr; Q_QML_PRIVATE_EXPORT QQmlGuiProvider *QQml_setGuiProvider(QQmlGuiProvider *newProvider) { @@ -356,7 +356,7 @@ Q_QML_PRIVATE_EXPORT QQmlGuiProvider *QQml_setGuiProvider(QQmlGuiProvider *newPr static QQmlGuiProvider **getGuiProvider(void) { - if (guiProvider == 0) { + if (guiProvider == nullptr) { static QQmlGuiProvider nullGuiProvider; //Still provides an application with no GUI support guiProvider = &nullGuiProvider; } diff --git a/src/qml/qml/qqmlglobal_p.h b/src/qml/qml/qqmlglobal_p.h index 5c46da0ea4..53f5dbed02 100644 --- a/src/qml/qml/qqmlglobal_p.h +++ b/src/qml/qml/qqmlglobal_p.h @@ -323,7 +323,7 @@ class Q_QML_PRIVATE_EXPORT QQmlApplication : public QObject Q_PROPERTY(QString organization READ organization WRITE setOrganization NOTIFY organizationChanged) Q_PROPERTY(QString domain READ domain WRITE setDomain NOTIFY domainChanged) public: - QQmlApplication(QObject* parent=0); + QQmlApplication(QObject* parent=nullptr); QStringList args(); @@ -347,7 +347,7 @@ Q_SIGNALS: void domainChanged(); protected: - QQmlApplication(QQmlApplicationPrivate &dd, QObject* parent=0); + QQmlApplication(QQmlApplicationPrivate &dd, QObject* parent=nullptr); private: Q_DISABLE_COPY(QQmlApplication) diff --git a/src/qml/qml/qqmlguard_p.h b/src/qml/qml/qqmlguard_p.h index 52526276be..87c3677d29 100644 --- a/src/qml/qml/qqmlguard_p.h +++ b/src/qml/qml/qqmlguard_p.h @@ -113,18 +113,18 @@ Q_DECLARE_METATYPE(QQmlGuard) QT_BEGIN_NAMESPACE QQmlGuardImpl::QQmlGuardImpl() -: o(0), next(0), prev(0) +: o(nullptr), next(nullptr), prev(nullptr) { } QQmlGuardImpl::QQmlGuardImpl(QObject *g) -: o(g), next(0), prev(0) +: o(g), next(nullptr), prev(nullptr) { if (o) addGuard(); } QQmlGuardImpl::QQmlGuardImpl(const QQmlGuardImpl &g) -: o(g.o), next(0), prev(0) +: o(g.o), next(nullptr), prev(nullptr) { if (o) addGuard(); } @@ -132,7 +132,7 @@ QQmlGuardImpl::QQmlGuardImpl(const QQmlGuardImpl &g) QQmlGuardImpl::~QQmlGuardImpl() { if (prev) remGuard(); - o = 0; + o = nullptr; } void QQmlGuardImpl::addGuard() @@ -155,8 +155,8 @@ void QQmlGuardImpl::remGuard() if (next) next->prev = prev; *prev = next; - next = 0; - prev = 0; + next = nullptr; + prev = nullptr; } template diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index a9113603b8..8e6cbcbd7e 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -728,7 +728,7 @@ bool QQmlImports::resolveType(QQmlImportNamespace *ns, const QHashedStringRef &t QQmlType *type_return, int *vmaj, int *vmin, QQmlType::RegistrationType registrationType) const { - return ns->resolveType(d->typeLoader, type, vmaj, vmin, type_return, 0, 0, registrationType); + return ns->resolveType(d->typeLoader, type, vmaj, vmin, type_return, nullptr, nullptr, registrationType); } bool QQmlImportInstance::resolveType(QQmlTypeLoader *typeLoader, const QHashedStringRef& type, @@ -803,7 +803,7 @@ bool QQmlImportInstance::resolveType(QQmlTypeLoader *typeLoader, const QHashedSt int major = vmajor ? *vmajor : -1; int minor = vminor ? *vminor : -1; QQmlType returnType = fetchOrCreateTypeForUrl(componentUrl, type, isCompositeSingleton, - 0, major, minor); + nullptr, major, minor); if (type_return) *type_return = returnType; return returnType.isValid(); @@ -831,7 +831,7 @@ bool QQmlImportInstance::resolveType(QQmlTypeLoader *typeLoader, const QHashedSt *typeRecursionDetected = true; } else { QQmlType returnType = fetchOrCreateTypeForUrl( - qmlUrl, type, registrationType == QQmlType::CompositeSingletonType, 0); + qmlUrl, type, registrationType == QQmlType::CompositeSingletonType, nullptr); if (type_return) *type_return = returnType; return returnType.isValid(); @@ -847,7 +847,7 @@ bool QQmlImportsPrivate::resolveType(const QHashedStringRef& type, int *vmajor, QQmlType::RegistrationType registrationType, QQmlImport::RecursionRestriction recursionRestriction) { - QQmlImportNamespace *s = 0; + QQmlImportNamespace *s = nullptr; int dot = type.indexOf(Dot); if (dot >= 0) { QHashedStringRef namespaceName(type.constData(), dot); @@ -978,7 +978,7 @@ QQmlImportNamespace *QQmlImportsPrivate::findQualifiedNamespace(const QHashedStr if (prefix == ns->prefix) return ns; } - return 0; + return nullptr; } /* @@ -1257,7 +1257,7 @@ bool QQmlImportsPrivate::locateQmldir(const QString &uri, int vmaj, int vmin, QQ // Check cache first - QQmlImportDatabase::QmldirCache *cacheHead = 0; + QQmlImportDatabase::QmldirCache *cacheHead = nullptr; { QQmlImportDatabase::QmldirCache **cachePtr = database->qmldirCache.value(uri); if (cachePtr) { @@ -1389,7 +1389,7 @@ bool QQmlImportsPrivate::validateQmldirVersion(const QQmlTypeLoaderQmldirContent QQmlImportNamespace *QQmlImportsPrivate::importNamespace(const QString &prefix) const { - QQmlImportNamespace *nameSpace = 0; + QQmlImportNamespace *nameSpace = nullptr; if (prefix.isEmpty()) { nameSpace = &unqualifiedset; @@ -1446,7 +1446,7 @@ bool QQmlImportsPrivate::addLibraryImport(const QString& uri, const QString &pre Q_ASSERT(inserted); if (!incomplete) { - const QQmlTypeLoaderQmldirContent *qmldir = 0; + const QQmlTypeLoaderQmldirContent *qmldir = nullptr; if (!qmldirIdentifier.isEmpty()) { if (!getQmldirContent(qmldirIdentifier, uri, &qmldir, errors)) @@ -1565,7 +1565,7 @@ bool QQmlImportsPrivate::addFileImport(const QString& uri, const QString &prefix Q_ASSERT(inserted); if (!incomplete && !qmldirIdentifier.isEmpty()) { - const QQmlTypeLoaderQmldirContent *qmldir = 0; + const QQmlTypeLoaderQmldirContent *qmldir = nullptr; if (!getQmldirContent(qmldirIdentifier, importUri, &qmldir, errors)) return false; @@ -1589,7 +1589,7 @@ bool QQmlImportsPrivate::updateQmldirContent(const QString &uri, const QString & Q_ASSERT(nameSpace); if (QQmlImportInstance *import = nameSpace->findImport(uri)) { - const QQmlTypeLoaderQmldirContent *qmldir = 0; + const QQmlTypeLoaderQmldirContent *qmldir = nullptr; if (!getQmldirContent(qmldirIdentifier, uri, &qmldir, errors)) return false; @@ -2095,7 +2095,7 @@ bool QQmlImportDatabase::importStaticPlugin(QObject *instance, const QString &ba } else { RegisteredPlugin plugin; plugin.uri = uri; - plugin.loader = 0; + plugin.loader = nullptr; plugins->insert(uniquePluginID, plugin); if (!registerPluginTypes(instance, basePath, uri, typeNamespace, vmaj, errors)) @@ -2156,7 +2156,7 @@ bool QQmlImportDatabase::importDynamicPlugin(const QString &filePath, const QStr return false; } - QPluginLoader* loader = 0; + QPluginLoader* loader = nullptr; if (!typesRegistered) { loader = new QPluginLoader(absoluteFilePath); diff --git a/src/qml/qml/qqmlimport_p.h b/src/qml/qml/qqmlimport_p.h index 6298dd9c22..b70bb5253c 100644 --- a/src/qml/qml/qqmlimport_p.h +++ b/src/qml/qml/qqmlimport_p.h @@ -92,7 +92,7 @@ struct QQmlImportInstance bool resolveType(QQmlTypeLoader *typeLoader, const QHashedStringRef &type, int *vmajor, int *vminor, QQmlType* type_return, - QString *base = 0, bool *typeRecursionDetected = 0, + QString *base = nullptr, bool *typeRecursionDetected = nullptr, QQmlType::RegistrationType = QQmlType::AnyRegistrationType, QQmlImport::RecursionRestriction recursionRestriction = QQmlImport::PreventRecursion) const; }; @@ -100,7 +100,7 @@ struct QQmlImportInstance class QQmlImportNamespace { public: - QQmlImportNamespace() : nextNamespace(0) {} + QQmlImportNamespace() : nextNamespace(nullptr) {} ~QQmlImportNamespace() { qDeleteAll(imports); } QList imports; @@ -109,7 +109,7 @@ public: bool resolveType(QQmlTypeLoader *typeLoader, const QHashedStringRef& type, int *vmajor, int *vminor, QQmlType* type_return, - QString *base = 0, QList *errors = 0, + QString *base = nullptr, QList *errors = nullptr, QQmlType::RegistrationType registrationType = QQmlType::AnyRegistrationType, QQmlImport::RecursionRestriction recursionRestriction = QQmlImport::PreventRecursion); @@ -137,7 +137,7 @@ public: QQmlType *type_return, int *version_major, int *version_minor, QQmlImportNamespace **ns_return, - QList *errors = 0, + QList *errors = nullptr, QQmlType::RegistrationType registrationType = QQmlType::AnyRegistrationType, QQmlImport::RecursionRestriction recursionRestriction = QQmlImport::PreventRecursion) const; diff --git a/src/qml/qml/qqmlincubator.cpp b/src/qml/qml/qqmlincubator.cpp index 9855c27375..4546a4423f 100644 --- a/src/qml/qml/qqmlincubator.cpp +++ b/src/qml/qml/qqmlincubator.cpp @@ -110,7 +110,7 @@ void QQmlEngine::setIncubationController(QQmlIncubationController *controller) { Q_D(QQmlEngine); if (d->incubationController) - d->incubationController->d = 0; + d->incubationController->d = nullptr; d->incubationController = controller; if (controller) controller->d = d; } @@ -128,7 +128,7 @@ QQmlIncubationController *QQmlEngine::incubationController() const QQmlIncubatorPrivate::QQmlIncubatorPrivate(QQmlIncubator *q, QQmlIncubator::IncubationMode m) : q(q), status(QQmlIncubator::Null), mode(m), isAsynchronous(false), progress(Execute), - result(0), enginePriv(0), waitingOnMe(0) + result(nullptr), enginePriv(nullptr), waitingOnMe(nullptr) { } @@ -147,16 +147,16 @@ void QQmlIncubatorPrivate::clear() if (controller) controller->incubatingObjectCountChanged(enginePriv->incubatorCount); } - enginePriv = 0; + enginePriv = nullptr; if (!rootContext.isNull()) { - rootContext->incubator = 0; - rootContext = 0; + rootContext->incubator = nullptr; + rootContext = nullptr; } if (nextWaitingFor.isInList()) { Q_ASSERT(waitingOnMe); nextWaitingFor.remove(); - waitingOnMe = 0; + waitingOnMe = nullptr; } // if we're waiting on any incubators then they should be cleared too. @@ -171,7 +171,7 @@ void QQmlIncubatorPrivate::clear() vmeGuard.clear(); if (creator && guardOk) creator->clear(); - creator.reset(0); + creator.reset(nullptr); } /*! @@ -218,15 +218,15 @@ than a static amount like 5 milliseconds - while not disturbing the application. Create a new incubation controller. */ QQmlIncubationController::QQmlIncubationController() -: d(0) +: d(nullptr) { } /*! \internal */ QQmlIncubationController::~QQmlIncubationController() { - if (d) QQmlEnginePrivate::get(d)->setIncubationController(0); - d = 0; + if (d) QQmlEnginePrivate::get(d)->setIncubationController(nullptr); + d = nullptr; } /*! @@ -294,8 +294,8 @@ void QQmlIncubatorPrivate::incubate(QQmlInstantiationInterrupt &i) if (progress == QQmlIncubatorPrivate::Execute) { enginePriv->referenceScarceResources(); - QObject *tresult = 0; - tresult = creator->create(subComponentToCreate, /*parent*/0, &i); + QObject *tresult = nullptr; + tresult = creator->create(subComponentToCreate, /*parent*/nullptr, &i); if (!tresult) errors = creator->errors; enginePriv->dereferenceScarceResources(); @@ -304,7 +304,7 @@ void QQmlIncubatorPrivate::incubate(QQmlInstantiationInterrupt &i) return; result = tresult; - if (errors.isEmpty() && result == 0) + if (errors.isEmpty() && result == nullptr) goto finishIncubate; if (result) { @@ -340,7 +340,7 @@ void QQmlIncubatorPrivate::incubate(QQmlInstantiationInterrupt &i) if (watcher.hasRecursed()) return; - QQmlContextData *ctxt = 0; + QQmlContextData *ctxt = nullptr; ctxt = creator->finalize(i); if (ctxt) { rootContext = ctxt; @@ -506,12 +506,12 @@ QQmlIncubator::QQmlIncubator(IncubationMode mode) /*! \internal */ QQmlIncubator::~QQmlIncubator() { - d->q = 0; + d->q = nullptr; if (!d->ref.deref()) { delete d; } - d = 0; + d = nullptr; } /*! @@ -557,18 +557,18 @@ void QQmlIncubator::clear() if (s == Loading) { Q_ASSERT(d->compilationUnit); if (d->result) d->result->deleteLater(); - d->result = 0; + d->result = nullptr; } d->clear(); Q_ASSERT(d->compilationUnit.isNull()); - Q_ASSERT(d->waitingOnMe.data() == 0); + Q_ASSERT(d->waitingOnMe.data() == nullptr); Q_ASSERT(d->waitingFor.isEmpty()); d->errors.clear(); d->progress = QQmlIncubatorPrivate::Execute; - d->result = 0; + d->result = nullptr; if (s == Loading) { Q_ASSERT(enginePriv); @@ -657,7 +657,7 @@ Return the incubated object if the status is Ready, otherwise 0. QObject *QQmlIncubator::object() const { if (status() != Ready) - return 0; + return nullptr; else return d->result; } diff --git a/src/qml/qml/qqmlinfo.cpp b/src/qml/qml/qqmlinfo.cpp index dae15e2eca..c8f5ba506f 100644 --- a/src/qml/qml/qqmlinfo.cpp +++ b/src/qml/qml/qqmlinfo.cpp @@ -182,7 +182,7 @@ QQmlInfo::~QQmlInfo() if (0 == --d->ref) { QList errors = d->errors; - QQmlEngine *engine = 0; + QQmlEngine *engine = nullptr; if (!d->buffer.isEmpty()) { QQmlError error; diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index cd35ab93c6..74148e3ca4 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -93,12 +93,12 @@ void QQmlDelayedError::catchJavaScriptException(QV4::ExecutionEngine *engine) QQmlJavaScriptExpression::QQmlJavaScriptExpression() - : m_error(0), - m_context(0), - m_prevExpression(0), - m_nextExpression(0), - m_v4Function(0), - m_sourceLocation(0) + : m_error(nullptr), + m_context(nullptr), + m_prevExpression(nullptr), + m_nextExpression(nullptr), + m_v4Function(nullptr), + m_sourceLocation(nullptr) { } @@ -114,7 +114,7 @@ QQmlJavaScriptExpression::~QQmlJavaScriptExpression() clearPermanentGuards(); clearError(); if (m_scopeObject.isT2()) // notify DeleteWatcher of our deletion. - m_scopeObject.asT2()->_s = 0; + m_scopeObject.asT2()->_s = nullptr; delete m_sourceLocation; } @@ -157,8 +157,8 @@ void QQmlJavaScriptExpression::setContext(QQmlContextData *context) *m_prevExpression = m_nextExpression; if (m_nextExpression) m_nextExpression->m_prevExpression = m_prevExpression; - m_prevExpression = 0; - m_nextExpression = 0; + m_prevExpression = nullptr; + m_nextExpression = nullptr; } m_context = context; @@ -211,7 +211,7 @@ QV4::ReturnedValue QQmlJavaScriptExpression::evaluate(QV4::CallData *callData, b QQmlPropertyCapture capture(m_context->engine, this, &watcher); QQmlPropertyCapture *lastPropertyCapture = ep->propertyCapture; - ep->propertyCapture = notifyOnValueChanged() ? &capture : 0; + ep->propertyCapture = notifyOnValueChanged() ? &capture : nullptr; if (notifyOnValueChanged()) @@ -253,7 +253,7 @@ QV4::ReturnedValue QQmlJavaScriptExpression::evaluate(QV4::CallData *callData, b for (int ii = 0; ii < capture.errorString->count(); ++ii) qWarning("%s", qPrintable(capture.errorString->at(ii))); delete capture.errorString; - capture.errorString = 0; + capture.errorString = nullptr; } while (QQmlJavaScriptExpressionGuard *g = capture.guards.takeFirst()) @@ -274,7 +274,7 @@ void QQmlPropertyCapture::captureProperty(QQmlNotifier *n, Duration duration) while (!guards.isEmpty() && !guards.first()->isConnected(n)) guards.takeFirst()->Delete(); - QQmlJavaScriptExpressionGuard *g = 0; + QQmlJavaScriptExpressionGuard *g = nullptr; if (!guards.isEmpty()) { g = guards.takeFirst(); g->cancelNotify(); @@ -323,7 +323,7 @@ void QQmlPropertyCapture::captureProperty(QObject *o, int c, int n, Duration dur while (!guards.isEmpty() && !guards.first()->isConnected(o, n)) guards.takeFirst()->Delete(); - QQmlJavaScriptExpressionGuard *g = 0; + QQmlJavaScriptExpressionGuard *g = nullptr; if (!guards.isEmpty()) { g = guards.takeFirst(); g->cancelNotify(); diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h index 1cb6d7bfd1..a028850074 100644 --- a/src/qml/qml/qqmljavascriptexpression_p.h +++ b/src/qml/qml/qqmljavascriptexpression_p.h @@ -62,7 +62,7 @@ struct QQmlSourceLocation; class QQmlDelayedError { public: - inline QQmlDelayedError() : nextError(0), prevError(0) {} + inline QQmlDelayedError() : nextError(nullptr), prevError(nullptr) {} inline ~QQmlDelayedError() { removeError(); } bool addError(QQmlEnginePrivate *); @@ -71,8 +71,8 @@ public: if (!prevError) return; if (nextError) nextError->prevError = prevError; *prevError = nextError; - nextError = 0; - prevError = 0; + nextError = nullptr; + prevError = nullptr; } inline bool isValid() const { return m_error.isValid(); } @@ -117,7 +117,7 @@ public: QQmlSourceLocation sourceLocation() const; void setSourceLocation(const QQmlSourceLocation &location); - bool isValid() const { return context() != 0; } + bool isValid() const { return context() != nullptr; } QQmlContextData *context() const { return m_context; } void setContext(QQmlContextData *context); @@ -193,11 +193,11 @@ class QQmlPropertyCapture { public: QQmlPropertyCapture(QQmlEngine *engine, QQmlJavaScriptExpression *e, QQmlJavaScriptExpression::DeleteWatcher *w) - : engine(engine), expression(e), watcher(w), errorString(0) { } + : engine(engine), expression(e), watcher(w), errorString(nullptr) { } ~QQmlPropertyCapture() { Q_ASSERT(guards.isEmpty()); - Q_ASSERT(errorString == 0); + Q_ASSERT(errorString == nullptr); } enum Duration { @@ -217,7 +217,7 @@ public: }; QQmlJavaScriptExpression::DeleteWatcher::DeleteWatcher(QQmlJavaScriptExpression *e) -: _c(0), _w(0), _s(e) +: _c(nullptr), _w(nullptr), _s(e) { if (e->m_scopeObject.isT1()) { _w = &_s; @@ -231,14 +231,14 @@ QQmlJavaScriptExpression::DeleteWatcher::DeleteWatcher(QQmlJavaScriptExpression QQmlJavaScriptExpression::DeleteWatcher::~DeleteWatcher() { - Q_ASSERT(*_w == 0 || (*_w == _s && _s->m_scopeObject.isT2())); + Q_ASSERT(*_w == nullptr || (*_w == _s && _s->m_scopeObject.isT2())); if (*_w && _s->m_scopeObject.asT2() == this) _s->m_scopeObject = _c; } bool QQmlJavaScriptExpression::DeleteWatcher::wasDeleted() const { - return *_w == 0; + return *_w == nullptr; } bool QQmlJavaScriptExpression::notifyOnValueChanged() const @@ -272,12 +272,12 @@ inline void QQmlJavaScriptExpression::clearError() { if (m_error) delete m_error; - m_error = 0; + m_error = nullptr; } QQmlJavaScriptExpressionGuard::QQmlJavaScriptExpressionGuard(QQmlJavaScriptExpression *e) : QQmlNotifierEndpoint(QQmlNotifierEndpoint::QQmlJavaScriptExpressionGuard), - expression(e), next(0) + expression(e), next(nullptr) { } diff --git a/src/qml/qml/qqmllist.cpp b/src/qml/qml/qqmllist.cpp index 9bfdd3da35..ac6e3695fe 100644 --- a/src/qml/qml/qqmllist.cpp +++ b/src/qml/qml/qqmllist.cpp @@ -55,7 +55,7 @@ QQmlListReference QQmlListReferencePrivate::init(const QQmlListProperty if (!prop.object) return rv; - QQmlEnginePrivate *p = engine?QQmlEnginePrivate::get(engine):0; + QQmlEnginePrivate *p = engine?QQmlEnginePrivate::get(engine):nullptr; int listType = p?p->listType(propType):QQmlMetaType::listType(propType); if (listType == -1) return rv; @@ -117,7 +117,7 @@ The \l {Qt Quick 1} version of this class is named QDeclarativeListReference. Constructs an invalid instance. */ QQmlListReference::QQmlListReference() -: d(0) +: d(nullptr) { } @@ -131,17 +131,17 @@ Passing \a engine is required to access some QML created list properties. If in is available, pass it. */ QQmlListReference::QQmlListReference(QObject *object, const char *property, QQmlEngine *engine) -: d(0) +: d(nullptr) { if (!object || !property) return; QQmlPropertyData local; QQmlPropertyData *data = - QQmlPropertyCache::property(engine, object, QLatin1String(property), 0, local); + QQmlPropertyCache::property(engine, object, QLatin1String(property), nullptr, local); if (!data || !data->isQList()) return; - QQmlEnginePrivate *p = engine?QQmlEnginePrivate::get(engine):0; + QQmlEnginePrivate *p = engine?QQmlEnginePrivate::get(engine):nullptr; int listType = p?p->listType(data->propType()):QQmlMetaType::listType(data->propType()); if (listType == -1) return; @@ -151,7 +151,7 @@ QQmlListReference::QQmlListReference(QObject *object, const char *property, QQml d->elementType = p ? p->rawMetaObjectForType(listType) : QQmlMetaType::qmlType(listType).baseMetaObject(); d->propertyType = data->propType(); - void *args[] = { &d->property, 0 }; + void *args[] = { &d->property, nullptr }; QMetaObject::metacall(object, QMetaObject::ReadProperty, data->coreIndex(), args); } @@ -191,7 +191,7 @@ Returns the list property's object. Returns 0 if the reference is invalid. QObject *QQmlListReference::object() const { if (isValid()) return d->object; - else return 0; + else return nullptr; } /*! @@ -204,7 +204,7 @@ to a list. const QMetaObject *QQmlListReference::listElementType() const { if (isValid()) return d->elementType.metaObject(); - else return 0; + else return nullptr; } /*! @@ -301,7 +301,7 @@ Returns the list element at \a index, or 0 if the operation failed. */ QObject *QQmlListReference::at(int index) const { - if (!canAt()) return 0; + if (!canAt()) return nullptr; return d->property.at(&d->property, index); } diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp index cdeb991e11..3fbe3df2ab 100644 --- a/src/qml/qml/qqmllistwrapper.cpp +++ b/src/qml/qml/qqmllistwrapper.cpp @@ -77,7 +77,7 @@ ReturnedValue QmlListWrapper::create(ExecutionEngine *engine, QObject *object, i Scoped r(scope, engine->memoryManager->allocObject()); r->d()->object = object; r->d()->propertyType = propType; - void *args[] = { &r->d()->property(), 0 }; + void *args[] = { &r->d()->property(), nullptr }; QMetaObject::metacall(object, QMetaObject::ReadProperty, propId, args); return r.asReturnedValue(); } @@ -151,7 +151,7 @@ bool QmlListWrapper::put(Managed *m, String *name, const Value &value) void QmlListWrapper::advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attrs) { - name->setM(0); + name->setM(nullptr); *index = UINT_MAX; Q_ASSERT(m->as()); QmlListWrapper *w = static_cast(m); diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp index eafe2792c1..2a5c58b47b 100644 --- a/src/qml/qml/qqmllocale.cpp +++ b/src/qml/qml/qqmllocale.cpp @@ -684,23 +684,23 @@ QV4LocaleDataDeletable::QV4LocaleDataDeletable(QV4::ExecutionEngine *engine) o->defineDefaultProperty(QStringLiteral("monthName"), QQmlLocaleData::method_monthName, 0); o->defineDefaultProperty(QStringLiteral("currencySymbol"), QQmlLocaleData::method_currencySymbol, 0); o->defineDefaultProperty(QStringLiteral("dateTimeFormat"), QQmlLocaleData::method_dateTimeFormat, 0); - o->defineAccessorProperty(QStringLiteral("name"), QQmlLocaleData::method_get_name, 0); - o->defineAccessorProperty(QStringLiteral("positiveSign"), QQmlLocaleData::method_get_positiveSign, 0); - o->defineAccessorProperty(QStringLiteral("uiLanguages"), QQmlLocaleData::method_get_uiLanguages, 0); - o->defineAccessorProperty(QStringLiteral("firstDayOfWeek"), QQmlLocaleData::method_get_firstDayOfWeek, 0); - o->defineAccessorProperty(QStringLiteral("pmText"), QQmlLocaleData::method_get_pmText, 0); - o->defineAccessorProperty(QStringLiteral("percent"), QQmlLocaleData::method_get_percent, 0); - o->defineAccessorProperty(QStringLiteral("textDirection"), QQmlLocaleData::method_get_textDirection, 0); - o->defineAccessorProperty(QStringLiteral("weekDays"), QQmlLocaleData::method_get_weekDays, 0); - o->defineAccessorProperty(QStringLiteral("negativeSign"), QQmlLocaleData::method_get_negativeSign, 0); - o->defineAccessorProperty(QStringLiteral("groupSeparator"), QQmlLocaleData::method_get_groupSeparator, 0); - o->defineAccessorProperty(QStringLiteral("decimalPoint"), QQmlLocaleData::method_get_decimalPoint, 0); - o->defineAccessorProperty(QStringLiteral("nativeLanguageName"), QQmlLocaleData::method_get_nativeLanguageName, 0); - o->defineAccessorProperty(QStringLiteral("nativeCountryName"), QQmlLocaleData::method_get_nativeCountryName, 0); - o->defineAccessorProperty(QStringLiteral("zeroDigit"), QQmlLocaleData::method_get_zeroDigit, 0); - o->defineAccessorProperty(QStringLiteral("amText"), QQmlLocaleData::method_get_amText, 0); - o->defineAccessorProperty(QStringLiteral("measurementSystem"), QQmlLocaleData::method_get_measurementSystem, 0); - o->defineAccessorProperty(QStringLiteral("exponential"), QQmlLocaleData::method_get_exponential, 0); + o->defineAccessorProperty(QStringLiteral("name"), QQmlLocaleData::method_get_name, nullptr); + o->defineAccessorProperty(QStringLiteral("positiveSign"), QQmlLocaleData::method_get_positiveSign, nullptr); + o->defineAccessorProperty(QStringLiteral("uiLanguages"), QQmlLocaleData::method_get_uiLanguages, nullptr); + o->defineAccessorProperty(QStringLiteral("firstDayOfWeek"), QQmlLocaleData::method_get_firstDayOfWeek, nullptr); + o->defineAccessorProperty(QStringLiteral("pmText"), QQmlLocaleData::method_get_pmText, nullptr); + o->defineAccessorProperty(QStringLiteral("percent"), QQmlLocaleData::method_get_percent, nullptr); + o->defineAccessorProperty(QStringLiteral("textDirection"), QQmlLocaleData::method_get_textDirection, nullptr); + o->defineAccessorProperty(QStringLiteral("weekDays"), QQmlLocaleData::method_get_weekDays, nullptr); + o->defineAccessorProperty(QStringLiteral("negativeSign"), QQmlLocaleData::method_get_negativeSign, nullptr); + o->defineAccessorProperty(QStringLiteral("groupSeparator"), QQmlLocaleData::method_get_groupSeparator, nullptr); + o->defineAccessorProperty(QStringLiteral("decimalPoint"), QQmlLocaleData::method_get_decimalPoint, nullptr); + o->defineAccessorProperty(QStringLiteral("nativeLanguageName"), QQmlLocaleData::method_get_nativeLanguageName, nullptr); + o->defineAccessorProperty(QStringLiteral("nativeCountryName"), QQmlLocaleData::method_get_nativeCountryName, nullptr); + o->defineAccessorProperty(QStringLiteral("zeroDigit"), QQmlLocaleData::method_get_zeroDigit, nullptr); + o->defineAccessorProperty(QStringLiteral("amText"), QQmlLocaleData::method_get_amText, nullptr); + o->defineAccessorProperty(QStringLiteral("measurementSystem"), QQmlLocaleData::method_get_measurementSystem, nullptr); + o->defineAccessorProperty(QStringLiteral("exponential"), QQmlLocaleData::method_get_exponential, nullptr); prototype.set(engine, o); } diff --git a/src/qml/qml/qqmllocale_p.h b/src/qml/qml/qqmllocale_p.h index 57666c64f1..8341b1f555 100644 --- a/src/qml/qml/qqmllocale_p.h +++ b/src/qml/qml/qqmllocale_p.h @@ -163,7 +163,7 @@ struct QQmlLocaleData : public QV4::Object const QQmlLocaleData *data = o ? o->as() : nullptr; if (!data) { scope.engine->throwTypeError(); - return 0; + return nullptr; } return data->d()->locale; } diff --git a/src/qml/qml/qqmlloggingcategory_p.h b/src/qml/qml/qqmlloggingcategory_p.h index 2b7f2f5b53..544db1fe33 100644 --- a/src/qml/qml/qqmlloggingcategory_p.h +++ b/src/qml/qml/qqmlloggingcategory_p.h @@ -67,7 +67,7 @@ class QQmlLoggingCategory : public QObject, public QQmlParserStatus Q_PROPERTY(QString name READ name WRITE setName) public: - QQmlLoggingCategory(QObject *parent = 0); + QQmlLoggingCategory(QObject *parent = nullptr); virtual ~QQmlLoggingCategory(); QString name() const; diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index 76d40bf442..7754f0fddc 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -170,7 +170,7 @@ public: ~QQmlTypePrivate(); void init() const; - void initEnums(const QQmlPropertyCache *cache = 0) const; + void initEnums(const QQmlPropertyCache *cache = nullptr) const; void insertEnums(const QMetaObject *metaObject) const; void insertEnumsFromPropertyCache(const QQmlPropertyCache *cache) const; @@ -315,31 +315,31 @@ QJSValue QQmlType::SingletonInstanceInfo::scriptApi(QQmlEngine *e) const QHash QQmlTypePrivate::attachedPropertyIds; QQmlTypePrivate::QQmlTypePrivate(QQmlType::RegistrationType type) -: refCount(1), regType(type), iid(0), typeId(0), listId(0), revision(0), - containsRevisionedAttributes(false), baseMetaObject(0), +: refCount(1), regType(type), iid(nullptr), typeId(0), listId(0), revision(0), + containsRevisionedAttributes(false), baseMetaObject(nullptr), index(-1), isSetup(false), isEnumSetup(false), haveSuperType(false) { switch (type) { case QQmlType::CppType: extraData.cd = new QQmlCppTypeData; extraData.cd->allocationSize = 0; - extraData.cd->newFunc = 0; + extraData.cd->newFunc = nullptr; extraData.cd->parserStatusCast = -1; - extraData.cd->extFunc = 0; - extraData.cd->extMetaObject = 0; - extraData.cd->customParser = 0; - extraData.cd->attachedPropertiesFunc = 0; - extraData.cd->attachedPropertiesType = 0; + extraData.cd->extFunc = nullptr; + extraData.cd->extMetaObject = nullptr; + extraData.cd->customParser = nullptr; + extraData.cd->attachedPropertiesFunc = nullptr; + extraData.cd->attachedPropertiesType = nullptr; extraData.cd->propertyValueSourceCast = -1; extraData.cd->propertyValueInterceptorCast = -1; break; case QQmlType::SingletonType: case QQmlType::CompositeSingletonType: extraData.sd = new QQmlSingletonTypeData; - extraData.sd->singletonInstanceInfo = 0; + extraData.sd->singletonInstanceInfo = nullptr; break; case QQmlType::InterfaceType: - extraData.cd = 0; + extraData.cd = nullptr; break; case QQmlType::CompositeType: extraData.fd = new QQmlCompositeTypeData; @@ -406,7 +406,7 @@ QQmlType::QQmlType(QQmlMetaTypeData *data, const QString &elementName, const QQm d->extraData.sd->singletonInstanceInfo->qobjectCallback = type.qobjectApi; d->extraData.sd->singletonInstanceInfo->typeName = QString::fromUtf8(type.typeName); d->extraData.sd->singletonInstanceInfo->instanceMetaObject - = (type.qobjectApi && type.version >= 1) ? type.instanceMetaObject : 0; + = (type.qobjectApi && type.version >= 1) ? type.instanceMetaObject : nullptr; } QQmlType::QQmlType(QQmlMetaTypeData *data, const QString &elementName, const QQmlPrivate::RegisterCompositeSingletonType &type) @@ -478,7 +478,7 @@ QQmlType::QQmlType(QQmlMetaTypeData *data, const QString &elementName, const QQm } QQmlType::QQmlType() - : d(0) + : d(nullptr) { } @@ -586,10 +586,10 @@ QQmlPropertyCache *QQmlType::compositePropertyCache(QQmlEnginePrivate *engine) c // similar logic to resolveCompositeBaseType Q_ASSERT(isComposite()); if (!engine) - return 0; + return nullptr; QQmlRefPointer td(engine->typeLoader.getType(sourceUrl()), QQmlRefPointer::Adopt); if (td.isNull() || !td->isComplete()) - return 0; + return nullptr; QV4::CompiledData::CompilationUnit *compilationUnit = td->compilationUnit(); return compilationUnit->rootPropertyCache(); } @@ -739,7 +739,7 @@ void QQmlTypePrivate::init() const // Check for revisioned details { - const QMetaObject *mo = 0; + const QMetaObject *mo = nullptr; if (metaObjects.isEmpty()) mo = baseMetaObject; else @@ -792,7 +792,7 @@ void QQmlTypePrivate::insertEnums(const QMetaObject *metaObject) const for (int ii = 0; ii < metaObject->enumeratorCount(); ++ii) { QMetaEnum e = metaObject->enumerator(ii); const bool isScoped = e.isScoped(); - QStringHash *scoped = isScoped ? new QStringHash() : 0; + QStringHash *scoped = isScoped ? new QStringHash() : nullptr; for (int jj = 0; jj < e.keyCount(); ++jj) { const QString key = QString::fromUtf8(e.key(jj)); @@ -888,7 +888,7 @@ QString QQmlType::qmlTypeName() const QObject *QQmlType::create() const { if (!d || !isCreatable()) - return 0; + return nullptr; d->init(); @@ -921,25 +921,25 @@ void QQmlType::create(QObject **out, void **memory, size_t additionalMemory) con QQmlType::SingletonInstanceInfo *QQmlType::singletonInstanceInfo() const { if (!d) - return 0; + return nullptr; if (d->regType != SingletonType && d->regType != CompositeSingletonType) - return 0; + return nullptr; return d->extraData.sd->singletonInstanceInfo; } QQmlCustomParser *QQmlType::customParser() const { if (!d) - return 0; + return nullptr; if (d->regType != CppType) - return 0; + return nullptr; return d->extraData.cd->customParser; } QQmlType::CreateFunc QQmlType::createFunction() const { if (!d || d->regType != CppType) - return 0; + return nullptr; return d->extraData.cd->newFunc; } @@ -1004,7 +1004,7 @@ int QQmlType::qListTypeId() const const QMetaObject *QQmlType::metaObject() const { if (!d) - return 0; + return nullptr; d->init(); if (d->metaObjects.isEmpty()) @@ -1016,7 +1016,7 @@ const QMetaObject *QQmlType::metaObject() const const QMetaObject *QQmlType::baseMetaObject() const { - return d ? d->baseMetaObject : 0; + return d ? d->baseMetaObject : nullptr; } bool QQmlType::containsRevisionedAttributes() const @@ -1036,7 +1036,7 @@ int QQmlType::metaObjectRevision() const QQmlAttachedPropertiesFunc QQmlType::attachedPropertiesFunction(QQmlEnginePrivate *engine) const { if (!d) - return 0; + return nullptr; if (d->regType == CppType) return d->extraData.cd->attachedPropertiesFunc; @@ -1049,7 +1049,7 @@ QQmlAttachedPropertiesFunc QQmlType::attachedPropertiesFunction(QQmlEnginePrivat const QMetaObject *QQmlType::attachedPropertiesType(QQmlEnginePrivate *engine) const { if (!d) - return 0; + return nullptr; if (d->regType == CppType) return d->extraData.cd->attachedPropertiesType; @@ -1101,7 +1101,7 @@ int QQmlType::propertyValueInterceptorCast() const const char *QQmlType::interfaceIId() const { if (!d || d->regType != InterfaceType) - return 0; + return nullptr; return d->iid; } @@ -1125,7 +1125,7 @@ int QQmlType::enumValue(QQmlEnginePrivate *engine, const QHashedStringRef &name, { Q_ASSERT(ok); if (d) { - const QQmlPropertyCache *cache = isComposite() ? compositePropertyCache(engine) : 0; + const QQmlPropertyCache *cache = isComposite() ? compositePropertyCache(engine) : nullptr; *ok = true; @@ -1144,7 +1144,7 @@ int QQmlType::enumValue(QQmlEnginePrivate *engine, const QHashedCStringRef &name { Q_ASSERT(ok); if (d) { - const QQmlPropertyCache *cache = isComposite() ? compositePropertyCache(engine) : 0; + const QQmlPropertyCache *cache = isComposite() ? compositePropertyCache(engine) : nullptr; *ok = true; @@ -1163,7 +1163,7 @@ int QQmlType::enumValue(QQmlEnginePrivate *engine, const QV4::String *name, bool { Q_ASSERT(ok); if (d) { - const QQmlPropertyCache *cache = isComposite() ? compositePropertyCache(engine) : 0; + const QQmlPropertyCache *cache = isComposite() ? compositePropertyCache(engine) : nullptr; *ok = true; d->initEnums(cache); @@ -1181,7 +1181,7 @@ int QQmlType::scopedEnumIndex(QQmlEnginePrivate *engine, const QV4::String *name { Q_ASSERT(ok); if (d) { - const QQmlPropertyCache *cache = isComposite() ? compositePropertyCache(engine) : 0; + const QQmlPropertyCache *cache = isComposite() ? compositePropertyCache(engine) : nullptr; *ok = true; d->initEnums(cache); @@ -1199,7 +1199,7 @@ int QQmlType::scopedEnumIndex(QQmlEnginePrivate *engine, const QString &name, bo { Q_ASSERT(ok); if (d) { - const QQmlPropertyCache *cache = isComposite() ? compositePropertyCache(engine) : 0; + const QQmlPropertyCache *cache = isComposite() ? compositePropertyCache(engine) : nullptr; *ok = true; d->initEnums(cache); @@ -1251,7 +1251,7 @@ int QQmlType::scopedEnumValue(QQmlEnginePrivate *engine, const QByteArray &scope { Q_ASSERT(ok); if (d) { - const QQmlPropertyCache *cache = isComposite() ? compositePropertyCache(engine) : 0; + const QQmlPropertyCache *cache = isComposite() ? compositePropertyCache(engine) : nullptr; *ok = true; d->initEnums(cache); @@ -1274,7 +1274,7 @@ int QQmlType::scopedEnumValue(QQmlEnginePrivate *engine, const QStringRef &scope { Q_ASSERT(ok); if (d) { - const QQmlPropertyCache *cache = isComposite() ? compositePropertyCache(engine) : 0; + const QQmlPropertyCache *cache = isComposite() ? compositePropertyCache(engine) : nullptr; *ok = true; d->initEnums(cache); @@ -1340,7 +1340,7 @@ QQmlTypeModule::QQmlTypeModule() QQmlTypeModule::~QQmlTypeModule() { - delete d; d = 0; + delete d; d = nullptr; } QString QQmlTypeModule::module() const @@ -1439,7 +1439,7 @@ void QQmlTypeModule::walkCompositeSingletons(const std::function::Construct, sizeof(QObject*), static_cast >(QtPrivate::QMetaTypeTypeFlags::Flags), - 0); + nullptr); int lst_type = QMetaType::registerNormalizedType(lst, QtMetaTypePrivate::QMetaTypeFunctionHelper >::Destruct, QtMetaTypePrivate::QMetaTypeFunctionHelper >::Construct, sizeof(QQmlListProperty), static_cast >(QtPrivate::QMetaTypeTypeFlags >::Flags), - static_cast(0)); + static_cast(nullptr)); compilationUnit->metaTypeId = ptr_type; compilationUnit->listMetaTypeId = lst_type; @@ -1964,7 +1964,7 @@ QObject *QQmlMetaType::toQObject(const QVariant &v, bool *ok) { if (!isQObject(v.userType())) { if (ok) *ok = false; - return 0; + return nullptr; } if (ok) *ok = true; @@ -2014,7 +2014,7 @@ int QQmlMetaType::attachedPropertiesFuncId(QQmlEnginePrivate *engine, const QMet QQmlAttachedPropertiesFunc QQmlMetaType::attachedPropertiesFuncById(QQmlEnginePrivate *engine, int id) { if (id < 0) - return 0; + return nullptr; QMutexLocker lock(metaTypeDataLock()); QQmlMetaTypeData *data = metaTypeData(); return data->types.at(id).attachedPropertiesFunction(engine); @@ -2107,7 +2107,7 @@ const char *QQmlMetaType::interfaceIId(int userType) if (type.isInterface() && type.typeId() == userType) return type.interfaceIId(); else - return 0; + return nullptr; } bool QQmlMetaType::isList(int userType) diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h index cee1070a09..07bef526ba 100644 --- a/src/qml/qml/qqmlmetatype_p.h +++ b/src/qml/qml/qqmlmetatype_p.h @@ -109,7 +109,7 @@ public: static QMetaMethod defaultMethod(QObject *); static bool isQObject(int); - static QObject *toQObject(const QVariant &, bool *ok = 0); + static QObject *toQObject(const QVariant &, bool *ok = nullptr); static int listType(int); static int attachedPropertiesFuncId(QQmlEnginePrivate *engine, const QMetaObject *); @@ -163,7 +163,7 @@ public: return d == other.d; } - bool isValid() const { return d != 0; } + bool isValid() const { return d != nullptr; } const QQmlTypePrivate *key() const { return d; } QByteArray typeName() const; @@ -218,7 +218,7 @@ public: { public: SingletonInstanceInfo() - : scriptCallback(0), qobjectCallback(0), instanceMetaObject(0) {} + : scriptCallback(nullptr), qobjectCallback(nullptr), instanceMetaObject(nullptr) {} QJSValue (*scriptCallback)(QQmlEngine *, QJSEngine *); QObject *(*qobjectCallback)(QQmlEngine *, QJSEngine *); diff --git a/src/qml/qml/qqmlnotifier.cpp b/src/qml/qml/qqmlnotifier.cpp index e068ad174a..ac247ae0ad 100644 --- a/src/qml/qml/qqmlnotifier.cpp +++ b/src/qml/qml/qqmlnotifier.cpp @@ -51,7 +51,7 @@ void QQmlJavaScriptExpressionGuard_callback(QQmlNotifierEndpoint *, void **); void QQmlVMEMetaObjectEndpoint_callback(QQmlNotifierEndpoint *, void **); static Callback QQmlNotifier_callbacks[] = { - 0, + nullptr, QQmlBoundSignal_callback, QQmlJavaScriptExpressionGuard_callback, QQmlVMEMetaObjectEndpoint_callback @@ -59,9 +59,9 @@ static Callback QQmlNotifier_callbacks[] = { namespace { struct NotifyListTraversalData { - NotifyListTraversalData(QQmlNotifierEndpoint *ep = 0) + NotifyListTraversalData(QQmlNotifierEndpoint *ep = nullptr) : originalSenderPtr(0) - , disconnectWatch(0) + , disconnectWatch(nullptr) , endpoint(ep) {} diff --git a/src/qml/qml/qqmlnotifier_p.h b/src/qml/qml/qqmlnotifier_p.h index a99b13f155..39761875bf 100644 --- a/src/qml/qml/qqmlnotifier_p.h +++ b/src/qml/qml/qqmlnotifier_p.h @@ -129,7 +129,7 @@ private: }; QQmlNotifier::QQmlNotifier() -: endpoints(0) +: endpoints(nullptr) { } @@ -142,22 +142,22 @@ QQmlNotifier::~QQmlNotifier() if (n->isNotifying()) *((qintptr *)(n->senderPtr & ~0x1)) = 0; - n->next = 0; - n->prev = 0; + n->next = nullptr; + n->prev = nullptr; n->senderPtr = 0; n->sourceSignal = -1; } - endpoints = 0; + endpoints = nullptr; } void QQmlNotifier::notify() { - void *args[] = { 0 }; + void *args[] = { nullptr }; if (endpoints) emitNotify(endpoints, args); } QQmlNotifierEndpoint::QQmlNotifierEndpoint(Callback callback) -: next(0), prev(0), senderPtr(0), callback(callback), needsConnectNotify(false), sourceSignal(-1) +: next(nullptr), prev(nullptr), senderPtr(0), callback(callback), needsConnectNotify(false), sourceSignal(-1) { } @@ -168,7 +168,7 @@ QQmlNotifierEndpoint::~QQmlNotifierEndpoint() bool QQmlNotifierEndpoint::isConnected() const { - return prev != 0; + return prev != nullptr; } /*! \internal @@ -212,8 +212,8 @@ void QQmlNotifierEndpoint::disconnect() } if (isNotifying()) *((qintptr *)(senderPtr & ~0x1)) = 0; - next = 0; - prev = 0; + next = nullptr; + prev = nullptr; senderPtr = 0; sourceSignal = -1; } diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index caf063c79f..36e56a01f8 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -82,13 +82,13 @@ QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, QV4::Compil { init(parentContext); - sharedState->componentAttached = 0; + sharedState->componentAttached = nullptr; sharedState->allCreatedBindings.allocate(compilationUnit->totalBindingsCount); sharedState->allParserStatusCallbacks.allocate(compilationUnit->totalParserStatusCount); sharedState->allCreatedObjects.allocate(compilationUnit->totalObjectCount); - sharedState->allJavaScriptObjects = 0; + sharedState->allJavaScriptObjects = nullptr; sharedState->creationContext = creationContext; - sharedState->rootContext = 0; + sharedState->rootContext = nullptr; if (auto profiler = QQmlEnginePrivate::get(engine)->profiler) { Q_QML_PROFILE_IF_ENABLED(QQmlProfilerDefinitions::ProfileCreating, profiler, @@ -105,7 +105,7 @@ QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, QV4::Compil , propertyCaches(&compilationUnit->propertyCaches) , sharedState(inheritedSharedState) , topLevelCreator(false) - , incubator(0) + , incubator(nullptr) { init(parentContext); } @@ -120,17 +120,17 @@ void QQmlObjectCreator::init(QQmlContextData *providedParentContext) compilationUnit->linkToEngine(v4); qmlUnit = compilationUnit->data; - context = 0; - _qobject = 0; - _scopeObject = 0; - _bindingTarget = 0; - _valueTypeProperty = 0; - _compiledObject = 0; + context = nullptr; + _qobject = nullptr; + _scopeObject = nullptr; + _bindingTarget = nullptr; + _valueTypeProperty = nullptr; + _compiledObject = nullptr; _compiledObjectIndex = -1; - _ddata = 0; - _propertyCache = 0; - _vmeMetaObject = 0; - _qmlContext = 0; + _ddata = nullptr; + _propertyCache = nullptr; + _vmeMetaObject = nullptr; + _qmlContext = nullptr; } QQmlObjectCreator::~QQmlObjectCreator() @@ -142,7 +142,7 @@ QQmlObjectCreator::~QQmlObjectCreator() for (int i = 0; i < sharedState->allParserStatusCallbacks.count(); ++i) { QQmlParserStatus *ps = sharedState->allParserStatusCallbacks.at(i); if (ps) - ps->d = 0; + ps->d = nullptr; } while (sharedState->componentAttached) { QQmlComponentAttached *a = sharedState->componentAttached; @@ -207,12 +207,12 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlI } if (topLevelCreator) - sharedState->allJavaScriptObjects = 0; + sharedState->allJavaScriptObjects = nullptr; phase = CreatingObjectsPhase2; if (interrupt && interrupt->shouldInterrupt()) - return 0; + return nullptr; phase = ObjectsCreated; @@ -796,7 +796,7 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con } const int id = attachedType.attachedPropertiesId(QQmlEnginePrivate::get(engine)); QObject *qmlObject = qmlAttachedPropertiesObjectById(id, _qobject); - if (!populateInstance(binding->value.objectIndex, qmlObject, qmlObject, /*value type property*/0)) + if (!populateInstance(binding->value.objectIndex, qmlObject, qmlObject, /*value type property*/nullptr)) return false; return true; } @@ -814,12 +814,12 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con QQmlPropertyData::WriteFlags propertyWriteFlags = QQmlPropertyData::BypassInterceptor | QQmlPropertyData::RemoveBindingOnAliasWrite; int propertyWriteStatus = -1; - void *argv[] = { &ss, 0, &propertyWriteStatus, &propertyWriteFlags }; + void *argv[] = { &ss, nullptr, &propertyWriteStatus, &propertyWriteFlags }; QMetaObject::metacall(_qobject, QMetaObject::WriteProperty, property->coreIndex(), argv); return true; } - QObject *createdSubObject = 0; + QObject *createdSubObject = nullptr; if (binding->type == QV4::CompiledData::Binding::Type_Object) { createdSubObject = createInstance(binding->value.objectIndex, _bindingTarget); if (!createdSubObject) @@ -833,9 +833,9 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con const QV4::CompiledData::Object *obj = qmlUnit->objectAt(binding->value.objectIndex); if (stringAt(obj->inheritedTypeNameIndex).isEmpty()) { - QObject *groupObject = 0; - QQmlValueType *valueType = 0; - const QQmlPropertyData *valueTypeProperty = 0; + QObject *groupObject = nullptr; + QQmlValueType *valueType = nullptr; + const QQmlPropertyData *valueTypeProperty = nullptr; QObject *bindingTarget = _bindingTarget; if (QQmlValueTypeFactory::isValueType(property->propType())) { @@ -1008,7 +1008,7 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con QQmlPropertyData::WriteFlags propertyWriteFlags = QQmlPropertyData::BypassInterceptor | QQmlPropertyData::RemoveBindingOnAliasWrite; int propertyWriteStatus = -1; - void *argv[] = { 0, 0, &propertyWriteStatus, &propertyWriteFlags }; + void *argv[] = { nullptr, nullptr, &propertyWriteStatus, &propertyWriteFlags }; if (const char *iid = QQmlMetaType::interfaceIId(property->propType())) { void *ptr = createdSubObject->qt_metacast(iid); @@ -1034,7 +1034,7 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con void *itemToAdd = createdSubObject; - const char *iid = 0; + const char *iid = nullptr; int listItemType = QQmlEnginePrivate::get(engine)->listType(property->propType()); if (listItemType != -1) iid = QQmlMetaType::interfaceIId(listItemType); @@ -1114,10 +1114,10 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo ActiveOCRestorer ocRestorer(this, QQmlEnginePrivate::get(engine)); bool isComponent = false; - QObject *instance = 0; - QQmlData *ddata = 0; - QQmlCustomParser *customParser = 0; - QQmlParserStatus *parserStatus = 0; + QObject *instance = nullptr; + QQmlData *ddata = nullptr; + QQmlCustomParser *customParser = nullptr; + QQmlParserStatus *parserStatus = nullptr; bool installPropertyCache = true; if (obj->flags & QV4::CompiledData::Object::IsComponent) { @@ -1137,11 +1137,11 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo Q_QML_OC_PROFILE(sharedState->profiler, profiler.update( compilationUnit, obj, type.qmlTypeName(), context->url())); - void *ddataMemory = 0; + void *ddataMemory = nullptr; type.create(&instance, &ddataMemory, sizeof(QQmlData)); if (!instance) { recordError(obj->location, tr("Unable to create object of type %1").arg(stringAt(obj->inheritedTypeNameIndex))); - return 0; + return nullptr; } { @@ -1173,14 +1173,14 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo if (typeRef->compilationUnit->data->isSingleton()) { recordError(obj->location, tr("Composite Singleton Type %1 is not creatable").arg(stringAt(obj->inheritedTypeNameIndex))); - return 0; + return nullptr; } QQmlObjectCreator subCreator(context, typeRef->compilationUnit, sharedState.data()); instance = subCreator.create(); if (!instance) { errors += subCreator.errors; - return 0; + return nullptr; } } if (instance->isWidgetType()) { @@ -1244,8 +1244,8 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo } customParser->applyBindings(instance, compilationUnit, bindings); - customParser->engine = 0; - customParser->imports = (QQmlTypeNameCache*)0; + customParser->engine = nullptr; + customParser->imports = (QQmlTypeNameCache*)nullptr; } if (isComponent) { @@ -1274,12 +1274,12 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo qSwap(_qmlContext, qmlContext); - bool result = populateInstance(index, instance, /*binding target*/instance, /*value type property*/0); + bool result = populateInstance(index, instance, /*binding target*/instance, /*value type property*/nullptr); qSwap(_qmlContext, qmlContext); qSwap(_scopeObject, scopeObject); - return result ? instance : 0; + return result ? instance : nullptr; } QQmlContextData *QQmlObjectCreator::finalize(QQmlInstantiationInterrupt &interrupt) @@ -1303,7 +1303,7 @@ QQmlContextData *QQmlObjectCreator::finalize(QQmlInstantiationInterrupt &interru QQmlPropertyData::DontRemoveBinding); if (watcher.hasRecursed() || interrupt.shouldInterrupt()) - return 0; + return nullptr; } if (QQmlVME::componentCompleteEnabled()) { // the qml designer does the component complete later @@ -1312,12 +1312,12 @@ QQmlContextData *QQmlObjectCreator::finalize(QQmlInstantiationInterrupt &interru QQmlParserStatus *status = sharedState->allParserStatusCallbacks.pop(); if (status && status->d) { - status->d = 0; + status->d = nullptr; status->componentComplete(); } if (watcher.hasRecursed() || interrupt.shouldInterrupt()) - return 0; + return nullptr; } } @@ -1325,11 +1325,11 @@ QQmlContextData *QQmlObjectCreator::finalize(QQmlInstantiationInterrupt &interru QQmlEnginePrivate::FinalizeCallback callback = sharedState->finalizeCallbacks.at(ii); QObject *obj = callback.first; if (obj) { - void *args[] = { 0 }; + void *args[] = { nullptr }; QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod, callback.second, args); } if (watcher.hasRecursed()) - return 0; + return nullptr; } sharedState->finalizeCallbacks.clear(); @@ -1344,7 +1344,7 @@ QQmlContextData *QQmlObjectCreator::finalize(QQmlInstantiationInterrupt &interru emit a->completed(); if (watcher.hasRecursed() || interrupt.shouldInterrupt()) - return 0; + return nullptr; } phase = Done; @@ -1386,7 +1386,7 @@ bool QQmlObjectCreator::populateInstance(int index, QObject *instance, QObject * QQmlRefPointer cache = propertyCaches->at(_compiledObjectIndex); - QQmlVMEMetaObject *vmeMetaObject = 0; + QQmlVMEMetaObject *vmeMetaObject = nullptr; if (propertyCaches->needsVMEMetaObject(_compiledObjectIndex)) { Q_ASSERT(!cache.isNull()); // install on _object diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h index bef58b8c9a..399a5f6d4a 100644 --- a/src/qml/qml/qqmlobjectcreator_p.h +++ b/src/qml/qml/qqmlobjectcreator_p.h @@ -85,10 +85,10 @@ class Q_QML_PRIVATE_EXPORT QQmlObjectCreator { Q_DECLARE_TR_FUNCTIONS(QQmlObjectCreator) public: - QQmlObjectCreator(QQmlContextData *parentContext, QV4::CompiledData::CompilationUnit *compilationUnit, QQmlContextData *creationContext, QQmlIncubatorPrivate *incubator = 0); + QQmlObjectCreator(QQmlContextData *parentContext, QV4::CompiledData::CompilationUnit *compilationUnit, QQmlContextData *creationContext, QQmlIncubatorPrivate *incubator = nullptr); ~QQmlObjectCreator(); - QObject *create(int subComponentIndex = -1, QObject *parent = 0, QQmlInstantiationInterrupt *interrupt = 0); + QObject *create(int subComponentIndex = -1, QObject *parent = nullptr, QQmlInstantiationInterrupt *interrupt = nullptr); bool populateDeferredProperties(QObject *instance, QQmlData::DeferredData *deferredData); bool populateDeferredBinding(const QQmlProperty &qmlProperty, QQmlData::DeferredData *deferredData, const QV4::CompiledData::Binding *binding); QQmlContextData *finalize(QQmlInstantiationInterrupt &interrupt); @@ -108,7 +108,7 @@ private: void init(QQmlContextData *parentContext); - QObject *createInstance(int index, QObject *parent = 0, bool isContextObject = false); + QObject *createInstance(int index, QObject *parent = nullptr, bool isContextObject = false); bool populateInstance(int index, QObject *instance, QObject *bindingTarget, const QQmlPropertyData *valueTypeProperty); diff --git a/src/qml/qml/qqmlopenmetaobject.cpp b/src/qml/qml/qqmlopenmetaobject.cpp index fc85030b3d..1b44bbdda3 100644 --- a/src/qml/qml/qqmlopenmetaobject.cpp +++ b/src/qml/qml/qqmlopenmetaobject.cpp @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE class QQmlOpenMetaObjectTypePrivate { public: - QQmlOpenMetaObjectTypePrivate() : mem(0), cache(0), engine(0) {} + QQmlOpenMetaObjectTypePrivate() : mem(nullptr), cache(nullptr), engine(nullptr) {} void init(const QMetaObject *metaObj); @@ -83,7 +83,7 @@ QQmlOpenMetaObjectType::~QQmlOpenMetaObjectType() void QQmlOpenMetaObjectType::clear() { - d->engine = 0; + d->engine = nullptr; } int QQmlOpenMetaObjectType::propertyOffset() const @@ -182,7 +182,7 @@ class QQmlOpenMetaObjectPrivate { public: QQmlOpenMetaObjectPrivate(QQmlOpenMetaObject *_q) - : q(_q), parent(0), type(0), cacheProperties(false) {} + : q(_q), parent(nullptr), type(nullptr), cacheProperties(false) {} inline QPair &getDataRef(int idx) { while (data.count() <= idx) @@ -220,7 +220,7 @@ QQmlOpenMetaObject::QQmlOpenMetaObject(QObject *obj, const QMetaObject *base, bo d->autoCreate = automatic; d->object = obj; - d->type = new QQmlOpenMetaObjectType(base ? base : obj->metaObject(), 0); + d->type = new QQmlOpenMetaObjectType(base ? base : obj->metaObject(), nullptr); d->type->d->referers.insert(this); QObjectPrivate *op = QObjectPrivate::get(obj); @@ -264,7 +264,7 @@ void QQmlOpenMetaObject::emitPropertyNotification(const QByteArray &propertyName QHash::ConstIterator iter = d->type->d->names.constFind(propertyName); if (iter == d->type->d->names.constEnd()) return; - activate(d->object, *iter + d->type->d->signalOffset, 0); + activate(d->object, *iter + d->type->d->signalOffset, nullptr); } int QQmlOpenMetaObject::metaCall(QObject *o, QMetaObject::Call c, int id, void **a) @@ -284,7 +284,7 @@ int QQmlOpenMetaObject::metaCall(QObject *o, QMetaObject::Call c, int id, void * prop.first = propertyWriteValue(propId, *reinterpret_cast(a[0])); prop.second = true; propertyWritten(propId); - activate(o, d->type->d->signalOffset + propId, 0); + activate(o, d->type->d->signalOffset + propId, nullptr); } } return -1; @@ -311,7 +311,7 @@ void QQmlOpenMetaObject::setValue(int id, const QVariant &value) QPair &prop = d->getDataRef(id); prop.first = propertyWriteValue(id, value); prop.second = true; - activate(d->object, id + d->type->d->signalOffset, 0); + activate(d->object, id + d->type->d->signalOffset, nullptr); } QVariant QQmlOpenMetaObject::value(const QByteArray &name) const @@ -353,7 +353,7 @@ bool QQmlOpenMetaObject::setValue(const QByteArray &name, const QVariant &val) return false; dataVal = val; - activate(d->object, id + d->type->d->signalOffset, 0); + activate(d->object, id + d->type->d->signalOffset, nullptr); return true; } @@ -382,7 +382,7 @@ void QQmlOpenMetaObject::setCached(bool c) } else { if (d->type->d->cache) d->type->d->cache->release(); - qmldata->propertyCache = 0; + qmldata->propertyCache = nullptr; } } @@ -395,7 +395,7 @@ int QQmlOpenMetaObject::createProperty(const char *name, const char *) if (QQmlData *ddata = QQmlData::get(d->object, /*create*/false)) { if (ddata->propertyCache) { ddata->propertyCache->release(); - ddata->propertyCache = 0; + ddata->propertyCache = nullptr; } } diff --git a/src/qml/qml/qqmlopenmetaobject_p.h b/src/qml/qml/qqmlopenmetaobject_p.h index 4bb92489a5..bb5477dfbf 100644 --- a/src/qml/qml/qqmlopenmetaobject_p.h +++ b/src/qml/qml/qqmlopenmetaobject_p.h @@ -95,7 +95,7 @@ class QQmlOpenMetaObjectPrivate; class Q_QML_PRIVATE_EXPORT QQmlOpenMetaObject : public QAbstractDynamicMetaObject { public: - QQmlOpenMetaObject(QObject *, const QMetaObject * = 0, bool = true); + QQmlOpenMetaObject(QObject *, const QMetaObject * = nullptr, bool = true); QQmlOpenMetaObject(QObject *, QQmlOpenMetaObjectType *, bool = true); ~QQmlOpenMetaObject(); diff --git a/src/qml/qml/qqmlparserstatus.cpp b/src/qml/qml/qqmlparserstatus.cpp index ad07cac7ef..1082c318cb 100644 --- a/src/qml/qml/qqmlparserstatus.cpp +++ b/src/qml/qml/qqmlparserstatus.cpp @@ -87,7 +87,7 @@ QT_BEGIN_NAMESPACE /*! \internal */ QQmlParserStatus::QQmlParserStatus() -: d(0) +: d(nullptr) { } @@ -95,7 +95,7 @@ QQmlParserStatus::QQmlParserStatus() QQmlParserStatus::~QQmlParserStatus() { if(d) - (*d) = 0; + (*d) = nullptr; } /*! diff --git a/src/qml/qml/qqmlplatform_p.h b/src/qml/qml/qqmlplatform_p.h index 6246ca7105..af33dffca3 100644 --- a/src/qml/qml/qqmlplatform_p.h +++ b/src/qml/qml/qqmlplatform_p.h @@ -64,7 +64,7 @@ class Q_QML_PRIVATE_EXPORT QQmlPlatform : public QObject Q_PROPERTY(QString pluginName READ pluginName CONSTANT) public: - explicit QQmlPlatform(QObject *parent = 0); + explicit QQmlPlatform(QObject *parent = nullptr); virtual ~QQmlPlatform(); static QString os(); diff --git a/src/qml/qml/qqmlprivate.h b/src/qml/qml/qqmlprivate.h index b9e9d5e59e..11adea6fc9 100644 --- a/src/qml/qml/qqmlprivate.h +++ b/src/qml/qml/qqmlprivate.h @@ -167,8 +167,8 @@ namespace QQmlPrivate class AttachedPropertySelector { public: - static inline QQmlAttachedPropertiesFunc func() { return 0; } - static inline const QMetaObject *metaObject() { return 0; } + static inline QQmlAttachedPropertiesFunc func() { return nullptr; } + static inline const QMetaObject *metaObject() { return nullptr; } }; template class AttachedPropertySelector diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index 50d9f13049..8ecd597a39 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -119,7 +119,7 @@ The \l {Qt Quick 1} version of this class was named QDeclarativeProperty. Create an invalid QQmlProperty. */ QQmlProperty::QQmlProperty() -: d(0) +: d(nullptr) { } @@ -128,7 +128,7 @@ QQmlProperty::~QQmlProperty() { if (d) d->release(); - d = 0; + d = nullptr; } /*! @@ -150,8 +150,8 @@ QQmlProperty::QQmlProperty(QObject *obj) QQmlProperty::QQmlProperty(QObject *obj, QQmlContext *ctxt) : d(new QQmlPropertyPrivate) { - d->context = ctxt?QQmlContextData::get(ctxt):0; - d->engine = ctxt?ctxt->engine():0; + d->context = ctxt?QQmlContextData::get(ctxt):nullptr; + d->engine = ctxt?ctxt->engine():nullptr; d->initDefault(obj); } @@ -164,7 +164,7 @@ QQmlProperty::QQmlProperty(QObject *obj, QQmlContext *ctxt) QQmlProperty::QQmlProperty(QObject *obj, QQmlEngine *engine) : d(new QQmlPropertyPrivate) { - d->context = 0; + d->context = nullptr; d->engine = engine; d->initDefault(obj); } @@ -190,7 +190,7 @@ QQmlProperty::QQmlProperty(QObject *obj, const QString &name) : d(new QQmlPropertyPrivate) { d->initProperty(obj, name); - if (!isValid()) d->object = 0; + if (!isValid()) d->object = nullptr; } /*! @@ -203,10 +203,10 @@ QQmlProperty::QQmlProperty(QObject *obj, const QString &name) QQmlProperty::QQmlProperty(QObject *obj, const QString &name, QQmlContext *ctxt) : d(new QQmlPropertyPrivate) { - d->context = ctxt?QQmlContextData::get(ctxt):0; - d->engine = ctxt?ctxt->engine():0; + d->context = ctxt?QQmlContextData::get(ctxt):nullptr; + d->engine = ctxt?ctxt->engine():nullptr; d->initProperty(obj, name); - if (!isValid()) { d->object = 0; d->context = 0; d->engine = 0; } + if (!isValid()) { d->object = nullptr; d->context = nullptr; d->engine = nullptr; } } /*! @@ -217,10 +217,10 @@ QQmlProperty::QQmlProperty(QObject *obj, const QString &name, QQmlContext *ctxt) QQmlProperty::QQmlProperty(QObject *obj, const QString &name, QQmlEngine *engine) : d(new QQmlPropertyPrivate) { - d->context = 0; + d->context = nullptr; d->engine = engine; d->initProperty(obj, name); - if (!isValid()) { d->object = 0; d->context = 0; d->engine = 0; } + if (!isValid()) { d->object = nullptr; d->context = nullptr; d->engine = nullptr; } } QQmlProperty QQmlPropertyPrivate::create(QObject *target, const QString &propertyName, QQmlContextData *context) @@ -240,7 +240,7 @@ QQmlProperty QQmlPropertyPrivate::create(QObject *target, const QString &propert } QQmlPropertyPrivate::QQmlPropertyPrivate() -: context(0), engine(0), object(0), isNameCached(false) +: context(nullptr), engine(nullptr), object(nullptr), isNameCached(false) { } @@ -248,14 +248,14 @@ QQmlContextData *QQmlPropertyPrivate::effectiveContext() const { if (context) return context; else if (engine) return QQmlContextData::get(engine->rootContext()); - else return 0; + else return nullptr; } void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name) { if (!obj) return; - QQmlTypeNameCache *typeNameCache = context?context->imports:0; + QQmlTypeNameCache *typeNameCache = context?context->imports:nullptr; QObject *currentObject = obj; QVector path; @@ -487,7 +487,7 @@ QQmlPropertyPrivate::propertyTypeCategory() const const char *QQmlProperty::propertyTypeName() const { if (!d) - return 0; + return nullptr; if (d->isValueType()) { const QMetaObject *valueTypeMetaObject = QQmlValueTypeFactory::metaObjectForMetaType(d->core.propType()); Q_ASSERT(valueTypeMetaObject); @@ -495,7 +495,7 @@ const char *QQmlProperty::propertyTypeName() const } else if (d->object && type() & Property && d->core.isValid()) { return d->object->metaObject()->property(d->core.coreIndex()).typeName(); } else { - return 0; + return nullptr; } } @@ -579,7 +579,7 @@ bool QQmlProperty::isSignalProperty() const */ QObject *QQmlProperty::object() const { - return d ? d->object : 0; + return d ? d->object : nullptr; } /*! @@ -717,7 +717,7 @@ QQmlAbstractBinding * QQmlPropertyPrivate::binding(const QQmlProperty &that) { if (!that.d || !that.isProperty() || !that.d->object) - return 0; + return nullptr; QQmlPropertyIndex thatIndex(that.d->core.coreIndex(), that.d->valueTypeData.coreIndex()); return binding(that.d->object, thatIndex); @@ -779,7 +779,7 @@ static void removeOldBinding(QObject *object, QQmlPropertyIndex index, QQmlPrope return; if (!(flags & QQmlPropertyPrivate::DontEnable)) - oldBinding->setEnabled(false, 0); + oldBinding->setEnabled(false, nullptr); oldBinding->removeFromObject(); } @@ -813,13 +813,13 @@ QQmlPropertyPrivate::binding(QObject *object, QQmlPropertyIndex index) QQmlData *data = QQmlData::get(object); if (!data) - return 0; + return nullptr; const int coreIndex = index.coreIndex(); const int valueTypeIndex = index.valueTypeIndex(); if (coreIndex < 0 || !data->hasBindingBit(coreIndex)) - return 0; + return nullptr; QQmlAbstractBinding *binding = data->bindings; while (binding && (binding->targetPropertyIndex().coreIndex() != coreIndex || @@ -845,11 +845,11 @@ void QQmlPropertyPrivate::findAliasTarget(QObject *object, QQmlPropertyIndex bin int valueTypeIndex = bindingIndex.valueTypeIndex(); QQmlPropertyData *propertyData = - data->propertyCache?data->propertyCache->property(coreIndex):0; + data->propertyCache?data->propertyCache->property(coreIndex):nullptr; if (propertyData && propertyData->isAlias()) { QQmlVMEMetaObject *vme = QQmlVMEMetaObject::getForProperty(object, coreIndex); - QObject *aObject = 0; int aCoreIndex = -1; int aValueTypeIndex = -1; + QObject *aObject = nullptr; int aCoreIndex = -1; int aValueTypeIndex = -1; if (vme->aliasTarget(coreIndex, &aObject, &aCoreIndex, &aValueTypeIndex)) { // This will either be a value type sub-reference or an alias to a value-type sub-reference not both Q_ASSERT(valueTypeIndex == -1 || aValueTypeIndex == -1); @@ -904,11 +904,11 @@ QQmlBoundSignalExpression * QQmlPropertyPrivate::signalExpression(const QQmlProperty &that) { if (!(that.type() & QQmlProperty::SignalProperty)) - return 0; + return nullptr; QQmlData *data = QQmlData::get(that.d->object); if (!data) - return 0; + return nullptr; QQmlBoundSignal *signalHandler = data->signalHandlers; @@ -918,7 +918,7 @@ QQmlPropertyPrivate::signalExpression(const QQmlProperty &that) if (signalHandler) return signalHandler->expression(); - return 0; + return nullptr; } /*! @@ -945,7 +945,7 @@ void QQmlPropertyPrivate::takeSignalExpression(const QQmlProperty &that, return; } - QQmlData *data = QQmlData::get(that.d->object, 0 != expr); + QQmlData *data = QQmlData::get(that.d->object, nullptr != expr); if (!data) return; @@ -1052,7 +1052,7 @@ QVariant QQmlPropertyPrivate::readValueProperty() } else if (core.isQObject()) { - QObject *rv = 0; + QObject *rv = nullptr; core.readProperty(object, &rv); return QVariant::fromValue(rv); @@ -1063,11 +1063,11 @@ QVariant QQmlPropertyPrivate::readValueProperty() QVariant value; int status = -1; - void *args[] = { 0, &value, &status }; + void *args[] = { nullptr, &value, &status }; if (core.propType() == QMetaType::QVariant) { args[0] = &value; } else { - value = QVariant(core.propType(), (void*)0); + value = QVariant(core.propType(), (void*)nullptr); args[0] = value.data(); } core.readPropertyWithArgs(object, args); @@ -1426,7 +1426,7 @@ QQmlMetaObject QQmlPropertyPrivate::rawMetaObjectForType(QQmlEnginePrivate *engi */ bool QQmlProperty::write(const QVariant &value) const { - return QQmlPropertyPrivate::write(*this, value, 0); + return QQmlPropertyPrivate::write(*this, value, nullptr); } /*! @@ -1495,7 +1495,7 @@ bool QQmlProperty::write(QObject *object, const QString &name, const QVariant &v bool QQmlProperty::reset() const { if (isResettable()) { - void *args[] = { 0 }; + void *args[] = { nullptr }; QMetaObject::metacall(d->object, QMetaObject::ResetProperty, d->core.coreIndex(), args); return true; } else { diff --git a/src/qml/qml/qqmlproperty_p.h b/src/qml/qml/qqmlproperty_p.h index 7a66d8113c..544eab4c7f 100644 --- a/src/qml/qml/qqmlproperty_p.h +++ b/src/qml/qml/qqmlproperty_p.h @@ -104,9 +104,9 @@ public: static bool writeValueProperty(QObject *, const QQmlPropertyData &, const QQmlPropertyData &valueTypeData, const QVariant &, QQmlContextData *, - QQmlPropertyData::WriteFlags flags = 0); + QQmlPropertyData::WriteFlags flags = nullptr); static bool write(QObject *, const QQmlPropertyData &, const QVariant &, - QQmlContextData *, QQmlPropertyData::WriteFlags flags = 0); + QQmlContextData *, QQmlPropertyData::WriteFlags flags = nullptr); static void findAliasTarget(QObject *, QQmlPropertyIndex, QObject **, QQmlPropertyIndex *); enum BindingFlag { @@ -140,7 +140,7 @@ public: static QMetaMethod findSignalByName(const QMetaObject *mo, const QByteArray &); static bool connect(const QObject *sender, int signal_index, const QObject *receiver, int method_index, - int type = 0, int *types = 0); + int type = 0, int *types = nullptr); static void flushSignal(const QObject *sender, int signal_index); static QVariant resolvedUrlSequence(const QVariant &value, QQmlContextData *context); diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp index bce81c1504..88eda9c020 100644 --- a/src/qml/qml/qqmlpropertycache.cpp +++ b/src/qml/qml/qqmlpropertycache.cpp @@ -243,9 +243,9 @@ void QQmlPropertyData::lazyLoad(const QMetaMethod &m) Creates a new empty QQmlPropertyCache. */ QQmlPropertyCache::QQmlPropertyCache() - : _parent(0), propertyIndexCacheStart(0), methodIndexCacheStart(0), + : _parent(nullptr), propertyIndexCacheStart(0), methodIndexCacheStart(0), signalHandlerIndexCacheStart(0), _hasPropertyOverrides(false), _ownMetaObject(false), - _metaObject(0), argumentsCache(0), _jsFactoryMethodIndex(-1) + _metaObject(nullptr), argumentsCache(nullptr), _jsFactoryMethodIndex(-1) { } @@ -277,8 +277,8 @@ QQmlPropertyCache::~QQmlPropertyCache() if (_parent) _parent->release(); if (_ownMetaObject) free(const_cast(_metaObject)); - _metaObject = 0; - _parent = 0; + _metaObject = nullptr; + _parent = nullptr; } QQmlPropertyCache *QQmlPropertyCache::copy(int reserve) @@ -310,7 +310,7 @@ QQmlPropertyCache *QQmlPropertyCache::copyAndReserve(int propertyCount, int meth rv->methodIndexCache.reserve(methodCount); rv->signalHandlerIndexCache.reserve(signalCount); rv->enumCache.reserve(enumCount); - rv->_metaObject = 0; + rv->_metaObject = nullptr; return rv; } @@ -337,7 +337,7 @@ void QQmlPropertyCache::appendProperty(const QString &name, QQmlPropertyData::Fl int index = propertyIndexCache.count(); propertyIndexCache.append(data); - setNamedProperty(name, index + propertyOffset(), propertyIndexCache.data() + index, (old != 0)); + setNamedProperty(name, index + propertyOffset(), propertyIndexCache.data() + index, (old != nullptr)); } void QQmlPropertyCache::appendSignal(const QString &name, QQmlPropertyData::Flags flags, @@ -374,8 +374,8 @@ void QQmlPropertyCache::appendSignal(const QString &name, QQmlPropertyData::Flag QString handlerName = QLatin1String("on") + name; handlerName[2] = handlerName.at(2).toUpper(); - setNamedProperty(name, methodIndex + methodOffset(), methodIndexCache.data() + methodIndex, (old != 0)); - setNamedProperty(handlerName, signalHandlerIndex + signalOffset(), signalHandlerIndexCache.data() + signalHandlerIndex, (old != 0)); + setNamedProperty(name, methodIndex + methodOffset(), methodIndexCache.data() + methodIndex, (old != nullptr)); + setNamedProperty(handlerName, signalHandlerIndex + signalOffset(), signalHandlerIndexCache.data() + signalHandlerIndex, (old != nullptr)); } void QQmlPropertyCache::appendMethod(const QString &name, QQmlPropertyData::Flags flags, @@ -402,7 +402,7 @@ void QQmlPropertyCache::appendMethod(const QString &name, QQmlPropertyData::Flag int methodIndex = methodIndexCache.count(); methodIndexCache.append(data); - setNamedProperty(name, methodIndex + methodOffset(), methodIndexCache.data() + methodIndex, (old != 0)); + setNamedProperty(name, methodIndex + methodOffset(), methodIndexCache.data() + methodIndex, (old != nullptr)); } void QQmlPropertyCache::appendEnum(const QString &name, const QVector &values) @@ -430,7 +430,7 @@ const QMetaObject *QQmlPropertyCache::createMetaObject() QQmlPropertyData *QQmlPropertyCache::defaultProperty() const { - return property(defaultPropertyName(), 0, 0); + return property(defaultPropertyName(), nullptr, nullptr); } void QQmlPropertyCache::setParent(QQmlPropertyCache *newParent) @@ -543,7 +543,7 @@ void QQmlPropertyCache::append(const QMetaObject *metaObject, } QQmlPropertyData *data = &methodIndexCache[ii - methodIndexCacheStart]; - QQmlPropertyData *sigdata = 0; + QQmlPropertyData *sigdata = nullptr; if (m.methodType() == QMetaMethod::Signal) data->setFlags(signalFlags); @@ -562,24 +562,24 @@ void QQmlPropertyCache::append(const QMetaObject *metaObject, sigdata->_flags.isSignalHandler = true; } - QQmlPropertyData *old = 0; + QQmlPropertyData *old = nullptr; if (utf8) { QHashedString methodName(QString::fromUtf8(rawName, cptr - rawName)); if (StringCache::mapped_type *it = stringCache.value(methodName)) old = it->second; - setNamedProperty(methodName, ii, data, (old != 0)); + setNamedProperty(methodName, ii, data, (old != nullptr)); if (data->isSignal()) { QHashedString on(QLatin1String("on") % methodName.at(0).toUpper() % methodName.midRef(1)); - setNamedProperty(on, ii, sigdata, (old != 0)); + setNamedProperty(on, ii, sigdata, (old != nullptr)); ++signalHandlerIndex; } } else { QHashedCStringRef methodName(rawName, cptr - rawName); if (StringCache::mapped_type *it = stringCache.value(methodName)) old = it->second; - setNamedProperty(methodName, ii, data, (old != 0)); + setNamedProperty(methodName, ii, data, (old != nullptr)); if (data->isSignal()) { int length = methodName.length(); @@ -593,7 +593,7 @@ void QQmlPropertyCache::append(const QMetaObject *metaObject, str[length + 2] = '\0'; QHashedString on(QString::fromLatin1(str.data())); - setNamedProperty(on, ii, data, (old != 0)); + setNamedProperty(on, ii, data, (old != nullptr)); ++signalHandlerIndex; } } @@ -636,18 +636,18 @@ void QQmlPropertyCache::append(const QMetaObject *metaObject, Q_ASSERT((allowedRevisionCache.count() - 1) < Q_INT16_MAX); data->setMetaObjectOffset(allowedRevisionCache.count() - 1); - QQmlPropertyData *old = 0; + QQmlPropertyData *old = nullptr; if (utf8) { QHashedString propName(QString::fromUtf8(str, cptr - str)); if (StringCache::mapped_type *it = stringCache.value(propName)) old = it->second; - setNamedProperty(propName, ii, data, (old != 0)); + setNamedProperty(propName, ii, data, (old != nullptr)); } else { QHashedCStringRef propName(str, cptr - str); if (StringCache::mapped_type *it = stringCache.value(propName)) old = it->second; - setNamedProperty(propName, ii, data, (old != 0)); + setNamedProperty(propName, ii, data, (old != nullptr)); } bool isGadget = true; @@ -750,7 +750,7 @@ void QQmlPropertyCache::invalidate(const QMetaObject *metaObject) signalHandlerIndexCache.clear(); _hasPropertyOverrides = false; - argumentsCache = 0; + argumentsCache = nullptr; int pc = metaObject->propertyCount(); int mc = metaObject->methodCount(); @@ -773,8 +773,8 @@ void QQmlPropertyCache::invalidate(const QMetaObject *metaObject) QQmlPropertyData *QQmlPropertyCache::findProperty(StringCache::ConstIterator it, QObject *object, QQmlContextData *context) const { - QQmlData *data = (object ? QQmlData::get(object) : 0); - const QQmlVMEMetaObject *vmemo = 0; + QQmlData *data = (object ? QQmlData::get(object) : nullptr); + const QQmlVMEMetaObject *vmemo = nullptr; if (data && data->hasVMEMetaObject) { QObjectPrivate *op = QObjectPrivate::get(object); vmemo = static_cast(op->metaObject); @@ -849,7 +849,7 @@ QQmlPropertyData *QQmlPropertyCache::findProperty(StringCache::ConstIterator it, return ensureResolved(result); } - return 0; + return nullptr; } QString QQmlPropertyData::name(QObject *object) const @@ -919,9 +919,9 @@ QQmlPropertyCacheMethodArguments *QQmlPropertyCache::createArgumentsObject(int a A *args = static_cast(malloc(sizeof(A) + (argc) * sizeof(int))); args->arguments[0] = argc; args->argumentsValid = false; - args->signalParameterStringForJS = 0; + args->signalParameterStringForJS = nullptr; args->parameterError = false; - args->names = argc ? new QList(names) : 0; + args->names = argc ? new QList(names) : nullptr; args->next = argumentsCache; argumentsCache = args; return args; @@ -1027,10 +1027,10 @@ static QQmlPropertyData qQmlPropertyCacheCreate(const QMetaObject *metaObject, c } /* If the "cmo" variable didn't change, set it to 0 to * avoid running into an infinite loop */ - if (!changed) cmo = 0; + if (!changed) cmo = nullptr; } } else { - cmo = 0; + cmo = nullptr; } } } @@ -1057,7 +1057,7 @@ QQmlPropertyData * qQmlPropertyCacheProperty(QJSEngine *engine, QObject *obj, T name, QQmlContextData *context, QQmlPropertyData &local) { - QQmlPropertyCache *cache = 0; + QQmlPropertyCache *cache = nullptr; QQmlData *ddata = QQmlData::get(obj, false); @@ -1073,7 +1073,7 @@ qQmlPropertyCacheProperty(QJSEngine *engine, QObject *obj, T name, } } - QQmlPropertyData *rv = 0; + QQmlPropertyData *rv = nullptr; if (cache) { rv = cache->property(name, obj, context); @@ -1214,7 +1214,7 @@ void QQmlPropertyCache::toMetaObjectBuilder(QMetaObjectBuilder &builder) // '+=' reserves extra capacity. Follow-up appending will be probably free. signature += methods.at(ii).first.toUtf8() + '('; - QQmlPropertyCacheMethodArguments *arguments = 0; + QQmlPropertyCacheMethodArguments *arguments = nullptr; if (data->hasArguments()) { arguments = (QQmlPropertyCacheMethodArguments *)data->arguments(); Q_ASSERT(arguments->argumentsValid); @@ -1252,7 +1252,7 @@ void QQmlPropertyCache::toMetaObjectBuilder(QMetaObjectBuilder &builder) } if (!_defaultPropertyName.isEmpty()) { - QQmlPropertyData *dp = property(_defaultPropertyName, 0, 0); + QQmlPropertyData *dp = property(_defaultPropertyName, nullptr, nullptr); if (dp && dp->coreIndex() >= propertyIndexCacheStart) { Q_ASSERT(!dp->isFunction()); builder.addClassInfo("DefaultProperty", _defaultPropertyName.toUtf8()); @@ -1577,7 +1577,7 @@ void QQmlMetaObject::resolveGadgetMethodOrPropertyIndex(QMetaObject::Call type, QQmlPropertyCache *QQmlMetaObject::propertyCache(QQmlEnginePrivate *e) const { - if (_m.isNull()) return 0; + if (_m.isNull()) return nullptr; if (_m.isT1()) return _m.asT1(); else return e->cache(_m.asT2()); } @@ -1588,7 +1588,7 @@ int QQmlMetaObject::methodReturnType(const QQmlPropertyData &data, QByteArray *u int type = data.propType(); - const char *propTypeName = 0; + const char *propTypeName = nullptr; if (type == QMetaType::UnknownType) { // Find the return type name from the method info @@ -1676,7 +1676,7 @@ int *QQmlMetaObject::methodParameterTypes(int index, ArgTypeStorage *argStorage, } if (type == QMetaType::UnknownType) { if (unknownTypeError) *unknownTypeError = argTypeNames.at(ii); - return 0; + return nullptr; } args->arguments[ii + 1] = type; } @@ -1715,7 +1715,7 @@ int *QQmlMetaObject::methodParameterTypes(const QMetaMethod &m, ArgTypeStorage * } if (type == QMetaType::UnknownType) { if (unknownTypeError) *unknownTypeError = argTypeNames.at(ii); - return 0; + return nullptr; } argStorage->operator[](ii + 1) = type; } @@ -1727,7 +1727,7 @@ void QQmlObjectOrGadget::metacall(QMetaObject::Call type, int index, void **argv { if (ptr.isNull()) { const QMetaObject *metaObject = _m.asT2(); - metaObject->d.static_metacall(0, type, index, argv); + metaObject->d.static_metacall(nullptr, type, index, argv); } else if (ptr.isT1()) { QMetaObject::metacall(ptr.asT1(), type, index, argv); diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h index 11b7c04c52..22be6ba60c 100644 --- a/src/qml/qml/qqmlpropertycache_p.h +++ b/src/qml/qml/qqmlpropertycache_p.h @@ -323,7 +323,7 @@ public: inline void readProperty(QObject *target, void *property) const { - void *args[] = { property, 0 }; + void *args[] = { property, nullptr }; readPropertyWithArgs(target, args); } @@ -340,7 +340,7 @@ public: bool writeProperty(QObject *target, void *value, WriteFlags flags) const { int status = -1; - void *argv[] = { value, 0, &status, &flags }; + void *argv[] = { value, nullptr, &status, &flags }; if (flags.testFlag(BypassInterceptor) && hasStaticMetaCallFunction()) staticMetaCallFunction()(target, QMetaObject::WriteProperty, relativePropertyIndex(), argv); else if (flags.testFlag(BypassInterceptor) && isDirect()) @@ -417,7 +417,7 @@ public: void appendProperty(const QString &, QQmlPropertyRawData::Flags flags, int coreIndex, int propType, int revision, int notifyIndex); void appendSignal(const QString &, QQmlPropertyRawData::Flags, int coreIndex, - const int *types = 0, const QList &names = QList()); + const int *types = nullptr, const QList &names = QList()); void appendMethod(const QString &, QQmlPropertyData::Flags flags, int coreIndex, const QList &names = QList()); void appendEnum(const QString &, const QVector &); @@ -465,7 +465,7 @@ public: static int originalClone(QObject *, int index); QList signalParameterNames(int index) const; - static QString signalParameterStringForJS(QV4::ExecutionEngine *engine, const QList ¶meterNameList, QString *errorString = 0); + static QString signalParameterStringForJS(QV4::ExecutionEngine *engine, const QList ¶meterNameList, QString *errorString = nullptr); const char *className() const; @@ -739,7 +739,7 @@ inline const QMetaObject *QQmlPropertyCache::metaObject() const // QML inline const QMetaObject *QQmlPropertyCache::firstCppMetaObject() const { - while (_parent && (_metaObject == 0 || _ownMetaObject)) + while (_parent && (_metaObject == nullptr || _ownMetaObject)) return _parent->firstCppMetaObject(); return _metaObject; } @@ -747,7 +747,7 @@ inline const QMetaObject *QQmlPropertyCache::firstCppMetaObject() const inline QQmlPropertyData *QQmlPropertyCache::property(int index) const { if (index < 0 || index >= (propertyIndexCacheStart + propertyIndexCache.count())) - return 0; + return nullptr; if (index < propertyIndexCacheStart) return _parent->property(index); @@ -759,7 +759,7 @@ inline QQmlPropertyData *QQmlPropertyCache::property(int index) const inline QQmlPropertyData *QQmlPropertyCache::method(int index) const { if (index < 0 || index >= (methodIndexCacheStart + methodIndexCache.count())) - return 0; + return nullptr; if (index < methodIndexCacheStart) return _parent->method(index); @@ -775,7 +775,7 @@ inline QQmlPropertyData *QQmlPropertyCache::method(int index) const inline QQmlPropertyData *QQmlPropertyCache::signal(int index) const { if (index < 0 || index >= (signalHandlerIndexCacheStart + signalHandlerIndexCache.count())) - return 0; + return nullptr; if (index < signalHandlerIndexCacheStart) return _parent->signal(index); @@ -788,7 +788,7 @@ inline QQmlPropertyData *QQmlPropertyCache::signal(int index) const inline QQmlEnumData *QQmlPropertyCache::qmlEnum(int index) const { if (index < 0 || index >= enumCache.count()) - return 0; + return nullptr; return const_cast(&enumCache.at(index)); } @@ -819,7 +819,7 @@ QQmlPropertyData * QQmlPropertyCache::overrideData(QQmlPropertyData *data) const { if (!data->hasOverride()) - return 0; + return nullptr; if (data->overrideIndexIsProperty()) return property(data->overrideIndex()); @@ -921,7 +921,7 @@ bool QQmlMetaObject::isNull() const const char *QQmlMetaObject::className() const { if (_m.isNull()) { - return 0; + return nullptr; } else if (_m.isT1()) { return _m.asT1()->className(); } else { @@ -947,7 +947,7 @@ bool QQmlMetaObject::hasMetaObject() const const QMetaObject *QQmlMetaObject::metaObject() const { - if (_m.isNull()) return 0; + if (_m.isNull()) return nullptr; if (_m.isT1()) return _m.asT1()->createMetaObject(); else return _m.asT2(); } diff --git a/src/qml/qml/qqmlpropertyvalueinterceptor.cpp b/src/qml/qml/qqmlpropertyvalueinterceptor.cpp index 52c003ab59..603245f29d 100644 --- a/src/qml/qml/qqmlpropertyvalueinterceptor.cpp +++ b/src/qml/qml/qqmlpropertyvalueinterceptor.cpp @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE /*! Constructs a QQmlPropertyValueInterceptor. */ -QQmlPropertyValueInterceptor::QQmlPropertyValueInterceptor() : m_next(0) +QQmlPropertyValueInterceptor::QQmlPropertyValueInterceptor() : m_next(nullptr) { } diff --git a/src/qml/qml/qqmlproxymetaobject.cpp b/src/qml/qml/qqmlproxymetaobject.cpp index 27e3c13ff8..e1500f70fb 100644 --- a/src/qml/qml/qqmlproxymetaobject.cpp +++ b/src/qml/qml/qqmlproxymetaobject.cpp @@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE QQmlProxyMetaObject::QQmlProxyMetaObject(QObject *obj, QList *mList) -: metaObjects(mList), proxies(0), parent(0), object(obj) +: metaObjects(mList), proxies(nullptr), parent(nullptr), object(obj) { *static_cast(this) = *metaObjects->constFirst().metaObject; @@ -58,11 +58,11 @@ QQmlProxyMetaObject::~QQmlProxyMetaObject() { if (parent) delete parent; - parent = 0; + parent = nullptr; if (proxies) delete [] proxies; - proxies = 0; + proxies = nullptr; } int QQmlProxyMetaObject::metaCall(QObject *o, QMetaObject::Call c, int id, void **a) diff --git a/src/qml/qml/qqmlscriptstring_p.h b/src/qml/qml/qqmlscriptstring_p.h index 2dfb817186..fd8ccd5d53 100644 --- a/src/qml/qml/qqmlscriptstring_p.h +++ b/src/qml/qml/qqmlscriptstring_p.h @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE class Q_AUTOTEST_EXPORT QQmlScriptStringPrivate : public QSharedData { public: - QQmlScriptStringPrivate() : context(0), scope(0), bindingId(-1), lineNumber(0), columnNumber(0), + QQmlScriptStringPrivate() : context(nullptr), scope(nullptr), bindingId(-1), lineNumber(0), columnNumber(0), numberValue(0), isStringLiteral(false), isNumberLiteral(false) {} //for testing diff --git a/src/qml/qml/qqmlstringconverters_p.h b/src/qml/qml/qqmlstringconverters_p.h index af344e3344..215f0c0aaf 100644 --- a/src/qml/qml/qqmlstringconverters_p.h +++ b/src/qml/qml/qqmlstringconverters_p.h @@ -67,19 +67,19 @@ class QByteArray; namespace QQmlStringConverters { Q_QML_PRIVATE_EXPORT QVariant variantFromString(const QString &); - Q_QML_PRIVATE_EXPORT QVariant variantFromString(const QString &, int preferredType, bool *ok = 0); + Q_QML_PRIVATE_EXPORT QVariant variantFromString(const QString &, int preferredType, bool *ok = nullptr); - Q_QML_PRIVATE_EXPORT QVariant colorFromString(const QString &, bool *ok = 0); - Q_QML_PRIVATE_EXPORT unsigned rgbaFromString(const QString &, bool *ok = 0); + Q_QML_PRIVATE_EXPORT QVariant colorFromString(const QString &, bool *ok = nullptr); + Q_QML_PRIVATE_EXPORT unsigned rgbaFromString(const QString &, bool *ok = nullptr); #if QT_CONFIG(datestring) - Q_QML_PRIVATE_EXPORT QDate dateFromString(const QString &, bool *ok = 0); - Q_QML_PRIVATE_EXPORT QTime timeFromString(const QString &, bool *ok = 0); - Q_QML_PRIVATE_EXPORT QDateTime dateTimeFromString(const QString &, bool *ok = 0); + Q_QML_PRIVATE_EXPORT QDate dateFromString(const QString &, bool *ok = nullptr); + Q_QML_PRIVATE_EXPORT QTime timeFromString(const QString &, bool *ok = nullptr); + Q_QML_PRIVATE_EXPORT QDateTime dateTimeFromString(const QString &, bool *ok = nullptr); #endif - Q_QML_PRIVATE_EXPORT QPointF pointFFromString(const QString &, bool *ok = 0); - Q_QML_PRIVATE_EXPORT QSizeF sizeFFromString(const QString &, bool *ok = 0); - Q_QML_PRIVATE_EXPORT QRectF rectFFromString(const QString &, bool *ok = 0); + Q_QML_PRIVATE_EXPORT QPointF pointFFromString(const QString &, bool *ok = nullptr); + Q_QML_PRIVATE_EXPORT QSizeF sizeFFromString(const QString &, bool *ok = nullptr); + Q_QML_PRIVATE_EXPORT QRectF rectFFromString(const QString &, bool *ok = nullptr); Q_QML_PRIVATE_EXPORT bool createFromString(int, const QString &, void *, size_t); } diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index e5682df761..ed1526c0a9 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -550,7 +550,7 @@ void QQmlDataBlob::networkError(QNetworkReply::NetworkError networkError) QQmlError error; error.setUrl(m_url); - const char *errorString = 0; + const char *errorString = nullptr; switch (networkError) { default: errorString = "Network error"; @@ -791,7 +791,7 @@ void QQmlDataBlob::ThreadData::setProgress(quint8 v) QQmlTypeLoaderThread::QQmlTypeLoaderThread(QQmlTypeLoader *loader) : m_loader(loader) #if QT_CONFIG(qml_network) -, m_networkAccessManager(0), m_networkReplyProxy(0) +, m_networkAccessManager(nullptr), m_networkReplyProxy(nullptr) #endif // qml_network { // Do that after initializing all the members. @@ -803,7 +803,7 @@ QNetworkAccessManager *QQmlTypeLoaderThread::networkAccessManager() const { Q_ASSERT(isThisThread()); if (!m_networkAccessManager) { - m_networkAccessManager = QQmlEnginePrivate::get(m_loader->engine())->createNetworkAccessManager(0); + m_networkAccessManager = QQmlEnginePrivate::get(m_loader->engine())->createNetworkAccessManager(nullptr); m_networkReplyProxy = new QQmlTypeLoaderNetworkReplyProxy(m_loader); } @@ -876,9 +876,9 @@ void QQmlTypeLoaderThread::shutdownThread() { #if QT_CONFIG(qml_network) delete m_networkAccessManager; - m_networkAccessManager = 0; + m_networkAccessManager = nullptr; delete m_networkReplyProxy; - m_networkReplyProxy = 0; + m_networkReplyProxy = nullptr; #endif // qml_network } @@ -962,7 +962,7 @@ void QQmlTypeLoader::invalidate() if (m_thread) { shutdownThread(); delete m_thread; - m_thread = 0; + m_thread = nullptr; } #if QT_CONFIG(qml_network) @@ -1535,7 +1535,7 @@ void QQmlTypeLoader::Blob::dependencyComplete(QQmlDataBlob *blob) bool QQmlTypeLoader::Blob::isDebugging() const { - return typeLoader()->engine()->handle()->debugger() != 0; + return typeLoader()->engine()->handle()->debugger() != nullptr; } bool QQmlTypeLoader::Blob::qmldirDataAvailable(QQmlQmldirData *data, QList *errors) @@ -1543,7 +1543,7 @@ bool QQmlTypeLoader::Blob::qmldirDataAvailable(QQmlQmldirData *data, QListimport(this); - data->setImport(this, 0); + data->setImport(this, nullptr); int priority = data->priority(this); data->setPriority(this, 0); @@ -1818,7 +1818,7 @@ QString QQmlTypeLoader::absoluteFilePath(const QString &path) if (!m_importDirCache.contains(dirPath)) { bool exists = QDir(dirPath).exists(); - QCache *entry = exists ? new QCache : 0; + QCache *entry = exists ? new QCache : nullptr; m_importDirCache.insert(dirPath, entry); } QCache *fileSet = m_importDirCache.object(dirPath); @@ -1881,12 +1881,12 @@ bool QQmlTypeLoader::directoryExists(const QString &path) if (!m_importDirCache.contains(dirPath)) { bool exists = QDir(dirPath).exists(); - QCache *files = exists ? new QCache : 0; + QCache *files = exists ? new QCache : nullptr; m_importDirCache.insert(dirPath, files); } QCache *fileSet = m_importDirCache.object(dirPath); - return fileSet != 0; + return fileSet != nullptr; } @@ -2764,7 +2764,7 @@ bool QQmlTypeData::resolveType(const QString &typeName, int &majorVersion, int & TypeReference &ref, int lineNumber, int columnNumber, bool reportErrors, QQmlType::RegistrationType registrationType) { - QQmlImportNamespace *typeNamespace = 0; + QQmlImportNamespace *typeNamespace = nullptr; QList errors; bool typeFound = m_importCache.resolveType(typeName, &ref.type, &majorVersion, &minorVersion, @@ -2824,9 +2824,9 @@ void QQmlTypeData::scriptImported(QQmlScriptBlob *blob, const QV4::CompiledData: } QQmlScriptData::QQmlScriptData() - : typeNameCache(0) + : typeNameCache(nullptr) , m_loaded(false) - , m_program(0) + , m_program(nullptr) { } @@ -2843,7 +2843,7 @@ void QQmlScriptData::initialize(QQmlEngine *engine) QV4::ExecutionEngine *v4 = engine->handle(); - m_program = new QV4::Script(v4, 0, m_precompiledScript); + m_program = new QV4::Script(v4, nullptr, m_precompiledScript); addToEngine(engine); @@ -2864,7 +2864,7 @@ QV4::ReturnedValue QQmlScriptData::scriptValueForContext(QQmlContextData *parent QQmlContextData *effectiveCtxt = parentCtxt; if (shared) - effectiveCtxt = 0; + effectiveCtxt = nullptr; // Create the script context if required QQmlContextDataRef ctxt(new QQmlContextData); @@ -2912,7 +2912,7 @@ QV4::ReturnedValue QQmlScriptData::scriptValueForContext(QQmlContextData *parent return QV4::Encode::undefined(); } - QV4::Scoped qmlContext(scope, QV4::QmlContext::create(v4->rootContext(), ctxt, 0)); + QV4::Scoped qmlContext(scope, QV4::QmlContext::create(v4->rootContext(), ctxt, nullptr)); m_program->qmlContext.set(scope.engine, qmlContext); m_program->run(); @@ -2936,7 +2936,7 @@ void QQmlScriptData::clear() { if (typeNameCache) { typeNameCache->release(); - typeNameCache = 0; + typeNameCache = nullptr; } for (int ii = 0; ii < scripts.count(); ++ii) @@ -2948,7 +2948,7 @@ void QQmlScriptData::clear() } QQmlScriptBlob::QQmlScriptBlob(const QUrl &url, QQmlTypeLoader *loader) -: QQmlTypeLoader::Blob(url, JavaScriptFile, loader), m_scriptData(0) +: QQmlTypeLoader::Blob(url, JavaScriptFile, loader), m_scriptData(nullptr) { } @@ -2956,7 +2956,7 @@ QQmlScriptBlob::~QQmlScriptBlob() { if (m_scriptData) { m_scriptData->release(); - m_scriptData = 0; + m_scriptData = nullptr; } } @@ -3135,7 +3135,7 @@ const QV4::CompiledData::Import *QQmlQmldirData::import(QQmlTypeLoader::Blob *bl QHash::const_iterator it = m_imports.find(blob); if (it == m_imports.end()) - return 0; + return nullptr; return *it; } diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h index 875c335c9a..f2327e9a5f 100644 --- a/src/qml/qml/qqmltypeloader_p.h +++ b/src/qml/qml/qqmltypeloader_p.h @@ -411,7 +411,7 @@ class Q_AUTOTEST_EXPORT QQmlTypeData : public QQmlTypeLoader::Blob public: struct TypeReference { - TypeReference() : majorVersion(0), minorVersion(0), typeData(0), needsCreation(true) {} + TypeReference() : majorVersion(0), minorVersion(0), typeData(nullptr), needsCreation(true) {} QV4::CompiledData::Location location; QQmlType type; @@ -425,7 +425,7 @@ public: struct ScriptReference { - ScriptReference() : script(0) {} + ScriptReference() : script(nullptr) {} QV4::CompiledData::Location location; QString qualifier; @@ -558,7 +558,7 @@ public: struct ScriptReference { - ScriptReference() : script(0) {} + ScriptReference() : script(nullptr) {} QV4::CompiledData::Location location; QString qualifier; diff --git a/src/qml/qml/qqmltypenamecache.cpp b/src/qml/qml/qqmltypenamecache.cpp index 32b0fa16c4..8f1a61e6ad 100644 --- a/src/qml/qml/qqmltypenamecache.cpp +++ b/src/qml/qml/qqmltypenamecache.cpp @@ -56,7 +56,7 @@ void QQmlTypeNameCache::add(const QHashedString &name, const QUrl &url, const QH { if (nameSpace.length() != 0) { QQmlImportRef *i = m_namedImports.value(nameSpace); - Q_ASSERT(i != 0); + Q_ASSERT(i != nullptr); i->compositeSingletons.insert(name, url); return; } @@ -75,7 +75,7 @@ void QQmlTypeNameCache::add(const QHashedString &name, int importedScriptIndex, if (nameSpace.length() != 0) { QQmlImportRef *i = m_namedImports.value(nameSpace); - Q_ASSERT(i != 0); + Q_ASSERT(i != nullptr); m_namespacedImports[i].insert(name, import); return; } @@ -98,10 +98,10 @@ QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedStringRef &name) if (!result.isValid()) { // Look up anonymous types from the imports of this document - QQmlImportNamespace *typeNamespace = 0; + QQmlImportNamespace *typeNamespace = nullptr; QList errors; QQmlType t; - bool typeFound = m_imports.resolveType(name, &t, 0, 0, &typeNamespace, &errors); + bool typeFound = m_imports.resolveType(name, &t, nullptr, nullptr, &typeNamespace, &errors); if (typeFound) { return Result(t); } @@ -126,10 +126,10 @@ QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedStringRef &name, // ### it would be nice if QQmlImports allowed us to resolve a namespace // first, and then types on it. QString qualifiedTypeName = importNamespace->m_qualifier + QLatin1Char('.') + name.toString(); - QQmlImportNamespace *typeNamespace = 0; + QQmlImportNamespace *typeNamespace = nullptr; QList errors; QQmlType t; - bool typeFound = m_imports.resolveType(qualifiedTypeName, &t, 0, 0, &typeNamespace, &errors); + bool typeFound = m_imports.resolveType(qualifiedTypeName, &t, nullptr, nullptr, &typeNamespace, &errors); if (typeFound) { return Result(t); } @@ -151,10 +151,10 @@ QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QV4::String *name, QQml if (!result.isValid()) { // Look up anonymous types from the imports of this document QString typeName = name->toQStringNoThrow(); - QQmlImportNamespace *typeNamespace = 0; + QQmlImportNamespace *typeNamespace = nullptr; QList errors; QQmlType t; - bool typeFound = m_imports.resolveType(typeName, &t, 0, 0, &typeNamespace, &errors, + bool typeFound = m_imports.resolveType(typeName, &t, nullptr, nullptr, &typeNamespace, &errors, QQmlType::AnyRegistrationType, recursionRestriction); if (typeFound) { return Result(t); @@ -186,10 +186,10 @@ QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QV4::String *name, cons // ### it would be nice if QQmlImports allowed us to resolve a namespace // first, and then types on it. QString qualifiedTypeName = importNamespace->m_qualifier + QLatin1Char('.') + name->toQStringNoThrow(); - QQmlImportNamespace *typeNamespace = 0; + QQmlImportNamespace *typeNamespace = nullptr; QList errors; QQmlType t; - bool typeFound = m_imports.resolveType(qualifiedTypeName, &t, 0, 0, &typeNamespace, &errors); + bool typeFound = m_imports.resolveType(qualifiedTypeName, &t, nullptr, nullptr, &typeNamespace, &errors); if (typeFound) { return Result(t); } diff --git a/src/qml/qml/qqmltypenamecache_p.h b/src/qml/qml/qqmltypenamecache_p.h index 8ac25c4fbe..c2f7a70d03 100644 --- a/src/qml/qml/qqmltypenamecache_p.h +++ b/src/qml/qml/qqmltypenamecache_p.h @@ -162,7 +162,7 @@ private: }; QQmlTypeNameCache::Result::Result() -: importNamespace(0), scriptIndex(-1) +: importNamespace(nullptr), scriptIndex(-1) { } @@ -172,12 +172,12 @@ QQmlTypeNameCache::Result::Result(const QQmlImportRef *importNamespace) } QQmlTypeNameCache::Result::Result(const QQmlType &type) -: type(type), importNamespace(0), scriptIndex(-1) +: type(type), importNamespace(nullptr), scriptIndex(-1) { } QQmlTypeNameCache::Result::Result(int scriptIndex) -: importNamespace(0), scriptIndex(scriptIndex) +: importNamespace(nullptr), scriptIndex(scriptIndex) { } diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp index 8e067932bb..6dbf6ad8c1 100644 --- a/src/qml/qml/qqmltypewrapper.cpp +++ b/src/qml/qml/qqmltypewrapper.cpp @@ -85,7 +85,7 @@ bool QQmlTypeWrapper::isSingleton() const QObject* QQmlTypeWrapper::singletonObject() const { if (!isSingleton()) - return 0; + return nullptr; QQmlEngine *e = engine()->qmlEngine(); QQmlType::SingletonInstanceInfo *siinfo = d()->type().singletonInstanceInfo(); diff --git a/src/qml/qml/qqmlvaluetype.cpp b/src/qml/qml/qqmlvaluetype.cpp index 520f512b1a..270414a676 100644 --- a/src/qml/qml/qqmlvaluetype.cpp +++ b/src/qml/qml/qqmlvaluetype.cpp @@ -68,7 +68,7 @@ struct QQmlValueTypeFactoryImpl QQmlValueTypeFactoryImpl::QQmlValueTypeFactoryImpl() { for (unsigned int ii = 0; ii < QVariant::UserType; ++ii) - valueTypes[ii] = 0; + valueTypes[ii] = nullptr; // See types wrapped in qqmlmodelindexvaluetype_p.h qRegisterMetaType(); @@ -83,7 +83,7 @@ QQmlValueTypeFactoryImpl::~QQmlValueTypeFactoryImpl() bool QQmlValueTypeFactoryImpl::isValueType(int idx) { if (idx >= (int)QVariant::UserType) { - return (valueType(idx) != 0); + return (valueType(idx) != nullptr); } else if (idx >= 0 && idx != QVariant::StringList && idx != QMetaType::QObjectStar @@ -130,7 +130,7 @@ const QMetaObject *QQmlValueTypeFactoryImpl::metaObjectForMetaType(int t) QMetaType metaType(t); if (metaType.flags() & QMetaType::IsGadget) return metaType.metaObject(); - return 0; + return nullptr; } QQmlValueType *QQmlValueTypeFactoryImpl::valueType(int idx) @@ -141,7 +141,7 @@ QQmlValueType *QQmlValueTypeFactoryImpl::valueType(int idx) QHash::iterator it = userTypes.find(idx); if (it == userTypes.end()) { - QQmlValueType *vt = 0; + QQmlValueType *vt = nullptr; if (const QMetaObject *mo = metaObjectForMetaType(idx)) vt = new QQmlValueType(idx, mo); it = userTypes.insert(idx, vt); @@ -209,14 +209,14 @@ QQmlValueType::~QQmlValueType() { QObjectPrivate *op = QObjectPrivate::get(this); Q_ASSERT(op->metaObject == this); - op->metaObject = 0; + op->metaObject = nullptr; ::free(const_cast(_metaObject)); metaType.destroy(gadgetPtr); } void QQmlValueType::read(QObject *obj, int idx) { - void *a[] = { gadgetPtr, 0 }; + void *a[] = { gadgetPtr, nullptr }; QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a); } @@ -224,7 +224,7 @@ void QQmlValueType::write(QObject *obj, int idx, QQmlPropertyData::WriteFlags fl { Q_ASSERT(gadgetPtr); int status = -1; - void *a[] = { gadgetPtr, 0, &status, &flags }; + void *a[] = { gadgetPtr, nullptr, &status, &flags }; QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a); } diff --git a/src/qml/qml/qqmlvaluetype_p.h b/src/qml/qml/qqmlvaluetype_p.h index 0502a5d665..7d8473db0e 100644 --- a/src/qml/qml/qqmlvaluetype_p.h +++ b/src/qml/qml/qqmlvaluetype_p.h @@ -272,19 +272,19 @@ int qmlRegisterValueTypeEnums(const char *uri, int versionMajor, int versionMino QQmlPrivate::RegisterType type = { 0, - qRegisterNormalizedMetaType(pointerName.constData()), 0, 0, 0, + qRegisterNormalizedMetaType(pointerName.constData()), 0, 0, nullptr, QString(), uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject, - 0, 0, + nullptr, nullptr, 0, 0, 0, - 0, 0, + nullptr, nullptr, - 0, + nullptr, 0 }; diff --git a/src/qml/qml/qqmlvaluetypeproxybinding.cpp b/src/qml/qml/qqmlvaluetypeproxybinding.cpp index 7a3e4b2df4..d5cff26444 100644 --- a/src/qml/qml/qqmlvaluetypeproxybinding.cpp +++ b/src/qml/qml/qqmlvaluetypeproxybinding.cpp @@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE QQmlValueTypeProxyBinding::QQmlValueTypeProxyBinding(QObject *o, QQmlPropertyIndex index) : QQmlAbstractBinding(), - m_bindings(0) + m_bindings(nullptr) { m_target = o; m_targetIndex = index; @@ -93,7 +93,7 @@ Removes a collection of bindings, corresponding to the set bits in \a mask. void QQmlValueTypeProxyBinding::removeBindings(quint32 mask) { QQmlAbstractBinding *binding = m_bindings.data(); - QQmlAbstractBinding *lastBinding = 0; + QQmlAbstractBinding *lastBinding = nullptr; while (binding) { const int valueTypeIndex = binding->targetPropertyIndex().valueTypeIndex(); @@ -102,7 +102,7 @@ void QQmlValueTypeProxyBinding::removeBindings(quint32 mask) remove->setAddedToObject(false); binding = remove->nextBinding(); - if (lastBinding == 0) + if (lastBinding == nullptr) m_bindings = remove->nextBinding(); else lastBinding->setNextBinding(remove->nextBinding()); diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index c643beeadc..a28115d192 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -131,7 +131,7 @@ bool QQmlValueTypeReference::readReferenceValue() const // variant-containing-value-type reference QVariant variantReferenceValue; - void *a[] = { &variantReferenceValue, 0 }; + void *a[] = { &variantReferenceValue, nullptr }; QMetaObject::metacall(d()->object, QMetaObject::ReadProperty, d()->property, a); int variantReferenceType = variantReferenceValue.userType(); @@ -141,14 +141,14 @@ bool QQmlValueTypeReference::readReferenceValue() const // We need to modify this reference to the updated value type, if // possible, or return false if it is not a value type. if (QQmlValueTypeFactory::isValueType(variantReferenceType)) { - QQmlPropertyCache *cache = 0; + QQmlPropertyCache *cache = nullptr; if (const QMetaObject *mo = QQmlValueTypeFactory::metaObjectForMetaType(variantReferenceType)) cache = QJSEnginePrivate::get(engine())->cache(mo); if (d()->gadgetPtr) { d()->valueType->metaType.destruct(d()->gadgetPtr); ::operator delete(d()->gadgetPtr); } - d()->gadgetPtr =0; + d()->gadgetPtr =nullptr; d()->setPropertyCache(cache); d()->valueType = QQmlValueTypeFactory::valueType(variantReferenceType); if (!cache) @@ -161,10 +161,10 @@ bool QQmlValueTypeReference::readReferenceValue() const } else { if (!d()->gadgetPtr) { d()->gadgetPtr = ::operator new(d()->valueType->metaType.sizeOf()); - d()->valueType->metaType.construct(d()->gadgetPtr, 0); + d()->valueType->metaType.construct(d()->gadgetPtr, nullptr); } // value-type reference - void *args[] = { d()->gadgetPtr, 0 }; + void *args[] = { d()->gadgetPtr, nullptr }; QMetaObject::metacall(d()->object, QMetaObject::ReadProperty, d()->property, args); } return true; @@ -191,7 +191,7 @@ ReturnedValue QQmlValueTypeWrapper::create(ExecutionEngine *engine, QObject *obj r->d()->property = property; r->d()->setPropertyCache(QJSEnginePrivate::get(engine)->cache(metaObject)); r->d()->valueType = QQmlValueTypeFactory::valueType(typeId); - r->d()->gadgetPtr = 0; + r->d()->gadgetPtr = nullptr; return r->asReturnedValue(); } @@ -203,7 +203,7 @@ ReturnedValue QQmlValueTypeWrapper::create(ExecutionEngine *engine, const QVaria Scoped r(scope, engine->memoryManager->allocObject()); r->d()->setPropertyCache(QJSEnginePrivate::get(engine)->cache(metaObject)); r->d()->valueType = QQmlValueTypeFactory::valueType(typeId); - r->d()->gadgetPtr = 0; + r->d()->gadgetPtr = nullptr; r->d()->setValue(value); return r->asReturnedValue(); } @@ -246,13 +246,13 @@ PropertyAttributes QQmlValueTypeWrapper::query(const Managed *m, String *name) Q_ASSERT(m->as()); const QQmlValueTypeWrapper *r = static_cast(m); - QQmlPropertyData *result = r->d()->propertyCache()->property(name, 0, 0); + QQmlPropertyData *result = r->d()->propertyCache()->property(name, nullptr, nullptr); return result ? Attr_Data : Attr_Invalid; } void QQmlValueTypeWrapper::advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes) { - name->setM(0); + name->setM(nullptr); *index = UINT_MAX; QQmlValueTypeWrapper *that = static_cast(m); @@ -299,7 +299,7 @@ bool QQmlValueTypeWrapper::write(QObject *target, int propertyIndex) const if (!d()->gadgetPtr) { Q_ALLOCA_ASSIGN(void, gadget, d()->valueType->metaType.sizeOf()); d()->gadgetPtr = gadget; - d()->valueType->metaType.construct(d()->gadgetPtr, 0); + d()->valueType->metaType.construct(d()->gadgetPtr, nullptr); destructGadgetOnExit = true; } if (!ref->readReferenceValue()) @@ -308,12 +308,12 @@ bool QQmlValueTypeWrapper::write(QObject *target, int propertyIndex) const int flags = 0; int status = -1; - void *a[] = { d()->gadgetPtr, 0, &status, &flags }; + void *a[] = { d()->gadgetPtr, nullptr, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, propertyIndex, a); if (destructGadgetOnExit) { d()->valueType->metaType.destruct(d()->gadgetPtr); - d()->gadgetPtr = 0; + d()->gadgetPtr = nullptr; } return true; } @@ -367,7 +367,7 @@ ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, String *name, bool *ha return Primitive::undefinedValue().asReturnedValue(); } - QQmlPropertyData *result = r->d()->propertyCache()->property(name, 0, 0); + QQmlPropertyData *result = r->d()->propertyCache()->property(name, nullptr, nullptr); if (!result) return Object::get(m, name, hasProperty); @@ -436,7 +436,7 @@ bool QQmlValueTypeWrapper::put(Managed *m, String *name, const Value &value) } const QMetaObject *metaObject = r->d()->propertyCache()->metaObject(); - const QQmlPropertyData *pd = r->d()->propertyCache()->property(name, 0, 0); + const QQmlPropertyData *pd = r->d()->propertyCache()->property(name, nullptr, nullptr); if (!pd) return false; @@ -505,13 +505,13 @@ bool QQmlValueTypeWrapper::put(Managed *m, String *name, const Value &value) int flags = 0; int status = -1; - void *a[] = { &variantReferenceValue, 0, &status, &flags }; + void *a[] = { &variantReferenceValue, nullptr, &status, &flags }; QMetaObject::metacall(reference->d()->object, QMetaObject::WriteProperty, reference->d()->property, a); } else { int flags = 0; int status = -1; - void *a[] = { r->d()->gadgetPtr, 0, &status, &flags }; + void *a[] = { r->d()->gadgetPtr, nullptr, &status, &flags }; QMetaObject::metacall(reference->d()->object, QMetaObject::WriteProperty, reference->d()->property, a); } } diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp index 72d4ab7e8f..018769948d 100644 --- a/src/qml/qml/qqmlvme.cpp +++ b/src/qml/qml/qqmlvme.cpp @@ -96,7 +96,7 @@ bool QQmlVME::componentCompleteEnabled() } QQmlVMEGuard::QQmlVMEGuard() -: m_objectCount(0), m_objects(0), m_contextCount(0), m_contexts(0) +: m_objectCount(0), m_objects(nullptr), m_contextCount(0), m_contexts(nullptr) { } @@ -126,9 +126,9 @@ void QQmlVMEGuard::clear() delete [] m_contexts; m_objectCount = 0; - m_objects = 0; + m_objects = nullptr; m_contextCount = 0; - m_contexts = 0; + m_contexts = nullptr; } bool QQmlVMEGuard::isOK() const diff --git a/src/qml/qml/qqmlvme_p.h b/src/qml/qml/qqmlvme_p.h index 99d63380ad..9a94ac6258 100644 --- a/src/qml/qml/qqmlvme_p.h +++ b/src/qml/qml/qqmlvme_p.h @@ -83,7 +83,7 @@ namespace QQmlVMETypes { struct State { enum Flag { Deferred = 0x00000001 }; - State() : flags(0), context(0), instructionStream(0) {} + State() : flags(0), context(nullptr), instructionStream(nullptr) {} quint32 flags; QQmlContextData *context; const char *instructionStream; @@ -143,7 +143,7 @@ private: }; QQmlInstantiationInterrupt::QQmlInstantiationInterrupt() - : mode(None), nsecs(0), runWhile(0) + : mode(None), nsecs(0), runWhile(nullptr) { } @@ -153,7 +153,7 @@ QQmlInstantiationInterrupt::QQmlInstantiationInterrupt(volatile bool *runWhile, } QQmlInstantiationInterrupt::QQmlInstantiationInterrupt(int nsecs) - : mode(Time), nsecs(nsecs), runWhile(0) + : mode(Time), nsecs(nsecs), runWhile(nullptr) { } diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp index 73cb20dc7f..c1d3980b58 100644 --- a/src/qml/qml/qqmlvmemetaobject.cpp +++ b/src/qml/qml/qqmlvmemetaobject.cpp @@ -64,7 +64,7 @@ static void list_append(QQmlListProperty *prop, QObject *o) { QList *list = static_cast *>(prop->data); list->append(o); - static_cast(prop->dummy1)->activate(prop->object, reinterpret_cast(prop->dummy2), 0); + static_cast(prop->dummy1)->activate(prop->object, reinterpret_cast(prop->dummy2), nullptr); } static int list_count(QQmlListProperty *prop) @@ -83,11 +83,11 @@ static void list_clear(QQmlListProperty *prop) { QList *list = static_cast *>(prop->data); list->clear(); - static_cast(prop->dummy1)->activate(prop->object, reinterpret_cast(prop->dummy2), 0); + static_cast(prop->dummy1)->activate(prop->object, reinterpret_cast(prop->dummy2), nullptr); } QQmlVMEVariantQObjectPtr::QQmlVMEVariantQObjectPtr() - : QQmlGuard(0), m_target(0), m_index(-1) + : QQmlGuard(nullptr), m_target(nullptr), m_index(-1) { } @@ -111,7 +111,7 @@ void QQmlVMEVariantQObjectPtr::objectDestroyed(QObject *) } } - m_target->activate(m_target->object, m_target->methodOffset() + m_index, 0); + m_target->activate(m_target->object, m_target->methodOffset() + m_index, nullptr); } } @@ -150,7 +150,7 @@ void QQmlVMEMetaObjectEndpoint::tryConnect() if (metaObject.flag()) { // This is actually notify int sigIdx = metaObject->methodOffset() + aliasId + metaObject->compiledObject->nProperties; - metaObject->activate(metaObject->object, sigIdx, 0); + metaObject->activate(metaObject->object, sigIdx, nullptr); } else { const QV4::CompiledData::Alias *aliasData = &metaObject->compiledObject->aliasTable()[aliasId]; if (!aliasData->isObjectAlias()) { @@ -179,7 +179,7 @@ void QQmlVMEMetaObjectEndpoint::tryConnect() QQmlInterceptorMetaObject::QQmlInterceptorMetaObject(QObject *obj, QQmlPropertyCache *cache) : object(obj), cache(cache), - interceptors(0), + interceptors(nullptr), hasAssignedMetaObjectData(false) { QObjectPrivate *op = QObjectPrivate::get(obj); @@ -320,7 +320,7 @@ QQmlVMEMetaObject::QQmlVMEMetaObject(QV4::ExecutionEngine *engine, : QQmlInterceptorMetaObject(obj, cache), engine(engine), ctxt(QQmlData::get(obj, true)->outerContext), - aliasEndpoints(0), compilationUnit(qmlCompilationUnit), compiledObject(0) + aliasEndpoints(nullptr), compilationUnit(qmlCompilationUnit), compiledObject(nullptr) { Q_ASSERT(engine); QQmlData::get(obj)->hasVMEMetaObject = true; @@ -358,7 +358,7 @@ QV4::MemberData *QQmlVMEMetaObject::propertyAndMethodStorageAsMemberData() const // such as the varProperties array) will have been cleaned up, but the // QObject ptr will not yet have been deleted (eg, waiting on deleteLater). // In this situation, return 0. - return 0; + return nullptr; } return static_cast(propertyAndMethodStorage.asManaged()); @@ -575,13 +575,13 @@ QObject* QQmlVMEMetaObject::readPropertyAsQObject(int id) const { QV4::MemberData *md = propertyAndMethodStorageAsMemberData(); if (!md) - return 0; + return nullptr; QV4::Scope scope(engine); QV4::ScopedValue sv(scope, *(md->data() + id)); const QV4::QObjectWrapper *wrapper = sv->as(); if (!wrapper) - return 0; + return nullptr; return wrapper->object(); } @@ -589,7 +589,7 @@ QList *QQmlVMEMetaObject::readPropertyAsList(int id) const { QV4::MemberData *md = propertyAndMethodStorageAsMemberData(); if (!md) - return 0; + return nullptr; QV4::Scope scope(engine); QV4::Scoped v(scope, *(md->data() + id)); @@ -643,7 +643,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); + QQmlEnginePrivate *ep = (ctxt == nullptr || ctxt->engine == nullptr) ? nullptr : QQmlEnginePrivate::get(ctxt->engine); if (ep) { if (c == QMetaObject::ReadProperty) { *reinterpret_cast(a[0]) = readPropertyAsVariant(id); @@ -836,7 +836,7 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void * } if (c == QMetaObject::WriteProperty && needActivate) { - activate(object, methodOffset() + id, 0); + activate(object, methodOffset() + id, nullptr); } return -1; @@ -848,7 +848,7 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void * const QV4::CompiledData::Alias *aliasData = &compiledObject->aliasTable()[id]; if ((aliasData->flags & QV4::CompiledData::Alias::AliasPointsToPointerObject) && c == QMetaObject::ReadProperty) - *reinterpret_cast(a[0]) = 0; + *reinterpret_cast(a[0]) = nullptr; if (!ctxt) return -1; @@ -899,7 +899,7 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void * int rv = QMetaObject::metacall(valueType, c, valueTypePropertyIndex, a); if (c == QMetaObject::WriteProperty) - valueType->write(target, coreIndex, 0x00); + valueType->write(target, coreIndex, nullptr); return rv; @@ -1037,7 +1037,7 @@ void QQmlVMEMetaObject::writeVarProperty(int id, const QV4::Value &value) if (oldVariant) oldVariant->removeVmePropertyReference(); - QObject *valueObject = 0; + QObject *valueObject = nullptr; QQmlVMEVariantQObjectPtr *guard = getQObjectGuardForProperty(id); // And, if the new value is a scarce resource, we need to ensure that it does not get @@ -1060,7 +1060,7 @@ void QQmlVMEMetaObject::writeVarProperty(int id, const QV4::Value &value) // Write the value and emit change signal as appropriate. md->set(engine, id, value); - activate(object, methodOffset() + id, 0); + activate(object, methodOffset() + id, nullptr); } void QQmlVMEMetaObject::writeProperty(int id, const QVariant &value) @@ -1088,7 +1088,7 @@ void QQmlVMEMetaObject::writeProperty(int id, const QVariant &value) QVariant currentValue = readPropertyAsVariant(id); md->set(engine, id, newv); if ((currentValue.userType() != value.userType() || currentValue != value)) - activate(object, methodOffset() + id, 0); + activate(object, methodOffset() + id, nullptr); } else { bool needActivate = false; if (value.userType() == QMetaType::QObjectStar) { @@ -1111,7 +1111,7 @@ void QQmlVMEMetaObject::writeProperty(int id, const QVariant &value) } if (needActivate) - activate(object, methodOffset() + id, 0); + activate(object, methodOffset() + id, nullptr); } } @@ -1187,7 +1187,7 @@ bool QQmlVMEMetaObject::aliasTarget(int index, QObject **target, int *coreIndex, { Q_ASSERT(compiledObject && (index >= propOffset() + int(compiledObject->nProperties))); - *target = 0; + *target = nullptr; *coreIndex = -1; *valueTypeIndex = -1; @@ -1289,7 +1289,7 @@ QQmlVMEVariantQObjectPtr *QQmlVMEMetaObject::getQObjectGuardForProperty(int inde } } - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/qml/qml/qqmlvmemetaobject_p.h b/src/qml/qml/qqmlvmemetaobject_p.h index 7881240452..46bff68327 100644 --- a/src/qml/qml/qqmlvmemetaobject_p.h +++ b/src/qml/qml/qqmlvmemetaobject_p.h @@ -112,7 +112,7 @@ public: if (it->m_propertyIndex == propertyIndex) return true; } - if (auto parentInterceptor = ((parent.isT1() && parent.flag()) ? static_cast(parent.asT1()) : 0)) + if (auto parentInterceptor = ((parent.isT1() && parent.flag()) ? static_cast(parent.asT1()) : nullptr)) return parentInterceptor->intercepts(propertyIndex); return false; } @@ -141,7 +141,7 @@ inline QQmlInterceptorMetaObject *QQmlInterceptorMetaObject::get(QObject *obj) } } - return 0; + return nullptr; } class QQmlVMEMetaObjectEndpoint; @@ -243,7 +243,7 @@ QQmlVMEMetaObject *QQmlVMEMetaObject::get(QObject *obj) } } - return 0; + return nullptr; } int QQmlVMEMetaObject::propOffset() const @@ -271,7 +271,7 @@ QQmlVMEMetaObject *QQmlVMEMetaObject::parentVMEMetaObject() const if (parent.isT1() && parent.flag()) return static_cast(parent.asT1()); - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 9c9e199a5b..5673acec89 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -116,7 +116,7 @@ class DocumentImpl; class NodeImpl { public: - NodeImpl() : type(Element), document(0), parent(0) {} + NodeImpl() : type(Element), document(nullptr), parent(nullptr) {} virtual ~NodeImpl() { qDeleteAll(children); qDeleteAll(attributes); @@ -157,7 +157,7 @@ public: class DocumentImpl : public QQmlRefCount, public NodeImpl { public: - DocumentImpl() : root(0) { type = Document; } + DocumentImpl() : root(nullptr) { type = Document; } virtual ~DocumentImpl() { delete root; } @@ -306,18 +306,18 @@ void Heap::NodePrototype::init() Scope scope(internalClass->engine); ScopedObject o(scope, this); - o->defineAccessorProperty(QStringLiteral("nodeName"), QV4::NodePrototype::method_get_nodeName, 0); - o->defineAccessorProperty(QStringLiteral("nodeValue"), QV4::NodePrototype::method_get_nodeValue, 0); - o->defineAccessorProperty(QStringLiteral("nodeType"), QV4::NodePrototype::method_get_nodeType, 0); - o->defineAccessorProperty(QStringLiteral("namespaceUri"), QV4::NodePrototype::method_get_namespaceUri, 0); + o->defineAccessorProperty(QStringLiteral("nodeName"), QV4::NodePrototype::method_get_nodeName, nullptr); + o->defineAccessorProperty(QStringLiteral("nodeValue"), QV4::NodePrototype::method_get_nodeValue, nullptr); + o->defineAccessorProperty(QStringLiteral("nodeType"), QV4::NodePrototype::method_get_nodeType, nullptr); + o->defineAccessorProperty(QStringLiteral("namespaceUri"), QV4::NodePrototype::method_get_namespaceUri, nullptr); - o->defineAccessorProperty(QStringLiteral("parentNode"), QV4::NodePrototype::method_get_parentNode, 0); - o->defineAccessorProperty(QStringLiteral("childNodes"), QV4::NodePrototype::method_get_childNodes, 0); - o->defineAccessorProperty(QStringLiteral("firstChild"), QV4::NodePrototype::method_get_firstChild, 0); - o->defineAccessorProperty(QStringLiteral("lastChild"), QV4::NodePrototype::method_get_lastChild, 0); - o->defineAccessorProperty(QStringLiteral("previousSibling"), QV4::NodePrototype::method_get_previousSibling, 0); - o->defineAccessorProperty(QStringLiteral("nextSibling"), QV4::NodePrototype::method_get_nextSibling, 0); - o->defineAccessorProperty(QStringLiteral("attributes"), QV4::NodePrototype::method_get_attributes, 0); + o->defineAccessorProperty(QStringLiteral("parentNode"), QV4::NodePrototype::method_get_parentNode, nullptr); + o->defineAccessorProperty(QStringLiteral("childNodes"), QV4::NodePrototype::method_get_childNodes, nullptr); + o->defineAccessorProperty(QStringLiteral("firstChild"), QV4::NodePrototype::method_get_firstChild, nullptr); + o->defineAccessorProperty(QStringLiteral("lastChild"), QV4::NodePrototype::method_get_lastChild, nullptr); + o->defineAccessorProperty(QStringLiteral("previousSibling"), QV4::NodePrototype::method_get_previousSibling, nullptr); + o->defineAccessorProperty(QStringLiteral("nextSibling"), QV4::NodePrototype::method_get_nextSibling, nullptr); + o->defineAccessorProperty(QStringLiteral("attributes"), QV4::NodePrototype::method_get_attributes, nullptr); } @@ -644,7 +644,7 @@ ReturnedValue Element::prototype(ExecutionEngine *engine) ScopedObject p(scope, engine->newObject()); ScopedObject pp(scope); p->setPrototype((pp = NodePrototype::getProto(engine))); - p->defineAccessorProperty(QStringLiteral("tagName"), NodePrototype::method_get_nodeName, 0); + p->defineAccessorProperty(QStringLiteral("tagName"), NodePrototype::method_get_nodeName, nullptr); d->elementPrototype.set(engine, p); engine->v8Engine->freezeObject(p); } @@ -659,9 +659,9 @@ ReturnedValue Attr::prototype(ExecutionEngine *engine) ScopedObject p(scope, engine->newObject()); ScopedObject pp(scope); p->setPrototype((pp = NodePrototype::getProto(engine))); - p->defineAccessorProperty(QStringLiteral("name"), method_name, 0); - p->defineAccessorProperty(QStringLiteral("value"), method_value, 0); - p->defineAccessorProperty(QStringLiteral("ownerElement"), method_ownerElement, 0); + p->defineAccessorProperty(QStringLiteral("name"), method_name, nullptr); + p->defineAccessorProperty(QStringLiteral("value"), method_value, nullptr); + p->defineAccessorProperty(QStringLiteral("ownerElement"), method_ownerElement, nullptr); d->attrPrototype.set(engine, p); engine->v8Engine->freezeObject(p); } @@ -716,8 +716,8 @@ ReturnedValue CharacterData::prototype(ExecutionEngine *v4) ScopedObject p(scope, v4->newObject()); ScopedObject pp(scope); p->setPrototype((pp = NodePrototype::getProto(v4))); - p->defineAccessorProperty(QStringLiteral("data"), NodePrototype::method_get_nodeValue, 0); - p->defineAccessorProperty(QStringLiteral("length"), method_length, 0); + p->defineAccessorProperty(QStringLiteral("data"), NodePrototype::method_get_nodeValue, nullptr); + p->defineAccessorProperty(QStringLiteral("length"), method_length, nullptr); d->characterDataPrototype.set(v4, p); v4->v8Engine->freezeObject(p); } @@ -752,8 +752,8 @@ ReturnedValue Text::prototype(ExecutionEngine *v4) ScopedObject p(scope, v4->newObject()); ScopedObject pp(scope); p->setPrototype((pp = CharacterData::prototype(v4))); - p->defineAccessorProperty(QStringLiteral("isElementContentWhitespace"), method_isElementContentWhitespace, 0); - p->defineAccessorProperty(QStringLiteral("wholeText"), method_wholeText, 0); + p->defineAccessorProperty(QStringLiteral("isElementContentWhitespace"), method_isElementContentWhitespace, nullptr); + p->defineAccessorProperty(QStringLiteral("wholeText"), method_wholeText, nullptr); d->textPrototype.set(v4, p); v4->v8Engine->freezeObject(p); } @@ -783,10 +783,10 @@ ReturnedValue Document::prototype(ExecutionEngine *v4) ScopedObject p(scope, v4->newObject()); ScopedObject pp(scope); p->setPrototype((pp = NodePrototype::getProto(v4))); - p->defineAccessorProperty(QStringLiteral("xmlVersion"), method_xmlVersion, 0); - p->defineAccessorProperty(QStringLiteral("xmlEncoding"), method_xmlEncoding, 0); - p->defineAccessorProperty(QStringLiteral("xmlStandalone"), method_xmlStandalone, 0); - p->defineAccessorProperty(QStringLiteral("documentElement"), method_documentElement, 0); + p->defineAccessorProperty(QStringLiteral("xmlVersion"), method_xmlVersion, nullptr); + p->defineAccessorProperty(QStringLiteral("xmlEncoding"), method_xmlEncoding, nullptr); + p->defineAccessorProperty(QStringLiteral("xmlStandalone"), method_xmlStandalone, nullptr); + p->defineAccessorProperty(QStringLiteral("documentElement"), method_documentElement, nullptr); d->documentPrototype.set(v4, p); v4->v8Engine->freezeObject(p); } @@ -797,7 +797,7 @@ ReturnedValue Document::load(ExecutionEngine *v4, const QByteArray &data) { Scope scope(v4); - DocumentImpl *document = 0; + DocumentImpl *document = nullptr; QStack nodeStack; QXmlStreamReader reader(data); @@ -885,7 +885,7 @@ ReturnedValue Document::load(ExecutionEngine *v4, const QByteArray &data) bool Node::isNull() const { - return d()->d == 0; + return d()->d == nullptr; } ReturnedValue NamedNodeMap::getIndexed(const Managed *m, uint index, bool *hasProperty) @@ -1098,7 +1098,7 @@ private: QQmlXMLHttpRequest::QQmlXMLHttpRequest(QNetworkAccessManager *manager) : m_state(Unsent), m_errorFlag(false), m_sendFlag(false) - , m_redirectCount(0), m_gotXml(false), m_textCodec(0), m_network(0), m_nam(manager) + , m_redirectCount(0), m_gotXml(false), m_textCodec(nullptr), m_network(nullptr), m_nam(manager) , m_responseType() , m_parsedDocument() { @@ -1443,7 +1443,7 @@ void QQmlXMLHttpRequest::finished() dispatchCallback(); m_thisObject.clear(); - m_qmlContext.setContextData(0); + m_qmlContext.setContextData(nullptr); } @@ -1516,7 +1516,7 @@ QV4::ReturnedValue QQmlXMLHttpRequest::xmlResponseBody(QV4::ExecutionEngine* eng #if QT_CONFIG(textcodec) QTextCodec* QQmlXMLHttpRequest::findTextCodec() const { - QTextCodec *codec = 0; + QTextCodec *codec = nullptr; if (!m_charset.isEmpty()) codec = QTextCodec::codecForName(m_charset); @@ -1528,10 +1528,10 @@ QTextCodec* QQmlXMLHttpRequest::findTextCodec() const } if (!codec && m_mime == "text/html") - codec = QTextCodec::codecForHtml(m_responseEntityBody, 0); + codec = QTextCodec::codecForHtml(m_responseEntityBody, nullptr); if (!codec) - codec = QTextCodec::codecForUtfText(m_responseEntityBody, 0); + codec = QTextCodec::codecForUtfText(m_responseEntityBody, nullptr); if (!codec) codec = QTextCodec::codecForName("UTF-8"); @@ -1595,7 +1595,7 @@ void QQmlXMLHttpRequest::destroyNetwork() if (m_network) { m_network->disconnect(); m_network->deleteLater(); - m_network = 0; + m_network = nullptr; } } @@ -1709,12 +1709,12 @@ void QQmlXMLHttpRequestCtor::setupProto() p->defineDefaultProperty(QStringLiteral("getAllResponseHeaders"), method_getAllResponseHeaders); // Read-only properties - p->defineAccessorProperty(QStringLiteral("readyState"), method_get_readyState, 0); - p->defineAccessorProperty(QStringLiteral("status"),method_get_status, 0); - p->defineAccessorProperty(QStringLiteral("statusText"),method_get_statusText, 0); - p->defineAccessorProperty(QStringLiteral("responseText"),method_get_responseText, 0); - p->defineAccessorProperty(QStringLiteral("responseXML"),method_get_responseXML, 0); - p->defineAccessorProperty(QStringLiteral("response"),method_get_response, 0); + p->defineAccessorProperty(QStringLiteral("readyState"), method_get_readyState, nullptr); + p->defineAccessorProperty(QStringLiteral("status"),method_get_status, nullptr); + p->defineAccessorProperty(QStringLiteral("statusText"),method_get_statusText, nullptr); + p->defineAccessorProperty(QStringLiteral("responseText"),method_get_responseText, nullptr); + p->defineAccessorProperty(QStringLiteral("responseXML"),method_get_responseXML, nullptr); + p->defineAccessorProperty(QStringLiteral("response"),method_get_response, nullptr); // Read-write properties p->defineAccessorProperty(QStringLiteral("responseType"), method_get_responseType, method_set_responseType); diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 44ad174f37..c147feeb73 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -151,10 +151,10 @@ void Heap::QtObject::init(QQmlEngine *qmlEngine) o->defineDefaultProperty(QStringLiteral("createComponent"), QV4::QtObject::method_createComponent); } - o->defineAccessorProperty(QStringLiteral("platform"), QV4::QtObject::method_get_platform, 0); - o->defineAccessorProperty(QStringLiteral("application"), QV4::QtObject::method_get_application, 0); - o->defineAccessorProperty(QStringLiteral("inputMethod"), QV4::QtObject::method_get_inputMethod, 0); - o->defineAccessorProperty(QStringLiteral("styleHints"), QV4::QtObject::method_get_styleHints, 0); + o->defineAccessorProperty(QStringLiteral("platform"), QV4::QtObject::method_get_platform, nullptr); + o->defineAccessorProperty(QStringLiteral("application"), QV4::QtObject::method_get_application, nullptr); + o->defineAccessorProperty(QStringLiteral("inputMethod"), QV4::QtObject::method_get_inputMethod, nullptr); + o->defineAccessorProperty(QStringLiteral("styleHints"), QV4::QtObject::method_get_styleHints, nullptr); o->defineDefaultProperty(QStringLiteral("callLater"), QV4::QtObject::method_callLater); } @@ -233,7 +233,7 @@ ReturnedValue QtObject::method_isQtObject(const FunctionObject *, const Value *, if (argc == 0) RETURN_RESULT(QV4::Encode(false)); - return QV4::Encode(argv[0].as() != 0); + return QV4::Encode(argv[0].as() != nullptr); } /*! @@ -948,7 +948,7 @@ ReturnedValue QtObject::method_resolvedUrl(const FunctionObject *b, const Value QUrl url = scope.engine->toVariant(argv[0], -1).toUrl(); QQmlEngine *e = scope.engine->qmlEngine(); - QQmlEnginePrivate *p = 0; + QQmlEnginePrivate *p = nullptr; if (e) p = QQmlEnginePrivate::get(e); if (p) { QQmlContextData *ctxt = scope.engine->callingQmlContext(); @@ -1120,7 +1120,7 @@ ReturnedValue QtObject::method_createQmlObject(const FunctionObject *b, const Va QQmlContextData *context = scope.engine->callingQmlContext(); Q_ASSERT(context); - QQmlContext *effectiveContext = 0; + QQmlContext *effectiveContext = nullptr; if (context->isPragmaLibraryContext) effectiveContext = engine->rootContext(); else @@ -1140,7 +1140,7 @@ ReturnedValue QtObject::method_createQmlObject(const FunctionObject *b, const Va if (url.isValid() && url.isRelative()) url = context->resolvedUrl(url); - QObject *parentArg = 0; + QObject *parentArg = nullptr; QV4::Scoped qobjectWrapper(scope, argv[1]); if (!!qobjectWrapper) parentArg = qobjectWrapper->object(); @@ -1249,14 +1249,14 @@ ReturnedValue QtObject::method_createComponent(const FunctionObject *b, const Va Q_ASSERT(context); QQmlContextData *effectiveContext = context; if (context->isPragmaLibraryContext) - effectiveContext = 0; + effectiveContext = nullptr; QString arg = argv[0].toQStringNoThrow(); if (arg.isEmpty()) RETURN_RESULT(QV4::Encode::null()); QQmlComponent::CompilationMode compileMode = QQmlComponent::PreferSynchronous; - QObject *parentArg = 0; + QObject *parentArg = nullptr; int consumedCount = 1; if (argc > 1) { @@ -1283,7 +1283,7 @@ ReturnedValue QtObject::method_createComponent(const FunctionObject *b, const Va if (!parentArg) THROW_GENERIC_ERROR("Qt.createComponent(): Invalid parent object"); } else if (lastArg->isNull()) { - parentArg = 0; + parentArg = nullptr; } else { THROW_GENERIC_ERROR("Qt.createComponent(): Invalid parent object"); } @@ -1514,7 +1514,7 @@ static QString jsStack(QV4::ExecutionEngine *engine) { static ReturnedValue writeToConsole(const FunctionObject *b, const Value *, const Value *argv, int argc, ConsoleLogTypes logType, bool printStack = false) { - QLoggingCategory *loggingCategory = 0; + QLoggingCategory *loggingCategory = nullptr; QString result; QV4::Scope scope(b); QV4::ExecutionEngine *v4 = scope.engine; diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp index 2bf623f144..038a75d50a 100644 --- a/src/qml/qml/v8/qv8engine.cpp +++ b/src/qml/qml/v8/qv8engine.cpp @@ -125,9 +125,9 @@ static void restoreJSValue(QDataStream &stream, void *data) QV8Engine::QV8Engine(QJSEngine *qq, QV4::ExecutionEngine *v4) : q(qq) - , m_engine(0) + , m_engine(nullptr) , m_v4Engine(v4) - , m_xmlHttpRequestData(0) + , m_xmlHttpRequestData(nullptr) { #ifdef Q_PROCESSOR_X86_32 if (!qCpuHasFeature(SSE2)) { @@ -159,7 +159,7 @@ QV8Engine::~QV8Engine() #if QT_CONFIG(xmlstreamreader) && QT_CONFIG(qml_network) qt_rem_qmlxmlhttprequest(m_v4Engine, m_xmlHttpRequestData); - m_xmlHttpRequestData = 0; + m_xmlHttpRequestData = nullptr; #endif } diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h index eb2b8b474c..b6a378667e 100644 --- a/src/qml/qml/v8/qv8engine_p.h +++ b/src/qml/qml/v8/qv8engine_p.h @@ -230,7 +230,7 @@ inline QV8Engine::Deletable *QV8Engine::extensionData(int index) const if (index < m_extensionData.count()) return m_extensionData[index]; else - return 0; + return nullptr; } -- cgit v1.2.3 From 06e962f263a86c4b66e1c6195b3d2615695fea1e Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 21 Feb 2018 11:52:59 +0100 Subject: init variables where they are declared when possible (clang-tidy) clang-tidy -p compile_commands.json $file -checks='-*,modernize-use-default-member-init,readability-redundant-member-init' -config='{CheckOptions: [{key: modernize-use-default-member-init.UseAssignment, value: "1"}]}' -header-filter='qtdeclarative' -fix Change-Id: I705f3235ff129ba68b0d8dad54a083e29fcead5f Reviewed-by: Johan Helsing --- src/qml/qml/ftw/qflagpointer_p.h | 6 +-- src/qml/qml/ftw/qhashedstring_p.h | 55 +++++++++++------------- src/qml/qml/ftw/qintrusivelist_p.h | 9 ++-- src/qml/qml/ftw/qqmlnullablevalue_p.h | 4 +- src/qml/qml/qqmlabstractbinding_p.h | 4 +- src/qml/qml/qqmlboundsignalexpressionpointer_p.h | 4 +- src/qml/qml/qqmldirparser_p.h | 18 ++++---- src/qml/qml/qqmlglobal_p.h | 6 +-- src/qml/qml/qqmlguard_p.h | 11 +++-- src/qml/qml/qqmllist.h | 30 +++++-------- src/qml/qml/qqmlnotifier_p.h | 3 +- src/qml/qml/qqmlpropertycache_p.h | 4 +- 12 files changed, 66 insertions(+), 88 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/ftw/qflagpointer_p.h b/src/qml/qml/ftw/qflagpointer_p.h index 6954a8f09c..91ce74bec9 100644 --- a/src/qml/qml/ftw/qflagpointer_p.h +++ b/src/qml/qml/ftw/qflagpointer_p.h @@ -83,7 +83,7 @@ public: inline T *data() const; private: - quintptr ptr_value; + quintptr ptr_value = 0; static const quintptr FlagBit = 0x1; static const quintptr Flag2Bit = 0x2; @@ -115,7 +115,7 @@ public: inline T2 *asT2() const; private: - quintptr ptr_value; + quintptr ptr_value = 0; static const quintptr FlagBit = 0x1; static const quintptr Flag2Bit = 0x2; @@ -124,7 +124,6 @@ private: template QFlagPointer::QFlagPointer() -: ptr_value(0) { } @@ -233,7 +232,6 @@ T *QFlagPointer::data() const template QBiPointer::QBiPointer() -: ptr_value(0) { } diff --git a/src/qml/qml/ftw/qhashedstring_p.h b/src/qml/qml/ftw/qhashedstring_p.h index bd2c9fbdb7..2d6c25bdd3 100644 --- a/src/qml/qml/ftw/qhashedstring_p.h +++ b/src/qml/qml/ftw/qhashedstring_p.h @@ -94,7 +94,7 @@ private: friend class QStringHashNode; inline void computeHash() const; - mutable quint32 m_hash; + mutable quint32 m_hash = 0; }; class QHashedCStringRef; @@ -142,9 +142,9 @@ private: inline void computeHash() const; - const QChar *m_data; - int m_length; - mutable quint32 m_hash; + const QChar *m_data = nullptr; + int m_length = 0; + mutable quint32 m_hash = 0; }; class Q_AUTOTEST_EXPORT QHashedCStringRef @@ -169,9 +169,9 @@ private: inline void computeHash() const; - const char *m_data; - int m_length; - mutable quint32 m_hash; + const char *m_data = nullptr; + int m_length = 0; + mutable quint32 m_hash = 0; }; class QStringHashData; @@ -179,7 +179,7 @@ class Q_AUTOTEST_EXPORT QStringHashNode { public: QStringHashNode() - : length(0), hash(0), symbolId(0), ckey(nullptr) + : ckey(nullptr) { } @@ -210,9 +210,9 @@ public: QFlagPointer next; - qint32 length; - quint32 hash; - quint32 symbolId; + qint32 length = 0; + quint32 hash = 0; + quint32 symbolId = 0; union { const char *ckey; @@ -276,25 +276,20 @@ public: class Q_AUTOTEST_EXPORT QStringHashData { public: - QStringHashData() - : buckets(nullptr), numBuckets(0), size(0), numBits(0) -#ifdef QSTRINGHASH_LINK_DEBUG - , linkCount(0) -#endif - {} + QStringHashData() {} - QStringHashNode **buckets; - int numBuckets; - int size; - short numBits; + QStringHashNode **buckets = nullptr; + int numBuckets = 0; + int size = 0; + short numBits = 0; #ifdef QSTRINGHASH_LINK_DEBUG - int linkCount; + int linkCount = 0; #endif struct IteratorData { - IteratorData() : n(nullptr), p(nullptr) {} - QStringHashNode *n; - void *p; + IteratorData() {} + QStringHashNode *n = nullptr; + void *p = nullptr; }; void rehashToBits(short); void rehashToSize(int); @@ -369,10 +364,10 @@ public: }; struct ReservedNodePool { - ReservedNodePool() : count(0), used(0), nodes(nullptr) {} + ReservedNodePool() : nodes(nullptr) {} ~ReservedNodePool() { delete [] nodes; } - int count; - int used; + int count = 0; + int used = 0; Node *nodes; }; @@ -1038,7 +1033,7 @@ inline uint qHash(const QHashedStringRef &string) } QHashedString::QHashedString() -: QString(), m_hash(0) +: QString() { } @@ -1089,7 +1084,6 @@ quint32 QHashedString::existingHash() const } QHashedStringRef::QHashedStringRef() -: m_data(nullptr), m_length(0), m_hash(0) { } @@ -1236,7 +1230,6 @@ quint32 QHashedStringRef::hash() const } QHashedCStringRef::QHashedCStringRef() -: m_data(nullptr), m_length(0), m_hash(0) { } diff --git a/src/qml/qml/ftw/qintrusivelist_p.h b/src/qml/qml/ftw/qintrusivelist_p.h index c3b16f5b8c..8992be9f93 100644 --- a/src/qml/qml/ftw/qintrusivelist_p.h +++ b/src/qml/qml/ftw/qintrusivelist_p.h @@ -95,7 +95,7 @@ public: private: static inline N *nodeToN(QIntrusiveListNode *node); - QIntrusiveListNode *__first; + QIntrusiveListNode *__first = nullptr; }; class QIntrusiveListNode @@ -107,8 +107,8 @@ public: inline void remove(); inline bool isInList() const; - QIntrusiveListNode *_next; - QIntrusiveListNode**_prev; + QIntrusiveListNode *_next = nullptr; + QIntrusiveListNode**_prev = nullptr; }; template @@ -165,7 +165,7 @@ typename QIntrusiveList::iterator &QIntrusiveList::iterato template QIntrusiveList::QIntrusiveList() -: __first(nullptr) + { } @@ -245,7 +245,6 @@ N *QIntrusiveList::nodeToN(QIntrusiveListNode *node) } QIntrusiveListNode::QIntrusiveListNode() -: _next(nullptr), _prev(nullptr) { } diff --git a/src/qml/qml/ftw/qqmlnullablevalue_p.h b/src/qml/qml/ftw/qqmlnullablevalue_p.h index 7a9e4d7b8a..5b3d2fc456 100644 --- a/src/qml/qml/ftw/qqmlnullablevalue_p.h +++ b/src/qml/qml/ftw/qqmlnullablevalue_p.h @@ -57,7 +57,7 @@ template struct QQmlNullableValue { QQmlNullableValue() - : isNull(true), value(T()) {} + : value(T()) {} QQmlNullableValue(const QQmlNullableValue &o) : isNull(o.isNull), value(o.value) {} QQmlNullableValue(const T &t) @@ -70,7 +70,7 @@ struct QQmlNullableValue void invalidate() { isNull = true; } bool isValid() const { return !isNull; } - bool isNull; + bool isNull = true; T value; }; diff --git a/src/qml/qml/qqmlabstractbinding_p.h b/src/qml/qml/qqmlabstractbinding_p.h index bea2d253e4..fc53be3e7b 100644 --- a/src/qml/qml/qqmlabstractbinding_p.h +++ b/src/qml/qml/qqmlabstractbinding_p.h @@ -95,8 +95,8 @@ public: { return m_nextBinding.flag2(); } struct RefCount { - RefCount() : refCount(0) {} - int refCount; + RefCount() {} + int refCount = 0; void ref() { ++refCount; } int deref() { return --refCount; } operator int() const { return refCount; } diff --git a/src/qml/qml/qqmlboundsignalexpressionpointer_p.h b/src/qml/qml/qqmlboundsignalexpressionpointer_p.h index 685e0160a3..eabe6666b4 100644 --- a/src/qml/qml/qqmlboundsignalexpressionpointer_p.h +++ b/src/qml/qml/qqmlboundsignalexpressionpointer_p.h @@ -58,7 +58,7 @@ class QQmlBoundSignalExpression; class Q_QML_PRIVATE_EXPORT QQmlBoundSignalExpressionPointer { public: - inline QQmlBoundSignalExpressionPointer() : o(nullptr) {} + inline QQmlBoundSignalExpressionPointer() {} QQmlBoundSignalExpressionPointer(QQmlBoundSignalExpression *); QQmlBoundSignalExpressionPointer(const QQmlBoundSignalExpressionPointer &); ~QQmlBoundSignalExpressionPointer(); @@ -73,7 +73,7 @@ public: QQmlBoundSignalExpressionPointer &take(QQmlBoundSignalExpression *); private: - QQmlBoundSignalExpression *o; + QQmlBoundSignalExpression *o = nullptr; }; QT_END_NAMESPACE diff --git a/src/qml/qml/qqmldirparser_p.h b/src/qml/qml/qqmldirparser_p.h index 1530b7a6cf..95370398ad 100644 --- a/src/qml/qml/qqmldirparser_p.h +++ b/src/qml/qml/qqmldirparser_p.h @@ -91,8 +91,7 @@ public: struct Component { - Component() - : majorVersion(0), minorVersion(0), internal(false), singleton(false) {} + Component() {} Component(const QString &typeName, const QString &fileName, int majorVersion, int minorVersion) : typeName(typeName), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion), @@ -100,24 +99,23 @@ public: QString typeName; QString fileName; - int majorVersion; - int minorVersion; - bool internal; - bool singleton; + int majorVersion = 0; + int minorVersion = 0; + bool internal = false; + bool singleton = false; }; struct Script { - Script() - : majorVersion(0), minorVersion(0) {} + Script() {} Script(const QString &nameSpace, const QString &fileName, int majorVersion, int minorVersion) : nameSpace(nameSpace), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion) {} QString nameSpace; QString fileName; - int majorVersion; - int minorVersion; + int majorVersion = 0; + int minorVersion = 0; }; QHash components() const; diff --git a/src/qml/qml/qqmlglobal_p.h b/src/qml/qml/qqmlglobal_p.h index 53f5dbed02..302fdd56c4 100644 --- a/src/qml/qml/qqmlglobal_p.h +++ b/src/qml/qml/qqmlglobal_p.h @@ -368,12 +368,12 @@ public: struct QQmlSourceLocation { - QQmlSourceLocation() : line(0), column(0) {} + QQmlSourceLocation() {} QQmlSourceLocation(const QString &sourceFile, quint16 line, quint16 column) : sourceFile(sourceFile), line(line), column(column) {} QString sourceFile; - quint16 line; - quint16 column; + quint16 line = 0; + quint16 column = 0; }; QT_END_NAMESPACE diff --git a/src/qml/qml/qqmlguard_p.h b/src/qml/qml/qqmlguard_p.h index 87c3677d29..808bf4c709 100644 --- a/src/qml/qml/qqmlguard_p.h +++ b/src/qml/qml/qqmlguard_p.h @@ -65,9 +65,9 @@ public: inline QQmlGuardImpl(const QQmlGuardImpl &); inline ~QQmlGuardImpl(); - QObject *o; - QQmlGuardImpl *next; - QQmlGuardImpl **prev; + QObject *o = nullptr; + QQmlGuardImpl *next = nullptr; + QQmlGuardImpl **prev = nullptr; inline void addGuard(); inline void remGuard(); @@ -113,18 +113,17 @@ Q_DECLARE_METATYPE(QQmlGuard) QT_BEGIN_NAMESPACE QQmlGuardImpl::QQmlGuardImpl() -: o(nullptr), next(nullptr), prev(nullptr) { } QQmlGuardImpl::QQmlGuardImpl(QObject *g) -: o(g), next(nullptr), prev(nullptr) +: o(g) { if (o) addGuard(); } QQmlGuardImpl::QQmlGuardImpl(const QQmlGuardImpl &g) -: o(g.o), next(nullptr), prev(nullptr) +: o(g.o) { if (o) addGuard(); } diff --git a/src/qml/qml/qqmllist.h b/src/qml/qml/qqmllist.h index 4c6ae0cb8f..90ec57c911 100644 --- a/src/qml/qml/qqmllist.h +++ b/src/qml/qml/qqmllist.h @@ -61,20 +61,15 @@ public: typedef void (*ClearFunction)(QQmlListProperty *); QQmlListProperty() - : object(nullptr), - data(nullptr), - append(nullptr), + : append(nullptr), count(nullptr), at(nullptr), - clear(nullptr), - dummy1(nullptr), - dummy2(nullptr) + clear(nullptr) {} QQmlListProperty(QObject *o, QList &list) : object(o), data(&list), append(qlist_append), count(qlist_count), at(qlist_at), - clear(qlist_clear), - dummy1(nullptr), - dummy2(nullptr) + clear(qlist_clear) + {} QQmlListProperty(QObject *o, void *d, AppendFunction a, CountFunction c, AtFunction t, ClearFunction r ) @@ -83,18 +78,15 @@ public: append(a), count(c), at(t), - clear(r), - dummy1(nullptr), - dummy2(nullptr) + clear(r) + {} QQmlListProperty(QObject *o, void *d, CountFunction c, AtFunction t) : object(o), data(d), append(nullptr), count(c), at(t), - clear(nullptr), - dummy1(nullptr), - dummy2(nullptr) + clear(nullptr) {} bool operator==(const QQmlListProperty &o) const { return object == o.object && @@ -105,8 +97,8 @@ public: clear == o.clear; } - QObject *object; - void *data; + QObject *object = nullptr; + void *data = nullptr; AppendFunction append; @@ -115,8 +107,8 @@ public: ClearFunction clear; - void *dummy1; - void *dummy2; + void *dummy1 = nullptr; + void *dummy2 = nullptr; private: static void qlist_append(QQmlListProperty *p, T *v) { diff --git a/src/qml/qml/qqmlnotifier_p.h b/src/qml/qml/qqmlnotifier_p.h index 39761875bf..d77e314de5 100644 --- a/src/qml/qml/qqmlnotifier_p.h +++ b/src/qml/qml/qqmlnotifier_p.h @@ -73,7 +73,7 @@ private: friend class QQmlThreadNotifierProxyObject; static void emitNotify(QQmlNotifierEndpoint *, void **a); - QQmlNotifierEndpoint *endpoints; + QQmlNotifierEndpoint *endpoints = nullptr; }; class QQmlEngine; @@ -129,7 +129,6 @@ private: }; QQmlNotifier::QQmlNotifier() -: endpoints(nullptr) { } diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h index 22be6ba60c..7b04ba11b8 100644 --- a/src/qml/qml/qqmlpropertycache_p.h +++ b/src/qml/qml/qqmlpropertycache_p.h @@ -376,10 +376,10 @@ private: struct QQmlEnumValue { - QQmlEnumValue() : value(-1) {} + QQmlEnumValue() {} QQmlEnumValue(const QString &n, int v) : namedValue(n), value(v) {} QString namedValue; - int value; + int value = -1; }; struct QQmlEnumData -- cgit v1.2.3 From 3aa73dc00b25aa0c1b85b8b7809a0fd8ad3617a7 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 26 Feb 2018 14:27:19 +0100 Subject: Remove unused testing code The helper function added in commit 2659c308792967322564b5088e0e21bb371e0283 is not needed - it was added by accident. Change-Id: I29c3cd31f726a46a24a056b27173e96a112eb8a6 Reviewed-by: Michael Brasser --- src/qml/qml/qqmlvmemetaobject_p.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlvmemetaobject_p.h b/src/qml/qml/qqmlvmemetaobject_p.h index 46bff68327..1da79b8a81 100644 --- a/src/qml/qml/qqmlvmemetaobject_p.h +++ b/src/qml/qml/qqmlvmemetaobject_p.h @@ -117,8 +117,6 @@ public: return false; } - // use by tst_qqmllanguage - QQmlPropertyValueInterceptor *firstInterceptor() const { return interceptors; } protected: int metaCall(QObject *o, QMetaObject::Call c, int id, void **a) override; bool intercept(QMetaObject::Call c, int id, void **a); -- cgit v1.2.3 From e17c89f4ce74e5699ed50dc2187a39d8990316c4 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 26 Feb 2018 17:34:27 +0100 Subject: use the override keyword consistently and correctly (clang-tidy) Change-Id: If9e28d143f8cba3df3c757476b4f2265e2eb8b2a Reviewed-by: Johan Helsing --- src/qml/qml/qqmlapplicationengine.h | 2 +- src/qml/qml/qqmlbinding_p.h | 2 +- src/qml/qml/qqmlboundsignal_p.h | 2 +- src/qml/qml/qqmlcomponent.h | 2 +- src/qml/qml/qqmlcontext.h | 2 +- src/qml/qml/qqmldelayedcallqueue_p.h | 2 +- src/qml/qml/qqmlengine.h | 2 +- src/qml/qml/qqmlengine_p.h | 4 ++-- src/qml/qml/qqmlexpression.h | 2 +- src/qml/qml/qqmlexpression_p.h | 2 +- src/qml/qml/qqmlextensioninterface.h | 2 +- src/qml/qml/qqmlextensionplugin.h | 2 +- src/qml/qml/qqmlfileselector.h | 2 +- src/qml/qml/qqmlopenmetaobject_p.h | 4 ++-- src/qml/qml/qqmlprivate.h | 2 +- src/qml/qml/qqmlpropertycache_p.h | 2 +- src/qml/qml/qqmltypeloader_p.h | 10 +++++----- src/qml/qml/qqmltypenamecache_p.h | 2 +- src/qml/qml/qqmlvaluetype_p.h | 2 +- src/qml/qml/qqmlvmemetaobject_p.h | 6 +++--- 20 files changed, 28 insertions(+), 28 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlapplicationengine.h b/src/qml/qml/qqmlapplicationengine.h index d0f9e6d319..bb5d6b5d68 100644 --- a/src/qml/qml/qqmlapplicationengine.h +++ b/src/qml/qml/qqmlapplicationengine.h @@ -56,7 +56,7 @@ public: QQmlApplicationEngine(QObject *parent = nullptr); QQmlApplicationEngine(const QUrl &url, QObject *parent = nullptr); QQmlApplicationEngine(const QString &filePath, QObject *parent = nullptr); - ~QQmlApplicationEngine(); + ~QQmlApplicationEngine() override; #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QList rootObjects(); // ### Qt 6: remove diff --git a/src/qml/qml/qqmlbinding_p.h b/src/qml/qml/qqmlbinding_p.h index 8bc9554a42..19ec3f5d4f 100644 --- a/src/qml/qml/qqmlbinding_p.h +++ b/src/qml/qml/qqmlbinding_p.h @@ -79,7 +79,7 @@ public: QObject *obj, QQmlContextData *ctxt, QV4::ExecutionContext *scope); static QQmlBinding *createTranslationBinding(QV4::CompiledData::CompilationUnit *unit, const QV4::CompiledData::Binding *binding, QObject *obj, QQmlContextData *ctxt); - ~QQmlBinding(); + ~QQmlBinding() override; void setTarget(const QQmlProperty &); void setTarget(QObject *, const QQmlPropertyData &, const QQmlPropertyData *valueType); diff --git a/src/qml/qml/qqmlboundsignal_p.h b/src/qml/qml/qqmlboundsignal_p.h index d3e584fd13..01094a11f7 100644 --- a/src/qml/qml/qqmlboundsignal_p.h +++ b/src/qml/qml/qqmlboundsignal_p.h @@ -92,7 +92,7 @@ public: QQmlEngine *engine() const { return context() ? context()->engine : nullptr; } private: - ~QQmlBoundSignalExpression(); + ~QQmlBoundSignalExpression() override; void init(QQmlContextData *ctxt, QObject *scope); diff --git a/src/qml/qml/qqmlcomponent.h b/src/qml/qml/qqmlcomponent.h index b8cc556e4a..444b3ec46c 100644 --- a/src/qml/qml/qqmlcomponent.h +++ b/src/qml/qml/qqmlcomponent.h @@ -83,7 +83,7 @@ public: QQmlComponent(QQmlEngine *, const QString &fileName, CompilationMode mode, QObject *parent = nullptr); QQmlComponent(QQmlEngine *, const QUrl &url, QObject *parent = nullptr); QQmlComponent(QQmlEngine *, const QUrl &url, CompilationMode mode, QObject *parent = nullptr); - virtual ~QQmlComponent(); + ~QQmlComponent() override; enum Status { Null, Ready, Loading, Error }; Q_ENUM(Status) diff --git a/src/qml/qml/qqmlcontext.h b/src/qml/qml/qqmlcontext.h index 506ae216b2..7ed70c7619 100644 --- a/src/qml/qml/qqmlcontext.h +++ b/src/qml/qml/qqmlcontext.h @@ -68,7 +68,7 @@ public: QQmlContext(QQmlEngine *parent, QObject *objParent = nullptr); QQmlContext(QQmlContext *parent, QObject *objParent = nullptr); - virtual ~QQmlContext(); + ~QQmlContext() override; bool isValid() const; diff --git a/src/qml/qml/qqmldelayedcallqueue_p.h b/src/qml/qml/qqmldelayedcallqueue_p.h index 47e211829c..7962318561 100644 --- a/src/qml/qml/qqmldelayedcallqueue_p.h +++ b/src/qml/qml/qqmldelayedcallqueue_p.h @@ -65,7 +65,7 @@ class QQmlDelayedCallQueue : public QObject Q_OBJECT public: QQmlDelayedCallQueue(); - ~QQmlDelayedCallQueue(); + ~QQmlDelayedCallQueue() override; void init(QV4::ExecutionEngine *); diff --git a/src/qml/qml/qqmlengine.h b/src/qml/qml/qqmlengine.h index 937920e191..73ad2754c8 100644 --- a/src/qml/qml/qqmlengine.h +++ b/src/qml/qml/qqmlengine.h @@ -97,7 +97,7 @@ class Q_QML_EXPORT QQmlEngine : public QJSEngine Q_OBJECT public: explicit QQmlEngine(QObject *p = nullptr); - virtual ~QQmlEngine(); + ~QQmlEngine() override; QQmlContext *rootContext() const; diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h index 2dfbd42e57..d6110c6699 100644 --- a/src/qml/qml/qqmlengine_p.h +++ b/src/qml/qml/qqmlengine_p.h @@ -122,7 +122,7 @@ class Q_QML_PRIVATE_EXPORT QQmlEnginePrivate : public QJSEnginePrivate Q_DECLARE_PUBLIC(QQmlEngine) public: QQmlEnginePrivate(QQmlEngine *); - ~QQmlEnginePrivate(); + ~QQmlEnginePrivate() override; void init(); // No mutex protecting baseModulesUninitialized, because use outside QQmlEngine @@ -341,7 +341,7 @@ void QQmlEnginePrivate::deleteInEngineThread(T *value) } else { struct I : public Deletable { I(T *value) : value(value) {} - ~I() { delete value; } + ~I() override { delete value; } T *value; }; I *i = new I(value); diff --git a/src/qml/qml/qqmlexpression.h b/src/qml/qml/qqmlexpression.h index e9c8770e92..0eceeb12e1 100644 --- a/src/qml/qml/qqmlexpression.h +++ b/src/qml/qml/qqmlexpression.h @@ -62,7 +62,7 @@ public: QQmlExpression(); QQmlExpression(QQmlContext *, QObject *, const QString &, QObject * = nullptr); explicit QQmlExpression(const QQmlScriptString &, QQmlContext * = nullptr, QObject * = nullptr, QObject * = nullptr); - virtual ~QQmlExpression(); + ~QQmlExpression() override; QQmlEngine *engine() const; QQmlContext *context() const; diff --git a/src/qml/qml/qqmlexpression_p.h b/src/qml/qml/qqmlexpression_p.h index 55059575e1..da10b31b2c 100644 --- a/src/qml/qml/qqmlexpression_p.h +++ b/src/qml/qml/qqmlexpression_p.h @@ -68,7 +68,7 @@ class QQmlExpressionPrivate : public QObjectPrivate, Q_DECLARE_PUBLIC(QQmlExpression) public: QQmlExpressionPrivate(); - ~QQmlExpressionPrivate(); + ~QQmlExpressionPrivate() override; void init(QQmlContextData *, const QString &, QObject *); void init(QQmlContextData *, QV4::Function *runtimeFunction, QObject *); diff --git a/src/qml/qml/qqmlextensioninterface.h b/src/qml/qml/qqmlextensioninterface.h index 62b9b26569..c2d20ef0a3 100644 --- a/src/qml/qml/qqmlextensioninterface.h +++ b/src/qml/qml/qqmlextensioninterface.h @@ -58,7 +58,7 @@ public: class Q_QML_EXPORT QQmlExtensionInterface : public QQmlTypesExtensionInterface { public: - virtual ~QQmlExtensionInterface() {} + ~QQmlExtensionInterface() override {} virtual void initializeEngine(QQmlEngine *engine, const char *uri) = 0; }; diff --git a/src/qml/qml/qqmlextensionplugin.h b/src/qml/qml/qqmlextensionplugin.h index 84a46fb93e..55e9b89dae 100644 --- a/src/qml/qml/qqmlextensionplugin.h +++ b/src/qml/qml/qqmlextensionplugin.h @@ -59,7 +59,7 @@ class Q_QML_EXPORT QQmlExtensionPlugin Q_INTERFACES(QQmlTypesExtensionInterface) public: explicit QQmlExtensionPlugin(QObject *parent = nullptr); - ~QQmlExtensionPlugin(); + ~QQmlExtensionPlugin() override; QUrl baseUrl() const; diff --git a/src/qml/qml/qqmlfileselector.h b/src/qml/qml/qqmlfileselector.h index 4eaf92c918..9b70e3936d 100644 --- a/src/qml/qml/qqmlfileselector.h +++ b/src/qml/qml/qqmlfileselector.h @@ -55,7 +55,7 @@ class Q_QML_EXPORT QQmlFileSelector : public QObject Q_DECLARE_PRIVATE(QQmlFileSelector) public: explicit QQmlFileSelector(QQmlEngine *engine, QObject *parent = nullptr); - ~QQmlFileSelector(); + ~QQmlFileSelector() override; QFileSelector *selector() const Q_DECL_NOTHROW; void setSelector(QFileSelector *selector); void setExtraSelectors(QStringList &strings); // TODO Qt6: remove diff --git a/src/qml/qml/qqmlopenmetaobject_p.h b/src/qml/qml/qqmlopenmetaobject_p.h index bb5477dfbf..4905190b75 100644 --- a/src/qml/qml/qqmlopenmetaobject_p.h +++ b/src/qml/qml/qqmlopenmetaobject_p.h @@ -69,7 +69,7 @@ class Q_QML_PRIVATE_EXPORT QQmlOpenMetaObjectType : public QQmlRefCount, public { public: QQmlOpenMetaObjectType(const QMetaObject *base, QQmlEngine *engine); - ~QQmlOpenMetaObjectType(); + ~QQmlOpenMetaObjectType() override; void createProperties(const QVector &names); int createProperty(const QByteArray &name); @@ -97,7 +97,7 @@ class Q_QML_PRIVATE_EXPORT QQmlOpenMetaObject : public QAbstractDynamicMetaObjec public: QQmlOpenMetaObject(QObject *, const QMetaObject * = nullptr, bool = true); QQmlOpenMetaObject(QObject *, QQmlOpenMetaObjectType *, bool = true); - ~QQmlOpenMetaObject(); + ~QQmlOpenMetaObject() override; QVariant value(const QByteArray &) const; bool setValue(const QByteArray &, const QVariant &); diff --git a/src/qml/qml/qqmlprivate.h b/src/qml/qml/qqmlprivate.h index 11adea6fc9..fabdcacc36 100644 --- a/src/qml/qml/qqmlprivate.h +++ b/src/qml/qml/qqmlprivate.h @@ -98,7 +98,7 @@ namespace QQmlPrivate class QQmlElement : public T { public: - virtual ~QQmlElement() { + ~QQmlElement() override { QQmlPrivate::qdeclarativeelement_destructor(this); } }; diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h index 7b04ba11b8..51a191a41f 100644 --- a/src/qml/qml/qqmlpropertycache_p.h +++ b/src/qml/qml/qqmlpropertycache_p.h @@ -394,7 +394,7 @@ class Q_QML_PRIVATE_EXPORT QQmlPropertyCache : public QQmlRefCount public: QQmlPropertyCache(); QQmlPropertyCache(const QMetaObject *); - virtual ~QQmlPropertyCache(); + ~QQmlPropertyCache() override; void update(const QMetaObject *); void invalidate(const QMetaObject *); diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h index f2327e9a5f..713f707387 100644 --- a/src/qml/qml/qqmltypeloader_p.h +++ b/src/qml/qml/qqmltypeloader_p.h @@ -110,7 +110,7 @@ public: }; QQmlDataBlob(const QUrl &, Type, QQmlTypeLoader* manager); - virtual ~QQmlDataBlob(); + ~QQmlDataBlob() override; void startLoading(); @@ -262,7 +262,7 @@ public: { public: Blob(const QUrl &url, QQmlDataBlob::Type type, QQmlTypeLoader *loader); - ~Blob(); + ~Blob() override; const QQmlImports &imports() const { return m_importCache; } @@ -438,7 +438,7 @@ private: QQmlTypeData(const QUrl &, QQmlTypeLoader *); public: - ~QQmlTypeData(); + ~QQmlTypeData() override; const QList &resolvedScripts() const; @@ -523,7 +523,7 @@ private: QQmlScriptData(); public: - ~QQmlScriptData(); + ~QQmlScriptData() override; QUrl url; QString urlString; @@ -554,7 +554,7 @@ private: QQmlScriptBlob(const QUrl &, QQmlTypeLoader *); public: - ~QQmlScriptBlob(); + ~QQmlScriptBlob() override; struct ScriptReference { diff --git a/src/qml/qml/qqmltypenamecache_p.h b/src/qml/qml/qqmltypenamecache_p.h index c2f7a70d03..28b5e7f0ad 100644 --- a/src/qml/qml/qqmltypenamecache_p.h +++ b/src/qml/qml/qqmltypenamecache_p.h @@ -85,7 +85,7 @@ class Q_QML_PRIVATE_EXPORT QQmlTypeNameCache : public QQmlRefCount { public: QQmlTypeNameCache(const QQmlImports &imports); - virtual ~QQmlTypeNameCache(); + ~QQmlTypeNameCache() override; inline bool isEmpty() const; diff --git a/src/qml/qml/qqmlvaluetype_p.h b/src/qml/qml/qqmlvaluetype_p.h index 7d8473db0e..4ea71e8955 100644 --- a/src/qml/qml/qqmlvaluetype_p.h +++ b/src/qml/qml/qqmlvaluetype_p.h @@ -67,7 +67,7 @@ class Q_QML_PRIVATE_EXPORT QQmlValueType : public QObject, public QAbstractDynam { public: QQmlValueType(int userType, const QMetaObject *metaObject); - ~QQmlValueType(); + ~QQmlValueType() override; void read(QObject *, int); void write(QObject *, int, QQmlPropertyData::WriteFlags flags); QVariant value(); diff --git a/src/qml/qml/qqmlvmemetaobject_p.h b/src/qml/qml/qqmlvmemetaobject_p.h index 1da79b8a81..0c82686d47 100644 --- a/src/qml/qml/qqmlvmemetaobject_p.h +++ b/src/qml/qml/qqmlvmemetaobject_p.h @@ -81,7 +81,7 @@ class QQmlVMEVariantQObjectPtr : public QQmlGuard { public: inline QQmlVMEVariantQObjectPtr(); - inline ~QQmlVMEVariantQObjectPtr(); + inline ~QQmlVMEVariantQObjectPtr() override; inline void objectDestroyed(QObject *) override; inline void setGuardedValue(QObject *obj, QQmlVMEMetaObject *target, int index); @@ -95,7 +95,7 @@ class Q_QML_PRIVATE_EXPORT QQmlInterceptorMetaObject : public QAbstractDynamicMe { public: QQmlInterceptorMetaObject(QObject *obj, QQmlPropertyCache *cache); - ~QQmlInterceptorMetaObject(); + ~QQmlInterceptorMetaObject() override; void registerInterceptor(QQmlPropertyIndex index, QQmlPropertyValueInterceptor *interceptor); @@ -147,7 +147,7 @@ class Q_QML_PRIVATE_EXPORT QQmlVMEMetaObject : public QQmlInterceptorMetaObject { public: QQmlVMEMetaObject(QV4::ExecutionEngine *engine, QObject *obj, QQmlPropertyCache *cache, QV4::CompiledData::CompilationUnit *qmlCompilationUnit, int qmlObjectId); - ~QQmlVMEMetaObject(); + ~QQmlVMEMetaObject() override; bool aliasTarget(int index, QObject **target, int *coreIndex, int *valueTypeIndex) const; QV4::ReturnedValue vmeMethod(int index) const; -- cgit v1.2.3 From f010b360c3b9929550ee1768c0eddd2a85345da6 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Fri, 23 Feb 2018 12:29:44 +0100 Subject: Do not write JSC files when debugging These will include Debug interpreter instructions, which wreck havoc when no debugger is attached. Task-number: QTBUG-66593 Change-Id: I0692207e51df6d52d0616f37a06ade76b6b2d54a Reviewed-by: Simon Hausmann --- src/qml/qml/qqmltypeloader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index ed1526c0a9..a107bb42ce 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -3015,7 +3015,7 @@ void QQmlScriptBlob::dataReceived(const SourceCodeData &data) // The js unit owns the data and will free the qml unit. unit->data = unitData; - if (!disableDiskCache() || forceDiskCache()) { + if ((!disableDiskCache() || forceDiskCache()) && !isDebugging()) { QString errorString; if (!unit->saveToDisk(url(), &errorString)) { qCDebug(DBG_DISK_CACHE()) << "Error saving cached version of" << unit->fileName() << "to disk:" << errorString; -- cgit v1.2.3 From 622decbe3b2478496295e57d59f9cf16a9f70a13 Mon Sep 17 00:00:00 2001 From: Ville Voutilainen Date: Wed, 28 Feb 2018 16:09:09 +0200 Subject: Silence GCC 8 warnings in qpodvector MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qpodvector_p.h:90:34: error: ‘void* realloc(void*, size_t)’ moving an object of non-trivially copyable type ‘class QQuickBasePositioner::PositionedItem’; use ‘new’ and ‘delete’ instead [-Werror=class-memaccess] m_data = (T *)realloc(m_data, m_capacity * sizeof(T)); qpodvector_p.h:94:22: error: ‘void* memmove(void*, const void*, size_t)’ writing to an object of non-trivially copyable type ‘class QQuickBasePositioner::PositionedItem’; use copy-assignment or copy-initialization instead [-Werror=class-memaccess] ::memmove(m_data + idx + 1, m_data + idx, moveCount * sizeof(T)); Change-Id: I37088986a0f8613152a355ed6f3f9572316fa607 Reviewed-by: Simon Hausmann --- src/qml/qml/ftw/qpodvector_p.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/ftw/qpodvector_p.h b/src/qml/qml/ftw/qpodvector_p.h index d0e4f89741..5255c1f617 100644 --- a/src/qml/qml/ftw/qpodvector_p.h +++ b/src/qml/qml/ftw/qpodvector_p.h @@ -87,11 +87,11 @@ public: void insert(int idx, const T &v) { if (m_count == m_capacity) { m_capacity += Increment; - m_data = (T *)realloc(m_data, m_capacity * sizeof(T)); + m_data = (T *)realloc(static_cast(m_data), m_capacity * sizeof(T)); } int moveCount = m_count - idx; if (moveCount) - ::memmove(m_data + idx + 1, m_data + idx, moveCount * sizeof(T)); + ::memmove(static_cast(m_data + idx + 1), static_cast(m_data + idx), moveCount * sizeof(T)); m_count++; m_data[idx] = v; } @@ -99,7 +99,7 @@ public: void reserve(int count) { if (count >= m_capacity) { m_capacity = (count + (Increment-1)) & (0xFFFFFFFF - Increment + 1); - m_data = (T *)realloc(m_data, m_capacity * sizeof(T)); + m_data = (T *)realloc(static_cast(m_data), m_capacity * sizeof(T)); } } @@ -108,7 +108,7 @@ public: reserve(newSize); int moveCount = m_count - idx; if (moveCount) - ::memmove(m_data + idx + count, m_data + idx, + ::memmove(static_cast(m_data + idx + count), static_cast(m_data + idx), moveCount * sizeof(T)); m_count = newSize; } -- cgit v1.2.3 From 55f71cdfc5746a71bcb89f0fa4ff3447cb8b5514 Mon Sep 17 00:00:00 2001 From: Ville Voutilainen Date: Wed, 28 Feb 2018 16:50:44 +0200 Subject: Silence another GCC 8 warning in qpodvector MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qtdeclarative/src/qml/qml/ftw/qpodvector_p.h:119:22: error: ‘void* memmove(void*, const void*, size_t)’ writing to an object of non-trivially copyable type ‘class QQuickBasePositioner::PositionedItem’; use copy-assignment or copy-initialization instead [-Werror=class-memaccess] ::memmove(m_data + idx, m_data + idx + count, Change-Id: I049703a0a6bb4432dfd3d3ce3c8cef13e9c2e31a Reviewed-by: Simon Hausmann --- src/qml/qml/ftw/qpodvector_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/ftw/qpodvector_p.h b/src/qml/qml/ftw/qpodvector_p.h index 5255c1f617..b2fb481793 100644 --- a/src/qml/qml/ftw/qpodvector_p.h +++ b/src/qml/qml/ftw/qpodvector_p.h @@ -116,7 +116,7 @@ public: void remove(int idx, int count = 1) { int moveCount = m_count - (idx + count); if (moveCount) - ::memmove(m_data + idx, m_data + idx + count, + ::memmove(static_cast(m_data + idx), static_cast(m_data + idx + count), moveCount * sizeof(T)); m_count -= count; } -- cgit v1.2.3 From 8d587c9fed01a2a36c1c0e2f5fb10763c5b0c7c5 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 5 Mar 2018 17:16:46 -0600 Subject: Improve documentation on component creation context Change-Id: I55adc9c261529ee4b88fbb5591b3955e396437a8 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlcomponent.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 061f3b54a5..3174bbecd3 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -241,6 +241,9 @@ V4_DEFINE_EXTENSION(QQmlComponentExtension, componentExtension); \li main.qml \li \snippet qml/component/main.qml 0 \endtable + + It is important that the lifetime of the creation context outlive any created objects. See + \l{Maintaining Dynamically Created Objects} for more details. */ /*! -- cgit v1.2.3 From efa0dac9c4c456793f9e0e706a3b026ed0941801 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 5 Mar 2018 10:19:33 +0100 Subject: Fix regression involving aliases on case-insensitive file systems When initializing a QQmlProperty with the following syntax: QQmlProperty property(root, "testType.objectName", QQmlEngine::contextForObject(root)); only try to look up types (for each token after splitting on the '.') if the token starts with an uppercase letter, as 1e350a8c now enforces that type names begin with an uppercase letter. Task-number: QTBUG-66715 Change-Id: Iab64be1deb971dca256fc65d358c773837222a57 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlproperty.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index 8ecd597a39..ebf296b29d 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -269,7 +269,9 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name) for (int ii = 0; ii < path.count() - 1; ++ii) { const QStringRef &pathName = path.at(ii); - if (typeNameCache) { + // Types must begin with an uppercase letter (see checkRegistration() + // in qqmlmetatype.cpp for the enforcement of this). + if (typeNameCache && !pathName.isEmpty() && pathName.at(0).isUpper()) { QQmlTypeNameCache::Result r = typeNameCache->query(pathName); if (r.isValid()) { if (r.type.isValid()) { -- cgit v1.2.3 From 5e0c3a798ab0d70be45a107661fc5f0a17322a2a Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 2 Mar 2018 09:09:17 +0100 Subject: Fix calling Qt.createComponent() from QQmlEngine::evaluate() If we're run from a top-level evaluate() call from the JS engine, then let's assume that any created components are top-level components that belong to the root QML engine context. This is not quite a typical use-case, but our API allows for this and this seems like an easy and sensible solution. Task-number: QTBUG-66792 Change-Id: Ic1c9171c257e8e60c0b2c43f9194bd038744ed2d Reviewed-by: Oleg Yadrov Reviewed-by: Michael Brasser --- src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/qml/qml') diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index c147feeb73..1371f1f041 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1119,6 +1119,11 @@ ReturnedValue QtObject::method_createQmlObject(const FunctionObject *b, const Va QQmlEngine *engine = scope.engine->qmlEngine(); QQmlContextData *context = scope.engine->callingQmlContext(); + if (!context) { + QQmlEngine *qmlEngine = scope.engine->qmlEngine(); + if (qmlEngine) + context = QQmlContextData::get(QQmlEnginePrivate::get(qmlEngine)->rootContext); + } Q_ASSERT(context); QQmlContext *effectiveContext = nullptr; if (context->isPragmaLibraryContext) @@ -1246,6 +1251,11 @@ ReturnedValue QtObject::method_createComponent(const FunctionObject *b, const Va QQmlEngine *engine = scope.engine->qmlEngine(); QQmlContextData *context = scope.engine->callingQmlContext(); + if (!context) { + QQmlEngine *qmlEngine = scope.engine->qmlEngine(); + if (qmlEngine) + context = QQmlContextData::get(QQmlEnginePrivate::get(qmlEngine)->rootContext); + } Q_ASSERT(context); QQmlContextData *effectiveContext = context; if (context->isPragmaLibraryContext) -- cgit v1.2.3 From 50f700aa8f68fff1e0153d19227b5a0bebbb6e51 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 22 Feb 2018 16:04:08 +0100 Subject: Fix group property bindings for aliases that point to id objects When declaring bindings within a group property and that group property itself is a locally declared alias, then by the time we try to determine property caches for the group property we will fail as the aliases haven't been resolved yet. To fix this we can keep track of such group property declarations (encapsulated in the QQmlInstantiatingBindingContext that has all we need) and after we've resolved the aliases (added them to the property caches), we can go back and fill in the entries in the propertyCaches array for the group properties. Task-number: QTBUG-51043 Change-Id: I5613513db3977934bcc51a3df530de47d57326f9 Reviewed-by: Mitch Curtis Reviewed-by: Michael Brasser --- src/qml/qml/qqmltypeloader.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index a107bb42ce..61208d1c4a 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -2187,8 +2187,12 @@ void QQmlTypeData::createTypeAndPropertyCaches(const QQmlRefPointerengine()); + QQmlPendingGroupPropertyBindings pendingGroupPropertyBindings; + { - QQmlPropertyCacheCreator propertyCacheCreator(&m_compiledData->propertyCaches, engine, m_compiledData, &m_importCache); + QQmlPropertyCacheCreator propertyCacheCreator(&m_compiledData->propertyCaches, + &pendingGroupPropertyBindings, + engine, m_compiledData, &m_importCache); QQmlCompileError error = propertyCacheCreator.buildMetaObjects(); if (error.isSet()) { setError(error); @@ -2198,6 +2202,8 @@ void QQmlTypeData::createTypeAndPropertyCaches(const QQmlRefPointer aliasCreator(&m_compiledData->propertyCaches, m_compiledData); aliasCreator.appendAliasPropertiesToMetaObjects(); + + pendingGroupPropertyBindings.resolveMissingPropertyCaches(engine, &m_compiledData->propertyCaches); } static bool addTypeReferenceChecksumsToHash(const QList &typeRefs, QCryptographicHash *hash, QQmlEngine *engine) -- cgit v1.2.3