aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/qml/CMakeLists.txt1
-rw-r--r--src/qml/qml/qqmlcomponent.cpp4
-rw-r--r--src/qml/qml/qqmlcomponent_p.h6
-rw-r--r--src/qml/qml/qqmlnotifyingblob.cpp46
-rw-r--r--src/qml/qml/qqmlnotifyingblob_p.h49
-rw-r--r--src/qml/qml/qqmlscriptblob.cpp2
-rw-r--r--src/qml/qml/qqmlscriptblob_p.h3
-rw-r--r--src/qml/qml/qqmltypedata.cpp41
-rw-r--r--src/qml/qml/qqmltypedata_p.h17
9 files changed, 108 insertions, 61 deletions
diff --git a/src/qml/CMakeLists.txt b/src/qml/CMakeLists.txt
index 211c097df5..8b1d428aab 100644
--- a/src/qml/CMakeLists.txt
+++ b/src/qml/CMakeLists.txt
@@ -295,6 +295,7 @@ qt_internal_add_qml_module(Qml
qml/qqmlmetatypedata.cpp qml/qqmlmetatypedata_p.h
qml/qqmlmoduleregistration.cpp qml/qqmlmoduleregistration.h
qml/qqmlnetworkaccessmanagerfactory.cpp qml/qqmlnetworkaccessmanagerfactory.h
+ qml/qqmlnotifyingblob.cpp qml/qqmlnotifyingblob_p.h
qml/qqmlnotifier.cpp qml/qqmlnotifier_p.h
qml/qqmlobjectcreator.cpp qml/qqmlobjectcreator_p.h
qml/qqmlobjectorgadget.cpp qml/qqmlobjectorgadget_p.h
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index 803521fa63..1dc73b9321 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -280,7 +280,7 @@ V4_DEFINE_EXTENSION(QQmlComponentExtension, componentExtension);
\value Asynchronous Load/compile the component in a background thread.
*/
-void QQmlComponentPrivate::typeDataReady(QQmlTypeData *)
+void QQmlComponentPrivate::ready(QQmlNotifyingBlob *)
{
Q_Q(QQmlComponent);
@@ -292,7 +292,7 @@ void QQmlComponentPrivate::typeDataReady(QQmlTypeData *)
emit q->statusChanged(q->status());
}
-void QQmlComponentPrivate::typeDataProgress(QQmlTypeData *, qreal p)
+void QQmlComponentPrivate::progress(QQmlNotifyingBlob *, qreal p)
{
setProgress(p);
}
diff --git a/src/qml/qml/qqmlcomponent_p.h b/src/qml/qml/qqmlcomponent_p.h
index 8e4a35fc36..6a3bd592e5 100644
--- a/src/qml/qml/qqmlcomponent_p.h
+++ b/src/qml/qml/qqmlcomponent_p.h
@@ -37,7 +37,7 @@ class QQmlEngine;
class QQmlComponentAttached;
class Q_QML_EXPORT QQmlComponentPrivate
- : public QObjectPrivate, public QQmlTypeData::TypeDataCallback
+ : public QObjectPrivate, public QQmlNotifyingBlob::Callback
{
Q_DECLARE_PUBLIC(QQmlComponent)
@@ -144,8 +144,8 @@ public:
const QQmlRefPointer<QQmlContextData> &context,
const QQmlRefPointer<QQmlContextData> &forContext);
- void typeDataReady(QQmlTypeData *) override;
- void typeDataProgress(QQmlTypeData *, qreal) override;
+ void ready(QQmlNotifyingBlob *) final;
+ void progress(QQmlNotifyingBlob *, qreal) final;
void fromTypeData(const QQmlRefPointer<QQmlTypeData> &data);
diff --git a/src/qml/qml/qqmlnotifyingblob.cpp b/src/qml/qml/qqmlnotifyingblob.cpp
new file mode 100644
index 0000000000..fc46ae942f
--- /dev/null
+++ b/src/qml/qml/qqmlnotifyingblob.cpp
@@ -0,0 +1,46 @@
+// Copyright (C) 2025 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include "qqmlnotifyingblob_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QQmlNotifyingBlob::Callback::~Callback() = default;
+
+void QQmlNotifyingBlob::Callback::ready(QQmlNotifyingBlob *) {}
+void QQmlNotifyingBlob::Callback::progress(QQmlNotifyingBlob *, qreal) {}
+
+void QQmlNotifyingBlob::registerCallback(Callback *callback)
+{
+ assertEngineThread();
+ Q_ASSERT(!m_callbacks.contains(callback));
+ m_callbacks.append(callback);
+}
+
+void QQmlNotifyingBlob::unregisterCallback(Callback *callback)
+{
+ assertEngineThread();
+ Q_ASSERT(m_callbacks.contains(callback));
+ m_callbacks.removeOne(callback);
+ Q_ASSERT(!m_callbacks.contains(callback));
+}
+
+void QQmlNotifyingBlob::completed()
+{
+ assertEngineThread();
+ // Notify callbacks
+ while (!m_callbacks.isEmpty()) {
+ Callback *callback = m_callbacks.takeFirst();
+ callback->ready(this);
+ }
+}
+
+void QQmlNotifyingBlob::downloadProgressChanged(qreal p)
+{
+ assertEngineThread();
+
+ for (Callback *callback : std::as_const(m_callbacks))
+ callback->progress(this, p);
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlnotifyingblob_p.h b/src/qml/qml/qqmlnotifyingblob_p.h
new file mode 100644
index 0000000000..3273140020
--- /dev/null
+++ b/src/qml/qml/qqmlnotifyingblob_p.h
@@ -0,0 +1,49 @@
+// Copyright (C) 2025 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef QQMLNOTIFYINGBLOB_P_H
+#define QQMLNOTIFYINGBLOB_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qqmltypeloader_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_QML_EXPORT QQmlNotifyingBlob : public QQmlTypeLoader::Blob
+{
+public:
+ QQmlNotifyingBlob(const QUrl &url, QQmlDataBlob::Type type, QQmlTypeLoader *loader)
+ : Blob(url, type, loader)
+ {}
+
+ struct Q_QML_EXPORT Callback
+ {
+ virtual ~Callback();
+ virtual void ready(QQmlNotifyingBlob *);
+ virtual void progress(QQmlNotifyingBlob *, qreal);
+ };
+
+ void registerCallback(Callback *callback);
+ void unregisterCallback(Callback *callback);
+
+protected:
+ void completed() override;
+ void downloadProgressChanged(qreal) override;
+
+private:
+ QList<Callback *> m_callbacks;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLNOTIFYINGBLOB_P_H
diff --git a/src/qml/qml/qqmlscriptblob.cpp b/src/qml/qml/qqmlscriptblob.cpp
index bcd026b957..d6b1fe80c0 100644
--- a/src/qml/qml/qqmlscriptblob.cpp
+++ b/src/qml/qml/qqmlscriptblob.cpp
@@ -17,7 +17,7 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(DBG_DISK_CACHE, "qt.qml.diskcache")
QQmlScriptBlob::QQmlScriptBlob(const QUrl &url, QQmlTypeLoader *loader, IsESModule isESModule)
- : QQmlTypeLoader::Blob(url, JavaScriptFile, loader)
+ : QQmlNotifyingBlob(url, JavaScriptFile, loader)
, m_isModule(isESModule == IsESModule::Yes)
{
}
diff --git a/src/qml/qml/qqmlscriptblob_p.h b/src/qml/qml/qqmlscriptblob_p.h
index b0d67d9ce2..4d882b7f4f 100644
--- a/src/qml/qml/qqmlscriptblob_p.h
+++ b/src/qml/qml/qqmlscriptblob_p.h
@@ -16,12 +16,13 @@
//
#include <private/qqmltypeloader_p.h>
+#include <private/qqmlnotifyingblob_p.h>
QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(DBG_DISK_CACHE)
class QQmlScriptData;
-class Q_AUTOTEST_EXPORT QQmlScriptBlob : public QQmlTypeLoader::Blob
+class Q_AUTOTEST_EXPORT QQmlScriptBlob : public QQmlNotifyingBlob
{
private:
friend class QQmlTypeLoader;
diff --git a/src/qml/qml/qqmltypedata.cpp b/src/qml/qml/qqmltypedata.cpp
index 8e8ec60daa..0faed498fe 100644
--- a/src/qml/qml/qqmltypedata.cpp
+++ b/src/qml/qml/qqmltypedata.cpp
@@ -22,10 +22,6 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcCycle, "qt.qml.typeresolution.cycle", QtWarningMsg)
-QQmlTypeData::TypeDataCallback::~TypeDataCallback()
-{
-}
-
QString QQmlTypeData::TypeReference::qualifiedName() const
{
QString result;
@@ -37,7 +33,7 @@ QString QQmlTypeData::TypeReference::qualifiedName() const
}
QQmlTypeData::QQmlTypeData(const QUrl &url, QQmlTypeLoader *manager)
- : QQmlTypeLoader::Blob(url, QmlFile, manager),
+ : QQmlNotifyingBlob(url, QmlFile, manager),
m_typesResolved(false), m_implicitImportLoaded(false)
{
@@ -55,21 +51,6 @@ QV4::CompiledData::CompilationUnit *QQmlTypeData::compilationUnit() const
return m_compiledData.data();
}
-void QQmlTypeData::registerCallback(TypeDataCallback *callback)
-{
- assertEngineThread();
- Q_ASSERT(!m_callbacks.contains(callback));
- m_callbacks.append(callback);
-}
-
-void QQmlTypeData::unregisterCallback(TypeDataCallback *callback)
-{
- assertEngineThread();
- Q_ASSERT(m_callbacks.contains(callback));
- m_callbacks.removeOne(callback);
- Q_ASSERT(!m_callbacks.contains(callback));
-}
-
QQmlType QQmlTypeData::qmlType(const QString &inlineComponentName) const
{
if (inlineComponentName.isEmpty())
@@ -696,16 +677,6 @@ void QQmlTypeData::done()
}
}
-void QQmlTypeData::completed()
-{
- assertEngineThread();
- // Notify callbacks
- while (!m_callbacks.isEmpty()) {
- TypeDataCallback *callback = m_callbacks.takeFirst();
- callback->typeDataReady(this);
- }
-}
-
bool QQmlTypeData::loadImplicitImport()
{
assertTypeLoaderThread();
@@ -908,16 +879,6 @@ void QQmlTypeData::allDependenciesDone()
resolveTypes();
}
-void QQmlTypeData::downloadProgressChanged(qreal p)
-{
- assertEngineThread();
-
- for (int ii = 0; ii < m_callbacks.size(); ++ii) {
- TypeDataCallback *callback = m_callbacks.at(ii);
- callback->typeDataProgress(this, p);
- }
-}
-
QString QQmlTypeData::stringAt(int index) const
{
if (m_compiledData)
diff --git a/src/qml/qml/qqmltypedata_p.h b/src/qml/qml/qqmltypedata_p.h
index 53e0e80f6d..f480d26742 100644
--- a/src/qml/qml/qqmltypedata_p.h
+++ b/src/qml/qml/qqmltypedata_p.h
@@ -15,6 +15,7 @@
// We mean it.
//
+#include <private/qqmlnotifyingblob_p.h>
#include <private/qqmlsourcecoordinate_p.h>
#include <private/qqmltypeloader_p.h>
#include <private/qv4executablecompilationunit_p.h>
@@ -23,7 +24,7 @@ QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(lcCycle)
-class Q_AUTOTEST_EXPORT QQmlTypeData : public QQmlTypeLoader::Blob
+class Q_AUTOTEST_EXPORT QQmlTypeData : public QQmlNotifyingBlob
{
Q_DECLARE_TR_FUNCTIONS(QQmlTypeData)
public:
@@ -58,26 +59,16 @@ public:
QV4::CompiledData::CompilationUnit *compilationUnit() const;
- // Used by QQmlComponent to get notifications
- struct TypeDataCallback {
- virtual ~TypeDataCallback();
- virtual void typeDataProgress(QQmlTypeData *, qreal) {}
- virtual void typeDataReady(QQmlTypeData *) {}
- };
- void registerCallback(TypeDataCallback *);
- void unregisterCallback(TypeDataCallback *);
-
QQmlType qmlType(const QString &inlineComponentName = QString()) const;
QByteArray typeClassName() const { return m_typeClassName; }
SourceCodeData backupSourceCode() const { return m_backupSourceCode; }
protected:
void done() override;
- void completed() override;
+
void dataReceived(const SourceCodeData &) override;
void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *unit) override;
void allDependenciesDone() override;
- void downloadProgressChanged(qreal) override;
QString stringAt(int index) const override;
@@ -135,8 +126,6 @@ private:
CompilationUnitPtr m_compiledData;
- QList<TypeDataCallback *> m_callbacks;
-
bool m_implicitImportLoaded;
bool loadImplicitImport();
bool checkScripts();