diff --git a/src/templateselector.cpp b/src/templateselector.cpp index 1a63eb2a71..44826805b4 100644 --- a/src/templateselector.cpp +++ b/src/templateselector.cpp @@ -104,6 +104,10 @@ TemplateSelector::TemplateSelector(QString name, QWidget *parent) TemplateSelector::~TemplateSelector() { + if (networkManager) { + networkManager->deleteLater(); + networkManager=nullptr; + } } void TemplateSelector::addResource(AbstractTemplateResource *res) @@ -157,7 +161,10 @@ const QNetworkRequest::Attribute tplAttributeItem = static_castget(request); connect(reply, &QNetworkReply::finished, this, &TemplateSelector::onRequestCompleted); +#if QT_VERSION_MAJOR<6 + connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError())); +#else + connect(reply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), SLOT(onRequestError())); +#endif } /*! @@ -203,7 +215,6 @@ void TemplateSelector::saveToCache(const QByteArray &data, const QString &path) } } - void TemplateSelector::itemExpanded(QTreeWidgetItem* item){ bool populated=item->data(0,PopulatedRole).toBool(); if(populated) return; @@ -614,3 +625,15 @@ void TemplateSelector::openTemplateLocation() } } +void TemplateSelector::onRequestError() +{ + QNetworkReply *reply = qobject_cast(sender()); + if (!reply) return; + + QMessageBox::warning(this, tr("Browse template repository"), + tr("Repository not found. Network error:%1").arg("\n"+reply->errorString()), + QMessageBox::Ok, + QMessageBox::Ok); + networkManager->deleteLater(); + networkManager=nullptr; +} diff --git a/src/templateselector.h b/src/templateselector.h index a2a388fbe7..6a9ad4b89f 100644 --- a/src/templateselector.h +++ b/src/templateselector.h @@ -75,6 +75,7 @@ private slots: void editTemplateInfo(); void removeTemplate(); void openTemplateLocation(); + void onRequestError(); private: QString orDefault(const QString &val, const QString &defaultIfValEmpty) const