Skip to content

Commit

Permalink
fix #275837, crash during the initialization of start center
Browse files Browse the repository at this point in the history
  • Loading branch information
vpereverzev committed Sep 11, 2020
1 parent a8a1554 commit 6cb94f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion mscore/downloadUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//=============================================================================

#include "downloadUtils.h"
#include <QTimer>

namespace Ms {

Expand Down Expand Up @@ -44,7 +45,7 @@ QByteArray DownloadUtils::returnData()
return sdata;
}

void DownloadUtils::download(bool showProgress)
void DownloadUtils::download(bool showProgress, const int timeOutMSecs)
{
QUrl url = QUrl::fromEncoded(_target.toLocal8Bit());
QNetworkRequest request(url);
Expand All @@ -55,6 +56,15 @@ void DownloadUtils::download(bool showProgress)
QObject::connect(&manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(downloadFinished(QNetworkReply*)));
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));

QTimer timer;
timer.setSingleShot(true);
timer.start(timeOutMSecs);
QObject::connect(&timer, &QTimer::timeout, this, [reply] () {
reply->abort();
});

QObject::connect(reply, &QNetworkReply::finished, &timer, &QTimer::stop);

if (showProgress) {
progressDialog = new QProgressDialog(static_cast<QWidget*>(parent()));
progressDialog->setWindowFlags(Qt::WindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowTitleHint));
Expand Down
2 changes: 1 addition & 1 deletion mscore/downloadUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class DownloadUtils : public QObject
void done();

public slots:
void download(bool showProgress = false);
void download(bool showProgress = false, const int timeOutMSecs = 20000);
void downloadFinished(QNetworkReply* data);
void downloadProgress(qint64 received, qint64 total);
};
Expand Down

0 comments on commit 6cb94f2

Please sign in to comment.