aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/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/qml
parent87265c7ab8743ece92262cd6b79bbba9dddd1fe1 (diff)
parente3948955c961972d34483e7da9c2908f5cb84420 (diff)
Merge remote-tracking branch 'origin/5.12.0' into 5.12
Diffstat (limited to 'src/qml/qml')
-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
3 files changed, 74 insertions, 78 deletions
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;
};