fix: network requests timing out too early (#5729)
This commit is contained in:
@@ -30,22 +30,35 @@ NetworkTask::~NetworkTask()
|
||||
|
||||
void NetworkTask::run()
|
||||
{
|
||||
const auto &timeout = this->data_->timeout;
|
||||
if (timeout.has_value())
|
||||
{
|
||||
this->timer_ = new QTimer(this);
|
||||
this->timer_->setSingleShot(true);
|
||||
this->timer_->start(timeout.value());
|
||||
QObject::connect(this->timer_, &QTimer::timeout, this,
|
||||
&NetworkTask::timeout);
|
||||
}
|
||||
|
||||
this->reply_ = this->createReply();
|
||||
if (!this->reply_)
|
||||
{
|
||||
this->deleteLater();
|
||||
return;
|
||||
}
|
||||
|
||||
const auto &timeout = this->data_->timeout;
|
||||
if (timeout.has_value())
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
|
||||
QObject::connect(this->reply_, &QNetworkReply::requestSent, this,
|
||||
[this]() {
|
||||
const auto &timeout = this->data_->timeout;
|
||||
this->timer_ = new QTimer(this);
|
||||
this->timer_->setSingleShot(true);
|
||||
this->timer_->start(timeout.value());
|
||||
QObject::connect(this->timer_, &QTimer::timeout,
|
||||
this, &NetworkTask::timeout);
|
||||
});
|
||||
#else
|
||||
this->timer_ = new QTimer(this);
|
||||
this->timer_->setSingleShot(true);
|
||||
this->timer_->start(timeout.value());
|
||||
QObject::connect(this->timer_, &QTimer::timeout, this,
|
||||
&NetworkTask::timeout);
|
||||
#endif
|
||||
}
|
||||
|
||||
QObject::connect(this->reply_, &QNetworkReply::finished, this,
|
||||
&NetworkTask::finished);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user