aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-11-16 10:08:49 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-11-16 10:08:50 +0100
commite7c316504770ce357b2c73be485cdd8c1da9c4c1 (patch)
treeb49032420022617396a83da310ebe01b38cda8f9 /src/qml
parent87265c7ab8743ece92262cd6b79bbba9dddd1fe1 (diff)
parente3948955c961972d34483e7da9c2908f5cb84420 (diff)
Merge remote-tracking branch 'origin/5.12.0' into 5.12
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/compiler/qv4codegen.cpp52
-rw-r--r--src/qml/compiler/qv4compileddata.cpp38
-rw-r--r--src/qml/compiler/qv4compileddata_p.h2
-rw-r--r--src/qml/compiler/qv4compilercontext.cpp8
-rw-r--r--src/qml/configure.json18
-rw-r--r--src/qml/doc/qtqml.qdocconf2
-rw-r--r--src/qml/jit/qv4baselineassembler.cpp8
-rw-r--r--src/qml/jsruntime/qv4engine.cpp2
-rw-r--r--src/qml/jsruntime/qv4module.cpp77
-rw-r--r--src/qml/jsruntime/qv4module_p.h6
-rw-r--r--src/qml/jsruntime/qv4qmlcontext.cpp15
-rw-r--r--src/qml/jsruntime/qv4qmlcontext_p.h7
-rw-r--r--src/qml/memory/qv4mm.cpp5
-rw-r--r--src/qml/qml/qqmlinfo.cpp63
-rw-r--r--src/qml/qml/qqmltypeloader.cpp86
-rw-r--r--src/qml/qml/qqmltypeloader_p.h3
-rw-r--r--src/qml/types/qqmldelegatecomponent.cpp22
-rw-r--r--src/qml/types/qqmldelegatemodel.cpp2
-rw-r--r--src/qml/types/qqmlitemselectionmodel.qdoc4
19 files changed, 249 insertions, 171 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 09c0e60f4d..75c47164c9 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -3059,34 +3059,36 @@ int Codegen::defineFunction(const QString &name, AST::Node *ast,
statementList(body);
- bytecodeGenerator->setLocation(ast->lastSourceLocation());
- _context->emitBlockFooter(this);
-
- if (_returnLabel || hasError || !functionEndsWithReturn) {
- if (_returnLabel)
- _returnLabel->link();
+ if (!hasError) {
+ bytecodeGenerator->setLocation(ast->lastSourceLocation());
+ _context->emitBlockFooter(this);
+
+ if (_returnLabel || !functionEndsWithReturn) {
+ if (_returnLabel)
+ _returnLabel->link();
+
+ if (_returnLabel || requiresReturnValue) {
+ Instruction::LoadReg load;
+ load.reg = Moth::StackSlot::createRegister(_returnAddress);
+ bytecodeGenerator->addInstruction(load);
+ } else {
+ Reference::fromConst(this, Encode::undefined()).loadInAccumulator();
+ }
- if (_returnLabel || requiresReturnValue) {
- Instruction::LoadReg load;
- load.reg = Moth::StackSlot::createRegister(_returnAddress);
- bytecodeGenerator->addInstruction(load);
- } else {
- Reference::fromConst(this, Encode::undefined()).loadInAccumulator();
+ bytecodeGenerator->addInstruction(Instruction::Ret());
}
- bytecodeGenerator->addInstruction(Instruction::Ret());
- }
-
- Q_ASSERT(_context == _functionContext);
- bytecodeGenerator->finalize(_context);
- _context->registerCountInFunction = bytecodeGenerator->registerCount();
- static const bool showCode = qEnvironmentVariableIsSet("QV4_SHOW_BYTECODE");
- if (showCode) {
- qDebug() << "=== Bytecode for" << _context->name << "strict mode" << _context->isStrict
- << "register count" << _context->registerCountInFunction << "implicit return" << requiresReturnValue;
- QV4::Moth::dumpBytecode(_context->code, _context->locals.size(), _context->arguments.size(),
- _context->line, _context->lineNumberMapping);
- qDebug();
+ Q_ASSERT(_context == _functionContext);
+ bytecodeGenerator->finalize(_context);
+ _context->registerCountInFunction = bytecodeGenerator->registerCount();
+ static const bool showCode = qEnvironmentVariableIsSet("QV4_SHOW_BYTECODE");
+ if (showCode) {
+ qDebug() << "=== Bytecode for" << _context->name << "strict mode" << _context->isStrict
+ << "register count" << _context->registerCountInFunction << "implicit return" << requiresReturnValue;
+ QV4::Moth::dumpBytecode(_context->code, _context->locals.size(), _context->arguments.size(),
+ _context->line, _context->lineNumberMapping);
+ qDebug();
+ }
}
qSwap(_returnAddress, returnAddress);
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp
index 3b2d6e0a48..b8497937c1 100644
--- a/src/qml/compiler/qv4compileddata.cpp
+++ b/src/qml/compiler/qv4compileddata.cpp
@@ -415,13 +415,20 @@ QStringList CompilationUnit::moduleRequests() const
Heap::Module *CompilationUnit::instantiate(ExecutionEngine *engine)
{
- if (m_module)
+ if (isESModule() && m_module)
return m_module;
+ if (data->indexOfRootFunction < 0)
+ return nullptr;
+
if (!this->engine)
linkToEngine(engine);
- m_module = engine->memoryManager->allocate<Module>(engine, this);
+ Scope scope(engine);
+ Scoped<Module> module(scope, engine->memoryManager->allocate<Module>(engine, this));
+
+ if (isESModule())
+ m_module = module->d();
for (const QString &request: moduleRequests()) {
auto dependentModuleUnit = engine->loadModule(QUrl(request), this);
@@ -430,7 +437,6 @@ Heap::Module *CompilationUnit::instantiate(ExecutionEngine *engine)
dependentModuleUnit->instantiate(engine);
}
- Scope scope(engine);
ScopedString importName(scope);
const uint importCount = data->importEntryTableSize;
@@ -465,7 +471,7 @@ Heap::Module *CompilationUnit::instantiate(ExecutionEngine *engine)
}
}
- return m_module;
+ return module->d();
}
const Value *CompilationUnit::resolveExport(QV4::String *exportName)
@@ -590,10 +596,13 @@ void CompilationUnit::getExportedNamesRecursively(QStringList *names, QVector<co
void CompilationUnit::evaluate()
{
- if (m_moduleEvaluated)
- return;
- m_moduleEvaluated = true;
+ QV4::Scope scope(engine);
+ QV4::Scoped<Module> module(scope, m_module);
+ module->evaluate();
+}
+void CompilationUnit::evaluateModuleRequests()
+{
for (const QString &request: moduleRequests()) {
auto dependentModuleUnit = engine->loadModule(QUrl(request), this);
if (engine->hasException)
@@ -602,19 +611,6 @@ void CompilationUnit::evaluate()
if (engine->hasException)
return;
}
-
- QV4::Function *moduleFunction = runtimeFunctions[data->indexOfRootFunction];
- CppStackFrame frame;
- frame.init(engine, moduleFunction, nullptr, 0);
- frame.setupJSFrame(engine->jsStackTop, Value::undefinedValue(), m_module->scope,
- Value::undefinedValue(), Value::undefinedValue());
-
- frame.push();
- engine->jsStackTop += frame.requiredJSStackFrameSize();
- auto frameCleanup = qScopeGuard([&frame]() {
- frame.pop();
- });
- Moth::VME::exec(&frame, engine);
}
bool CompilationUnit::loadFromDisk(const QUrl &url, const QDateTime &sourceTimeStamp, QString *errorString)
@@ -768,7 +764,7 @@ QString Binding::valueAsString(const CompilationUnit *unit) const
case Type_Translation: {
const TranslationData &translation = unit->unitData()->translations()[value.translationDataIndex];
// This code must match that in the qsTr() implementation
- const QString &path = unit->stringAt(unit->unitData()->sourceFileIndex);
+ const QString &path = unit->fileName();
int lastSlash = path.lastIndexOf(QLatin1Char('/'));
QStringRef context = (lastSlash > -1) ? path.midRef(lastSlash + 1, path.length() - lastSlash - 5)
: QStringRef();
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h
index d0785c6883..7c26b0b67d 100644
--- a/src/qml/compiler/qv4compileddata_p.h
+++ b/src/qml/compiler/qv4compileddata_p.h
@@ -1223,6 +1223,7 @@ public:
const Value *resolveExport(QV4::String *exportName);
QStringList exportedNames() const;
void evaluate();
+ void evaluateModuleRequests();
QV4::Function *linkToEngine(QV4::ExecutionEngine *engine);
void unlink();
@@ -1265,7 +1266,6 @@ private:
Q_NEVER_INLINE IdentifierHash createNamedObjectsPerComponent(int componentObjectIndex);
Heap::Module *m_module = nullptr;
- bool m_moduleEvaluated = false;
public:
#if defined(V4_BOOTSTRAP)
diff --git a/src/qml/compiler/qv4compilercontext.cpp b/src/qml/compiler/qv4compilercontext.cpp
index 572f24f148..ca4cbfc4fc 100644
--- a/src/qml/compiler/qv4compilercontext.cpp
+++ b/src/qml/compiler/qv4compilercontext.cpp
@@ -207,7 +207,7 @@ void Context::emitBlockHeader(Codegen *codegen)
blockIndex = codegen->module()->blocks.count() - 1;
}
- if (contextType == ContextType::Global || contextType == ContextType::ScriptImportedByQML) {
+ if (contextType == ContextType::Global) {
Instruction::PushScriptContext scriptContext;
scriptContext.index = blockIndex;
bytecodeGenerator->addInstruction(scriptContext);
@@ -222,7 +222,7 @@ void Context::emitBlockHeader(Codegen *codegen)
blockContext.index = blockIndex;
bytecodeGenerator->addInstruction(blockContext);
}
- } else if (contextType != ContextType::ESModule) {
+ } else if (contextType != ContextType::ESModule && contextType != ContextType::ScriptImportedByQML) {
Instruction::CreateCallContext createContext;
bytecodeGenerator->addInstruction(createContext);
}
@@ -316,9 +316,9 @@ void Context::emitBlockFooter(Codegen *codegen)
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wmaybe-uninitialized") // the loads below are empty structs.
- if (contextType == ContextType::Global || contextType == ContextType::ScriptImportedByQML)
+ if (contextType == ContextType::Global)
bytecodeGenerator->addInstruction(Instruction::PopScriptContext());
- else if (contextType != ContextType::ESModule)
+ else if (contextType != ContextType::ESModule && contextType != ContextType::ScriptImportedByQML)
bytecodeGenerator->addInstruction(Instruction::PopContext());
QT_WARNING_POP
}
diff --git a/src/qml/configure.json b/src/qml/configure.json
index aea62c3439..878ec0119b 100644
--- a/src/qml/configure.json
+++ b/src/qml/configure.json
@@ -12,7 +12,25 @@
}
},
+ "tests": {
+ "cxx14_make_unique": {
+ "label": "C++14 make_unique()",
+ "type": "compile",
+ "test": {
+ "include": "memory",
+ "main": [
+ "std::unique_ptr<int> ptr = std::make_unique<int>();"
+ ]
+ }
+ }
+ },
+
"features": {
+ "cxx14_make_unique": {
+ "label": "C++14 make_unique",
+ "condition": "tests.cxx14_make_unique",
+ "output": [ "privateFeature" ]
+ },
"qml-network": {
"label": "QML network support",
"purpose": "Provides network transparency.",
diff --git a/src/qml/doc/qtqml.qdocconf b/src/qml/doc/qtqml.qdocconf
index 6161760471..40acc7c13f 100644
--- a/src/qml/doc/qtqml.qdocconf
+++ b/src/qml/doc/qtqml.qdocconf
@@ -33,7 +33,7 @@ qhp.QtQml.subprojects.qmltypes.sortPages = true
tagfile = ../../../doc/qtqml/qtqml.tags
-depends += qtcore qtxmlpatterns qtgui qtquick qtdoc qtlinguist qmake qtscript qtwidgets
+depends += qtcore qtgui qtquick qtdoc qtlinguist qmake qtscript qtwidgets
headerdirs += .. \
../../imports/models
diff --git a/src/qml/jit/qv4baselineassembler.cpp b/src/qml/jit/qv4baselineassembler.cpp
index f6b745632b..c62d6e5388 100644
--- a/src/qml/jit/qv4baselineassembler.cpp
+++ b/src/qml/jit/qv4baselineassembler.cpp
@@ -444,12 +444,12 @@ public:
void moveReg(Address sourceRegAddress, Address destRegAddress)
{
- load32(sourceRegAddress, ReturnValueRegisterValue);
+ load32(sourceRegAddress, ScratchRegister);
+ store32(ScratchRegister, destRegAddress);
sourceRegAddress.offset += 4;
- load32(sourceRegAddress, ReturnValueRegisterTag);
- store32(ReturnValueRegisterValue, destRegAddress);
destRegAddress.offset += 4;
- store32(ReturnValueRegisterTag, destRegAddress);
+ load32(sourceRegAddress, ScratchRegister);
+ store32(ScratchRegister, destRegAddress);
}
void loadString(int stringId)
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 169ab0a4a4..57a364b205 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -342,7 +342,7 @@ ExecutionEngine::ExecutionEngine(QJSEngine *jsEngine)
jsObjects[BooleanProto] = memoryManager->allocate<BooleanPrototype>();
jsObjects[DateProto] = memoryManager->allocate<DatePrototype>();
-#ifdef QT_NO_DEBUG
+#if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS)
InternalClassEntry *index = nullptr;
#else
InternalClassEntry _index;
diff --git a/src/qml/jsruntime/qv4module.cpp b/src/qml/jsruntime/qv4module.cpp
index 19a036374f..237ada8321 100644
--- a/src/qml/jsruntime/qv4module.cpp
+++ b/src/qml/jsruntime/qv4module.cpp
@@ -46,6 +46,8 @@
#include <private/qv4symbol_p.h>
#include <private/qv4identifiertable_p.h>
+#include <QScopeGuard>
+
using namespace QV4;
DEFINE_OBJECT_VTABLE(Module);
@@ -98,20 +100,60 @@ void Heap::Module::init(ExecutionEngine *engine, CompiledData::CompilationUnit *
This->setPrototypeUnchecked(nullptr);
}
+void Module::evaluate()
+{
+ if (d()->evaluated)
+ return;
+ d()->evaluated = true;
+
+ CompiledData::CompilationUnit *unit = d()->unit;
+
+ unit->evaluateModuleRequests();
+
+ ExecutionEngine *v4 = engine();
+ Function *moduleFunction = unit->runtimeFunctions[unit->data->indexOfRootFunction];
+ CppStackFrame frame;
+ frame.init(v4, moduleFunction, nullptr, 0);
+ frame.setupJSFrame(v4->jsStackTop, Value::undefinedValue(), d()->scope,
+ Value::undefinedValue(), Value::undefinedValue());
+
+ frame.push();
+ v4->jsStackTop += frame.requiredJSStackFrameSize();
+ auto frameCleanup = qScopeGuard([&frame]() {
+ frame.pop();
+ });
+ Moth::VME::exec(&frame, v4);
+}
+
+const Value *Module::resolveExport(PropertyKey id) const
+{
+ if (d()->unit->isESModule()) {
+ if (!id.isString())
+ return nullptr;
+ Scope scope(engine());
+ ScopedString name(scope, id.asStringOrSymbol());
+ return d()->unit->resolveExport(name);
+ } else {
+ InternalClassEntry entry = d()->scope->internalClass->find(id);
+ if (entry.isValid())
+ return &d()->scope->locals[entry.index];
+ return nullptr;
+ }
+}
+
ReturnedValue Module::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
{
if (id.isSymbol())
return Object::virtualGet(m, id, receiver, hasProperty);
const Module *module = static_cast<const Module *>(m);
- Scope scope(m->engine());
- ScopedString expectedName(scope, id.toStringOrSymbol(scope.engine));
- const Value *v = module->d()->unit->resolveExport(expectedName);
+ const Value *v = module->resolveExport(id);
if (hasProperty)
*hasProperty = v != nullptr;
if (!v)
return Encode::undefined();
if (v->isEmpty()) {
+ Scope scope(m->engine());
ScopedValue propName(scope, id.toStringOrSymbol(scope.engine));
return scope.engine->throwReferenceError(propName);
}
@@ -124,9 +166,7 @@ PropertyAttributes Module::virtualGetOwnProperty(const Managed *m, PropertyKey i
return Object::virtualGetOwnProperty(m, id, p);
const Module *module = static_cast<const Module *>(m);
- Scope scope(m->engine());
- ScopedString expectedName(scope, id.toStringOrSymbol(scope.engine));
- const Value *v = module->d()->unit->resolveExport(expectedName);
+ const Value *v = module->resolveExport(id);
if (!v) {
if (p)
p->value = Encode::undefined();
@@ -135,6 +175,7 @@ PropertyAttributes Module::virtualGetOwnProperty(const Managed *m, PropertyKey i
if (p)
p->value = v->isEmpty() ? Encode::undefined() : v->asReturnedValue();
if (v->isEmpty()) {
+ Scope scope(m->engine());
ScopedValue propName(scope, id.toStringOrSymbol(scope.engine));
scope.engine->throwReferenceError(propName);
}
@@ -147,9 +188,7 @@ bool Module::virtualHasProperty(const Managed *m, PropertyKey id)
return Object::virtualHasProperty(m, id);
const Module *module = static_cast<const Module *>(m);
- Scope scope(m->engine());
- ScopedString expectedName(scope, id.toStringOrSymbol(scope.engine));
- const Value *v = module->d()->unit->resolveExport(expectedName);
+ const Value *v = module->resolveExport(id);
return v != nullptr;
}
@@ -173,11 +212,7 @@ bool Module::virtualDeleteProperty(Managed *m, PropertyKey id)
if (id.isSymbol())
return Object::virtualDeleteProperty(m, id);
const Module *module = static_cast<const Module *>(m);
- Scope scope(m->engine());
- ScopedString expectedName(scope, id.toStringOrSymbol(scope.engine));
- if (!expectedName)
- return true;
- const Value *v = module->d()->unit->resolveExport(expectedName);
+ const Value *v = module->resolveExport(id);
if (v)
return false;
return true;
@@ -202,7 +237,7 @@ PropertyKey ModuleNamespaceIterator::next(const Object *o, Property *pd, Propert
Scope scope(module->engine());
ScopedString exportName(scope, scope.engine->newString(exportedNames.at(exportIndex)));
exportIndex++;
- const Value *v = module->d()->unit->resolveExport(exportName);
+ const Value *v = module->resolveExport(exportName->toPropertyKey());
if (pd) {
if (v->isEmpty())
scope.engine->throwReferenceError(exportName);
@@ -218,7 +253,17 @@ OwnPropertyKeyIterator *Module::virtualOwnPropertyKeys(const Object *o, Value *t
{
const Module *module = static_cast<const Module *>(o);
*target = *o;
- return new ModuleNamespaceIterator(module->d()->unit->exportedNames());
+
+ QStringList names;
+ if (module->d()->unit->isESModule()) {
+ names = module->d()->unit->exportedNames();
+ } else {
+ Heap::InternalClass *scopeClass = module->d()->scope->internalClass;
+ for (uint i = 0; i < scopeClass->size; ++i)
+ names << scopeClass->keyAt(i);
+ }
+
+ return new ModuleNamespaceIterator(names);
}
Heap::Object *Module::virtualGetPrototypeOf(const Managed *)
diff --git a/src/qml/jsruntime/qv4module_p.h b/src/qml/jsruntime/qv4module_p.h
index 0cab161b82..dca0678fe9 100644
--- a/src/qml/jsruntime/qv4module_p.h
+++ b/src/qml/jsruntime/qv4module_p.h
@@ -62,7 +62,8 @@ namespace Heap {
#define ModuleMembers(class, Member) \
Member(class, NoMark, CompiledData::CompilationUnit *, unit) \
Member(class, Pointer, CallContext *, scope) \
- Member(class, HeapValue, HeapValue, self)
+ Member(class, HeapValue, HeapValue, self) \
+ Member(class, NoMark, bool, evaluated)
DECLARE_EXPORTED_HEAP_OBJECT(Module, Object) {
DECLARE_MARKOBJECTS(Module)
@@ -75,6 +76,9 @@ DECLARE_EXPORTED_HEAP_OBJECT(Module, Object) {
struct Q_QML_EXPORT Module : public Object {
V4_OBJECT2(Module, Object)
+ void evaluate();
+ const Value *resolveExport(PropertyKey key) const;
+
static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p);
static bool virtualHasProperty(const Managed *m, PropertyKey id);
diff --git a/src/qml/jsruntime/qv4qmlcontext.cpp b/src/qml/jsruntime/qv4qmlcontext.cpp
index cc0b0feeee..88b0822f42 100644
--- a/src/qml/jsruntime/qv4qmlcontext.cpp
+++ b/src/qml/jsruntime/qv4qmlcontext.cpp
@@ -54,6 +54,7 @@
#include <private/qqmljavascriptexpression_p.h>
#include <private/qjsvalue_p.h>
#include <private/qv4qobjectwrapper_p.h>
+#include <private/qv4module_p.h>
QT_BEGIN_NAMESPACE
@@ -87,8 +88,20 @@ ReturnedValue QQmlContextWrapper::virtualGet(const Managed *m, PropertyKey id, c
QV4::ExecutionEngine *v4 = resource->engine();
QV4::Scope scope(v4);
- if (v4->callingQmlContext() != *resource->d()->context)
+ if (v4->callingQmlContext() != *resource->d()->context) {
+ if (resource->d()->module) {
+ Scoped<Module> module(scope, resource->d()->module);
+ bool hasProp = false;
+ ScopedValue value(scope, module->get(id, receiver, &hasProp));
+ if (hasProp) {
+ if (hasProperty)
+ *hasProperty = hasProp;
+ return value->asReturnedValue();
+ }
+ }
+
return Object::virtualGet(m, id, receiver, hasProperty);
+ }
bool hasProp = false;
ScopedValue result(scope, Object::virtualGet(m, id, receiver, &hasProp));
diff --git a/src/qml/jsruntime/qv4qmlcontext_p.h b/src/qml/jsruntime/qv4qmlcontext_p.h
index 4fe34a0a06..dd6de3323d 100644
--- a/src/qml/jsruntime/qv4qmlcontext_p.h
+++ b/src/qml/jsruntime/qv4qmlcontext_p.h
@@ -66,7 +66,12 @@ struct QQmlContextWrapper;
namespace Heap {
-struct QQmlContextWrapper : Object {
+#define QQmlContextWrapperMembers(class, Member) \
+ Member(class, Pointer, Module *, module)
+
+DECLARE_HEAP_OBJECT(QQmlContextWrapper, Object) {
+ DECLARE_MARKOBJECTS(QQmlContextWrapper);
+
void init(QQmlContextData *context, QObject *scopeObject);
void destroy();
diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp
index fb6d9478db..97254b9172 100644
--- a/src/qml/memory/qv4mm.cpp
+++ b/src/qml/memory/qv4mm.cpp
@@ -666,11 +666,10 @@ HeapItem *HugeItemAllocator::allocate(size_t size) {
Chunk *c = nullptr;
if (size >= MemorySegment::SegmentSize/2) {
// too large to handle through the ChunkAllocator, let's get our own memory segement
- size_t segmentSize = size + Chunk::HeaderSize; // space required for the Chunk header
+ size += Chunk::HeaderSize; // space required for the Chunk header
size_t pageSize = WTF::pageSize();
- segmentSize = (segmentSize + pageSize - 1) & ~(pageSize - 1); // align to page sizes
- m = new MemorySegment(segmentSize);
size = (size + pageSize - 1) & ~(pageSize - 1); // align to page sizes
+ m = new MemorySegment(size);
c = m->allocate(size);
} else {
c = chunkAllocator->allocate(size);
diff --git a/src/qml/qml/qqmlinfo.cpp b/src/qml/qml/qqmlinfo.cpp
index c8f5ba506f..6322302422 100644
--- a/src/qml/qml/qqmlinfo.cpp
+++ b/src/qml/qml/qqmlinfo.cpp
@@ -50,6 +50,12 @@
QT_BEGIN_NAMESPACE
/*!
+ \namespace QtQml
+ \inmodule QtQml
+ \brief Provides functions for producing logging messages for QML types.
+*/
+
+/*!
\fn QQmlInfo QtQml::qmlDebug(const QObject *object)
\relates QQmlEngine
\since 5.9
@@ -57,6 +63,7 @@ QT_BEGIN_NAMESPACE
Prints debug messages that include the file and line number for the
specified QML \a object.
+//! [qqmlinfo-desc]
When QML types produce logging messages, it improves traceability
if they include the QML file and line number on which the
particular instance was instantiated.
@@ -65,6 +72,7 @@ QT_BEGIN_NAMESPACE
the file and line number is not available for that instance
(either it was not instantiated by the QML engine or location
information is disabled), "unknown location" will be used instead.
+//! [qqmlinfo-desc]
For example,
@@ -74,7 +82,7 @@ QT_BEGIN_NAMESPACE
prints
- \code
+ \badcode
QML MyCustomType (unknown location): Internal state: 42
\endcode
@@ -88,14 +96,7 @@ QT_BEGIN_NAMESPACE
Prints informational messages that include the file and line number for the
specified QML \a object.
- When QML types produce logging messages, it improves traceability
- if they include the QML file and line number on which the
- particular instance was instantiated.
-
- To include the file and line number, an object must be passed. If
- the file and line number is not available for that instance
- (either it was not instantiated by the QML engine or location
- information is disabled), "unknown location" will be used instead.
+ \include qqmlinfo.cpp qqmlinfo-desc
For example,
@@ -105,7 +106,7 @@ QT_BEGIN_NAMESPACE
prints
- \code
+ \badcode
QML MyCustomType (unknown location): component property is a write-once property
\endcode
@@ -116,7 +117,6 @@ QT_BEGIN_NAMESPACE
\sa QtQml::qmlDebug, QtQml::qmlWarning
*/
-
/*!
\fn QQmlInfo QtQml::qmlWarning(const QObject *object)
\relates QQmlEngine
@@ -125,14 +125,7 @@ QT_BEGIN_NAMESPACE
Prints warning messages that include the file and line number for the
specified QML \a object.
- When QML types produce logging messages, it improves traceability
- if they include the QML file and line number on which the
- particular instance was instantiated.
-
- To include the file and line number, an object must be passed. If
- the file and line number is not available for that instance
- (either it was not instantiated by the QML engine or location
- information is disabled), "unknown location" will be used instead.
+ \include qqmlinfo.cpp qqmlinfo-desc
For example,
@@ -142,13 +135,43 @@ QT_BEGIN_NAMESPACE
prints
- \code
+ \badcode
QML MyCustomType (unknown location): property cannot be set to 0
\endcode
\sa QtQml::qmlDebug, QtQml::qmlInfo
*/
+/*!
+ \fn QQmlInfo QtQml::qmlDebug(const QObject *object, const QQmlError &error)
+ \internal
+*/
+
+/*!
+ \fn QQmlInfo QtQml::qmlDebug(const QObject *object, const QList<QQmlError> &errors)
+ \internal
+*/
+
+/*!
+ \fn QQmlInfo QtQml::qmlInfo(const QObject *object, const QQmlError &error)
+ \internal
+*/
+
+/*!
+ \fn QQmlInfo QtQml::qmlInfo(const QObject *object, const QList<QQmlError> &errors)
+ \internal
+*/
+
+/*!
+ \fn QQmlInfo QtQml::qmlWarning(const QObject *object, const QQmlError &error)
+ \internal
+*/
+
+/*!
+ \fn QQmlInfo QtQml::qmlWarning(const QObject *object, const QList<QQmlError> &errors)
+ \internal
+*/
+
class QQmlInfoPrivate
{
public:
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 89b023c164..7480475ca7 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -2881,30 +2881,9 @@ void QQmlTypeData::scriptImported(const QQmlRefPointer<QQmlScriptBlob> &blob, co
QQmlScriptData::QQmlScriptData()
: typeNameCache(nullptr)
, m_loaded(false)
- , m_program(nullptr)
{
}
-QQmlScriptData::~QQmlScriptData()
-{
- delete m_program;
-}
-
-void QQmlScriptData::initialize(QQmlEngine *engine)
-{
- Q_ASSERT(!m_program);
- Q_ASSERT(engine);
- Q_ASSERT(!hasEngine());
-
- QV4::ExecutionEngine *v4 = engine->handle();
-
- m_program = new QV4::Script(v4, nullptr, m_precompiledScript);
-
- addToEngine(engine);
-
- addref();
-}
-
QQmlContextData *QQmlScriptData::qmlContextDataForContext(QQmlContextData *parentQmlContextData)
{
Q_ASSERT(parentQmlContextData && parentQmlContextData->engine);
@@ -2954,57 +2933,54 @@ QQmlContextData *QQmlScriptData::qmlContextDataForContext(QQmlContextData *paren
return qmlContextData;
}
-QV4::ReturnedValue QQmlScriptData::scriptValueForContext(QQmlContextData *parentCtxt)
+QV4::ReturnedValue QQmlScriptData::scriptValueForContext(QQmlContextData *parentQmlContextData)
{
if (m_loaded)
return m_value.value();
- Q_ASSERT(parentCtxt && parentCtxt->engine);
- QV4::ExecutionEngine *v4 = parentCtxt->engine->handle();
-
- if (m_precompiledScript->isESModule()) {
- m_loaded = true;
-
- m_value.set(v4, m_precompiledScript->instantiate(v4));
- if (!m_value.isNullOrUndefined())
- m_precompiledScript->evaluate();
+ Q_ASSERT(parentQmlContextData && parentQmlContextData->engine);
+ QV4::ExecutionEngine *v4 = parentQmlContextData->engine->handle();
+ QV4::Scope scope(v4);
- return m_value.value();
+ if (!hasEngine()) {
+ addToEngine(parentQmlContextData->engine);
+ addref();
}
- QQmlEnginePrivate *ep = QQmlEnginePrivate::get(parentCtxt->engine);
- QV4::Scope scope(v4);
-
- // Create the script context if required
- QQmlContextDataRef ctxt(qmlContextDataForContext(parentCtxt));
+ QQmlContextDataRef qmlContextData = qmlContextDataForContext(parentQmlContextData);
+ QV4::Scoped<QV4::QmlContext> qmlExecutionContext(scope);
+ if (qmlContextData)
+ qmlExecutionContext =
+ QV4::QmlContext::create(v4->rootContext(), qmlContextData, /* scopeObject: */ nullptr);
- if (!hasEngine())
- initialize(parentCtxt->engine);
+ QV4::Scoped<QV4::Module> module(scope, m_precompiledScript->instantiate(v4));
+ if (module) {
+ if (qmlContextData) {
+ module->d()->scope->outer.set(v4, qmlExecutionContext->d());
+ qmlExecutionContext->d()->qml()->module.set(v4, module->d());
+ }
- if (!m_program) {
- if (m_precompiledScript->isSharedLibrary())
- m_loaded = true;
- return QV4::Encode::undefined();
+ module->evaluate();
}
- QV4::Scoped<QV4::QmlContext> qmlContext(scope, QV4::QmlContext::create(v4->rootContext(), ctxt, nullptr));
-
- m_program->qmlContext.set(scope.engine, qmlContext);
- m_program->run();
- m_program->qmlContext.clear();
- if (scope.engine->hasException) {
- QQmlError error = scope.engine->catchExceptionAsQmlError();
+ if (v4->hasException) {
+ QQmlError error = v4->catchExceptionAsQmlError();
if (error.isValid())
- ep->warning(error);
+ QQmlEnginePrivate::get(v4)->warning(error);
}
- QV4::ScopedValue retval(scope, qmlContext->d()->qml());
- if (m_precompiledScript->isSharedLibrary()) {
- m_value.set(scope.engine, retval);
+ QV4::ScopedValue value(scope);
+ if (qmlContextData)
+ value = qmlExecutionContext->d()->qml();
+ else if (module)
+ value = module->d();
+
+ if (m_precompiledScript->isSharedLibrary() || m_precompiledScript->isESModule()) {
m_loaded = true;
+ m_value.set(v4, value);
}
- return retval->asReturnedValue();
+ return value->asReturnedValue();
}
void QQmlScriptData::clear()
diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h
index 29c91346de..5bb4e9d490 100644
--- a/src/qml/qml/qqmltypeloader_p.h
+++ b/src/qml/qml/qqmltypeloader_p.h
@@ -534,8 +534,6 @@ private:
QQmlScriptData();
public:
- ~QQmlScriptData() override;
-
QUrl url;
QString urlString;
QQmlTypeNameCache *typeNameCache;
@@ -556,7 +554,6 @@ private:
bool m_loaded;
QQmlRefPointer<QV4::CompiledData::CompilationUnit> m_precompiledScript;
- QV4::Script *m_program;
QV4::PersistentValue m_value;
};
diff --git a/src/qml/types/qqmldelegatecomponent.cpp b/src/qml/types/qqmldelegatecomponent.cpp
index 007e8e2ec6..470f6cab6a 100644
--- a/src/qml/types/qqmldelegatecomponent.cpp
+++ b/src/qml/types/qqmldelegatecomponent.cpp
@@ -66,9 +66,9 @@ QVariant QQmlAbstractDelegateComponent::value(QQmlAdaptorModel *adaptorModel, in
To use this module, import the module with the following line:
- \code
+ \qml
import Qt.labs.qmlmodels 1.0
- \endcode
+ \endqml
*/
/*!
@@ -79,6 +79,7 @@ QVariant QQmlAbstractDelegateComponent::value(QQmlAdaptorModel *adaptorModel, in
The DelegateChoice type wraps a delegate and defines the circumstances
in which it should be chosen.
+
DelegateChoices can be nested inside a DelegateChooser.
\sa DelegateChooser
@@ -86,7 +87,7 @@ QVariant QQmlAbstractDelegateComponent::value(QQmlAdaptorModel *adaptorModel, in
/*!
\qmlproperty string QtQml.Models::DelegateChoice::roleValue
- This property holds the value used to match the role data for the role provided by \l DefaultDelegateChooser::role.
+ This property holds the value used to match the role data for the role provided by \l DelegateChooser::role.
*/
QVariant QQmlDelegateChoice::roleValue() const
{
@@ -106,20 +107,20 @@ void QQmlDelegateChoice::setRoleValue(const QVariant &value)
\qmlproperty index QtQml.Models::DelegateChoice::row
This property holds the value used to match the row value of model elements.
With models that have only the index property (and thus only one column), this property
- should be intended as index, and set to the desired index value.
+ should be intended as an index, and set to the desired index value.
\note Setting both row and index has undefined behavior. The two are equivalent and only
one should be used.
- \sa QtQml.Models::DelegateChoice::index
+ \sa index
*/
/*!
\qmlproperty index QtQml.Models::DelegateChoice::index
This property holds the value used to match the index value of model elements.
- This is effectively an alias for \l QtQml.Models::DelegateChoice::row
+ This is effectively an alias for \l row.
- \sa QtQml.Models::DelegateChoice::row
+ \sa row
*/
int QQmlDelegateChoice::row() const
{
@@ -190,14 +191,14 @@ bool QQmlDelegateChoice::match(int row, int column, const QVariant &value) const
}
/*!
- \qmltype QQmlDelegateChooser
+ \qmltype DelegateChooser
\instantiates QQmlDelegateChooser
\inqmlmodule Qt.labs.qmlmodels
\brief Allows a view to use different delegates for different types of items in the model.
The DelegateChooser is a special \l Component type intended for those scenarios where a Component is required
by a view and used as a delegate.
- DelegateChooser encapsulates a set of \l DelegateChoices.
+ DelegateChooser encapsulates a set of \l {DelegateChoice}s.
These choices are used determine the delegate that will be instantiated for each
item in the model.
The selection of the choice is performed based on the value that a model item has for \l role,
@@ -227,13 +228,14 @@ void QQmlDelegateChooser::setRole(const QString &role)
/*!
\qmlproperty list<DelegateChoice> QtQml.Models::DelegateChooser::choices
\default
+
The list of DelegateChoices for the chooser.
The list is treated as an ordered list, where the first DelegateChoice to match
will be used be a view.
It should not generally be necessary to refer to the \c choices property,
- as it is the default property for DefaultDelegateChooser and thus all child items are
+ as it is the default property for DelegateChooser and thus all child items are
automatically assigned to this property.
*/
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp
index 243a7ce749..8a0d60a092 100644
--- a/src/qml/types/qqmldelegatemodel.cpp
+++ b/src/qml/types/qqmldelegatemodel.cpp
@@ -437,8 +437,6 @@ void QQmlDelegateModel::setModel(const QVariant &model)
The delegate provides a template defining each item instantiated by a view.
The index is exposed as an accessible \c index property. Properties of the
model are also available depending upon the type of \l {qml-data-models}{Data Model}.
-
- \sa DelegateComponent
*/
QQmlComponent *QQmlDelegateModel::delegate() const
{
diff --git a/src/qml/types/qqmlitemselectionmodel.qdoc b/src/qml/types/qqmlitemselectionmodel.qdoc
index 7ddfd79217..43da4f7a55 100644
--- a/src/qml/types/qqmlitemselectionmodel.qdoc
+++ b/src/qml/types/qqmlitemselectionmodel.qdoc
@@ -52,7 +52,7 @@
It will trigger property binding updates every time \l selectionChanged()
is emitted, even though its value hasn't changed.
- \sa selection(), selectedIndexes, select(), selectionChanged()
+ \sa selection, selectedIndexes, select(), selectionChanged()
*/
/*!
@@ -235,5 +235,5 @@
Note that this signal will not be emitted when the item model is reset.
- \sa currentIndex(), setCurrentIndex(), selectionChanged()
+ \sa currentIndex, setCurrentIndex(), selectionChanged()
*/