forked from qt-creator/qt-creator
FileDownloader: Do not assume existence of QQmlData
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 <henning.gruendl@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -258,18 +258,16 @@ void FileDownloader::doProbeUrl()
|
|||||||
QNetworkReply::connect(reply,
|
QNetworkReply::connect(reply,
|
||||||
&QNetworkReply::errorOccurred,
|
&QNetworkReply::errorOccurred,
|
||||||
this,
|
this,
|
||||||
[this](QNetworkReply::NetworkError) {
|
[this](QNetworkReply::NetworkError code) {
|
||||||
QQmlData *data = QQmlData::get(this, false);
|
|
||||||
if (!data) {
|
|
||||||
qDebug() << Q_FUNC_INFO << "FileDownloader is nullptr.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (QQmlData::wasDeleted(this)) {
|
if (QQmlData::wasDeleted(this)) {
|
||||||
qDebug() << Q_FUNC_INFO << "FileDownloader was deleted.";
|
qDebug() << Q_FUNC_INFO << "FileDownloader was deleted.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug() << Q_FUNC_INFO << "Network error:" << code
|
||||||
|
<< qobject_cast<QNetworkReply *>(sender())->errorString();
|
||||||
|
|
||||||
m_available = false;
|
m_available = false;
|
||||||
emit availableChanged();
|
emit availableChanged();
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user