Skip to content

Commit c4d8bd2

Browse files
committed
Fix minor bugs when switching branches
1 parent 99f1620 commit c4d8bd2

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

mainwindow.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@ MainWindow::MainWindow(QWidget *parent) :
1616
ui->progressBar->setHidden(true);
1717
connect(ui->launchButton, &QPushButton::clicked, this, &MainWindow::launch);
1818

19-
#ifndef Q_OS_OSX
20-
ui->splash->setScaledContents(true);
21-
#endif
22-
2319
connect(&updater, &Updater::installed, [this]{ ui->progressBar->setHidden(true); ui->launchButton->setEnabled(true); });
24-
connect(&updater, &Updater::error, [this](QString error){ qDebug() << error; ui->errorLabel->setText(error); ui->launchButton->setEnabled(true); });
20+
connect(&updater, &Updater::error, [this](QString error){
21+
qDebug() << error; ui->errorLabel->setText(error); ui->progressBar->setHidden(true); ui->launchButton->setEnabled(true); });
2522
connect(&updater, &Updater::downloadProgress, [this](qint64 bytesReceived, qint64 bytesTotal){
2623
ui->progressBar->setHidden(false); ui->progressBar->setMaximum(bytesTotal); ui->progressBar->setValue(bytesReceived); });
2724

@@ -43,7 +40,8 @@ void MainWindow::on_optionsButton_clicked() {
4340
}
4441

4542
Configuration config(&updater.settings, dir.filePath(QStringLiteral("config.ini")));
46-
connect(&config, &Configuration::redownload, [this]{ ui->launchButton->setEnabled(false); updater.download(); });
43+
connect(&config, &Configuration::redownload, [this]{ ui->launchButton->setEnabled(false);
44+
ui->errorLabel->setText(QStringLiteral("")); updater.download(); ui->progressBar->setHidden(true); });
4745
config.exec();
4846
}
4947

mainwindow.ui

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
<property name="pixmap">
5454
<pixmap resource="resources.qrc">:/splash.png</pixmap>
5555
</property>
56+
<property name="scaledContents">
57+
<bool>true</bool>
58+
</property>
5659
<property name="alignment">
5760
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
5861
</property>

updater.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
Updater::Updater(QObject *parent) : QObject(parent)
2626
{
2727
connect(&net, &QNetworkAccessManager::sslErrors, [](QNetworkReply * reply, const QList<QSslError> & errors){Q_UNUSED(reply); qDebug() << errors;});
28+
29+
QNetworkRequest urequest(QStringLiteral("https://api.github.com/repos/LRFLEW/OpenRCT2Launcher/releases/latest"));
30+
update = net.get(urequest);
31+
connect(update, &QNetworkReply::finished, this, &Updater::receivedUpdate);
2832
}
2933

3034
void Updater::queryDownloads(QString flavor) {
@@ -47,15 +51,10 @@ void Updater::queryDownloads(QString flavor) {
4751
}
4852

4953
void Updater::download() {
50-
if (update != nullptr) update->abort(), update->deleteLater(), update = nullptr;
5154
if (api != nullptr) api->abort(), api->deleteLater(), api = nullptr;
5255
if (bundle != nullptr) bundle->abort(), bundle->deleteLater(), bundle = nullptr;
5356

5457
queryDownloads(QStringLiteral(OPENRCT2_FLAVOR));
55-
56-
QNetworkRequest urequest(QStringLiteral("https://api.github.com/repos/LRFLEW/OpenRCT2Launcher/releases/latest"));
57-
update = net.get(urequest);
58-
connect(update, &QNetworkReply::finished, this, &Updater::receivedUpdate);
5958
}
6059

6160
void Updater::receivedUpdate() {
@@ -105,8 +104,10 @@ void Updater::receivedUpdate() {
105104

106105
void Updater::receivedAPI() {
107106
if (api->error() != QNetworkReply::NoError) {
108-
emit error(api->errorString());
109-
api->deleteLater(), api = nullptr;
107+
if (api->error() != QNetworkReply::OperationCanceledError) {
108+
emit error(api->errorString());
109+
api->deleteLater(), api = nullptr;
110+
}
110111
return;
111112
}
112113

@@ -151,8 +152,10 @@ void Updater::receivedAPI() {
151152

152153
void Updater::receivedBundle() {
153154
if (bundle->error() != QNetworkReply::NoError) {
154-
emit error(bundle->errorString());
155-
bundle->deleteLater(), bundle = nullptr;
155+
if (bundle->error() != QNetworkReply::OperationCanceledError) {
156+
emit error(bundle->errorString());
157+
bundle->deleteLater(), bundle = nullptr;
158+
}
156159
return;
157160
}
158161

0 commit comments

Comments
 (0)