aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2024-03-26 11:01:48 +0100
committerUlf Hermann <ulf.hermann@qt.io>2024-04-17 11:27:35 +0100
commit9e0fe0d9ec5edc47422eca94aa95ad804ca69a7a (patch)
tree1dc95544c5bf556a9aef47466fd876092639e8e5 /src/qml/qml
parent4f1c1ba238e382697cee636bb544e92532d9ba51 (diff)
QtQml: Uncruftify QQmlImports::getQmldirContent
Return early where possible and construct the errors using the correct URL right away. Change-Id: I91bc4e41d1baf910a341b68a5c137cd2e6c588ae Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qqmlimport.cpp18
-rw-r--r--src/qml/qml/qqmltypeloaderqmldircontent.cpp3
-rw-r--r--src/qml/qml/qqmltypeloaderqmldircontent_p.h2
3 files changed, 6 insertions, 17 deletions
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index 1e205be6cb..7002140362 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -949,21 +949,11 @@ bool QQmlImports::getQmldirContent(
Q_ASSERT(qmldir);
*qmldir = typeLoader->qmldirContent(qmldirIdentifier);
- if ((*qmldir).hasContent()) {
- // Ensure that parsing was successful
- if ((*qmldir).hasError()) {
- QUrl url = QUrl::fromLocalFile(qmldirIdentifier);
- const QList<QQmlError> qmldirErrors = (*qmldir).errors(uri);
- for (int i = 0; i < qmldirErrors.size(); ++i) {
- QQmlError error = qmldirErrors.at(i);
- error.setUrl(url);
- errors->append(error);
- }
- return false;
- }
- }
+ if (!qmldir->hasContent() || !qmldir->hasError())
+ return true;
- return true;
+ errors->append(qmldir->errors(uri, QUrl::fromLocalFile(qmldirIdentifier)));
+ return false;
}
QString QQmlImports::resolvedUri(const QString &dir_arg, QQmlImportDatabase *database)
diff --git a/src/qml/qml/qqmltypeloaderqmldircontent.cpp b/src/qml/qml/qqmltypeloaderqmldircontent.cpp
index 15767f01ad..5744cf2bb7 100644
--- a/src/qml/qml/qqmltypeloaderqmldircontent.cpp
+++ b/src/qml/qml/qqmltypeloaderqmldircontent.cpp
@@ -7,10 +7,9 @@
QT_BEGIN_NAMESPACE
-QList<QQmlError> QQmlTypeLoaderQmldirContent::errors(const QString &uri) const
+QList<QQmlError> QQmlTypeLoaderQmldirContent::errors(const QString &uri, const QUrl &url) const
{
QList<QQmlError> errors;
- const QUrl url(uri);
const auto parseErrors = m_parser.errors(uri);
for (const auto &parseError : parseErrors) {
QQmlError error;
diff --git a/src/qml/qml/qqmltypeloaderqmldircontent_p.h b/src/qml/qml/qqmltypeloaderqmldircontent_p.h
index 4d1f1967a1..421eb16da4 100644
--- a/src/qml/qml/qqmltypeloaderqmldircontent_p.h
+++ b/src/qml/qml/qqmltypeloaderqmldircontent_p.h
@@ -35,7 +35,7 @@ public:
bool hasContent() const { return m_hasContent; }
bool hasError() const { return m_parser.hasError(); }
- QList<QQmlError> errors(const QString &uri) const;
+ QList<QQmlError> errors(const QString &uri, const QUrl &url) const;
QString typeNamespace() const { return m_parser.typeNamespace(); }