From 50aa8fedd246a33ac53ccc78adefb757dad0de23 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Thu, 20 Apr 2023 14:51:21 +0200 Subject: [PATCH] FileDownloader: Do not assume existence of QQmlData MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QQmlData::wasDeleted returns a sensible result, even when the QQmlData has not been created (for instance because the object was not instantiated by the QML engine). Checking the result of QQmlData::get is counterproductive, as FileDownloader objects are for instance created by ContentLibraryMaterialsModel::fetchBundleIcons, without going through the QML engine. Moreover, try to log some information about why we ended up with a network error. Task-number: QDS-9687 Change-Id: Icf7fba94a8a0552305ac39f2caa32426e58972a0 Reviewed-by: Henning Gründl Reviewed-by: Qt CI Bot --- src/plugins/qmldesigner/utils/filedownloader.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/plugins/qmldesigner/utils/filedownloader.cpp b/src/plugins/qmldesigner/utils/filedownloader.cpp index b5c735d87a8..20ba2b3eec9 100644 --- a/src/plugins/qmldesigner/utils/filedownloader.cpp +++ b/src/plugins/qmldesigner/utils/filedownloader.cpp @@ -258,18 +258,16 @@ void FileDownloader::doProbeUrl() QNetworkReply::connect(reply, &QNetworkReply::errorOccurred, this, - [this](QNetworkReply::NetworkError) { - QQmlData *data = QQmlData::get(this, false); - if (!data) { - qDebug() << Q_FUNC_INFO << "FileDownloader is nullptr."; - return; - } + [this](QNetworkReply::NetworkError code) { if (QQmlData::wasDeleted(this)) { qDebug() << Q_FUNC_INFO << "FileDownloader was deleted."; return; } + qDebug() << Q_FUNC_INFO << "Network error:" << code + << qobject_cast(sender())->errorString(); + m_available = false; emit availableChanged(); });