4#include <private/qqmldatablob_p.h>
5#include <private/qqmlglobal_p.h>
6#include <private/qqmlprofiler_p.h>
7#include <private/qqmltypeloader_p.h>
8#include <private/qqmltypeloaderthread_p.h>
9#include <private/qqmlsourcecoordinate_p.h>
11#include <QtQml/qqmlengine.h>
13#include <qtqml_tracepoints_p.h>
16#define ASSERT_CALLBACK() do { if (!m_typeLoader || !m_typeLoader->m_thread->isThisThread()) qFatal("QQmlDataBlob: An API call was made outside a callback"); } while (false)
18#define ASSERT_CALLBACK()
66: m_typeLoader(
manager), m_type(
type), m_url(
url), m_finalUrl(
url), m_redirectCount(0),
79 cancelAllWaitingFor();
104 return m_data.status();
163 if (
p == 0xFF)
return 1.;
210 if (m_finalUrlString.
isEmpty())
211 m_finalUrlString = m_finalUrl.
toString();
213 return m_finalUrlString;
257 if (
error.url().isEmpty()) {
260 m_errors.
append(mutableError);
266 m_data.setStatus(
Error);
273 cancelAllWaitingFor();
284 e.setDescription(
error.message);
292 e.setDescription(description);
314 for (
const auto &existingDep: std::as_const(m_waitingFor))
315 if (existingDep.data() == blob)
320 m_waitingFor.append(blob);
327 m_data.setStatus(
Error);
355#if QT_CONFIG(qml_network)
368 const char *errorString =
nullptr;
369 switch (networkError) {
371 errorString =
"Network error";
374 errorString =
"Connection refused";
377 errorString =
"Remote host closed the connection";
380 errorString =
"Host not found";
383 errorString =
"Timeout";
391 errorString =
"Proxy error";
394 errorString =
"Access denied";
397 errorString =
"File not found";
400 errorString =
"Authentication required";
476void QQmlDataBlob::tryDone()
478 if (
status() !=
Loading && m_waitingFor.isEmpty() && !m_isDone) {
490 notifyAllWaitingOnMe();
495 qWarning(
"QQmlDataBlob: Dispatching completed");
503void QQmlDataBlob::cancelAllWaitingFor()
505 while (m_waitingFor.size()) {
508 Q_ASSERT(blob->m_waitingOnMe.contains(
this));
510 blob->m_waitingOnMe.removeOne(
this);
514void QQmlDataBlob::notifyAllWaitingOnMe()
519 Q_ASSERT(std::any_of(blob->m_waitingFor.constBegin(), blob->m_waitingFor.constEnd(),
522 blob->notifyComplete(
this);
535 for (
int i = 0;
i < m_waitingFor.size(); ++
i) {
536 if (m_waitingFor.at(
i).data() == blob) {
537 blobRef = m_waitingFor.takeAt(
i);
549 if (!
isError() && m_waitingFor.isEmpty())
552 m_inCallback =
false;
560 if (hasInlineSourceCode)
561 return inlineSourceCode;
571 if (
uchar *mappedData =
f.map(0, fileSize)) {
587 if (hasInlineSourceCode)
590 return fileInfo.lastModified();
595 if (hasInlineSourceCode)
597 return fileInfo.exists();
602 if (hasInlineSourceCode)
603 return inlineSourceCode.isEmpty();
604 return fileInfo.size() == 0;
\inmodule QtCore\reentrant
QString absoluteFilePath() const
Returns an absolute path including the file name.
qint64 size() const
Returns the file size in bytes.
qsizetype size() const noexcept
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
void reserve(qsizetype size)
void append(parameter_type t)
NetworkError
Indicates all possible error conditions found during the processing of the request.
@ ProxyConnectionRefusedError
@ ProxyConnectionClosedError
@ ProxyAuthenticationRequiredError
@ AuthenticationRequiredError
DataType
Specifies where URL interception is taking place.
QDateTime sourceTimeStamp() const
QString readAll(QString *error) const
The QQmlDataBlob encapsulates a data request that can be issued to a QQmlTypeLoader.
bool isLoading() const
Returns true if the status is Loading.
bool isError() const
Returns true if the status is Error.
qreal progress() const
Returns the data download progress from 0 to 1.
bool isCompleteOrError() const
Returns true if the status is Complete or Error.
bool isNull() const
Returns true if the status is Null.
void addDependency(QQmlDataBlob *)
Wait for blob to become complete or to error.
QList< QQmlError > errors() const
Return the errors on this blob.
bool isComplete() const
Returns true if the status is Complete.
QUrl url() const
Returns the physical url of the data.
QQmlTypeLoader * typeLoader() const
QUrl finalUrl() const
Returns the logical URL to be used for resolving further URLs referred to in the code.
Type
This enum describes the type of the data blob.
Status status() const
Returns the blob's status.
QList< QQmlDataBlob * > m_waitingOnMe
virtual void allDependenciesDone()
Called when all blobs waited for have completed.
QString finalUrlString() const
Returns the finalUrl() as a string.
bool isWaiting() const
Returns true if the status is WaitingForDependencies.
void startLoading()
Must be called before loading can occur.
virtual void dependencyError(QQmlDataBlob *)
Called if blob, which was previously waited for, has an error.
virtual void dependencyComplete(QQmlDataBlob *)
Called if blob, which was previously waited for, has completed.
virtual void completed()
Invoked on the main thread sometime after done() was called on the load thread.
Type type() const
Returns the type provided to the constructor.
QQmlDataBlob(const QUrl &, Type, QQmlTypeLoader *manager)
Create a new QQmlDataBlob for url and of the provided type.
void setError(const QQmlError &)
Mark this blob as having errors.
QString urlString() const
virtual void done()
Invoked once data has either been received or a network error occurred, and all dependencies are comp...
QQmlTypeLoader * m_typeLoader
Status
This enum describes the status of the data blob.
virtual void downloadProgressChanged(qreal)
Called when the download progress of this blob changes.
The QQmlEngine class provides an environment for instantiating QML components.
QUrl interceptUrl(const QUrl &url, QQmlAbstractUrlInterceptor::DataType type) const
Run the current URL interceptors on the given url of the given type and return the result.
The QQmlError class encapsulates a QML error.
QString toString() const
Returns the error as a human readable string.
void setUrl(const QUrl &)
Sets the url for the file that caused this error.
bool isThisThread() const
void callCompleted(const QQmlDataBlob::Ptr &b)
The QQmlTypeLoader class abstracts loading files and their dependencies over the network.
QQmlEngine * engine() const
Return the QQmlEngine associated with this loader.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString toString(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
Combined button and popup list for selecting options.
constexpr Initialization Uninitialized
DBusConnection const char DBusError * error
#define qCWarning(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLsizei GLsizei GLchar * source
QQmlEngine * qmlEngine(const QObject *obj)
#define ASSERT_CALLBACK()
#define DEFINE_BOOL_CONFIG_OPTION(name, var)
int qmlConvertSourceCoordinate< quint32, int >(quint32 n)
#define qPrintable(string)
QLatin1StringView QLatin1String
#define Q_TRACE_SCOPE(x,...)
QUrl url("example.com")
[constructor-url-reference]
QNetworkAccessManager manager
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept