diff options
author | Petr Mrázek <peterix@gmail.com> | 2017-05-02 01:43:18 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2017-05-02 01:43:18 +0200 |
commit | 6a8bb3691b9e30bcb90003eead34b287010cf17f (patch) | |
tree | afe9068330e2c1971355938b2fef7d93c172a47c /application/MainWindow.cpp | |
parent | 0132fd99291e359aae4af184c5f57ace21bf9863 (diff) | |
download | MultiMC-6a8bb3691b9e30bcb90003eead34b287010cf17f.tar MultiMC-6a8bb3691b9e30bcb90003eead34b287010cf17f.tar.gz MultiMC-6a8bb3691b9e30bcb90003eead34b287010cf17f.tar.lz MultiMC-6a8bb3691b9e30bcb90003eead34b287010cf17f.tar.xz MultiMC-6a8bb3691b9e30bcb90003eead34b287010cf17f.zip |
GH-1874 do not allow updating while an instance is running
This is a nasty hack. Proper solution will require moving all
update related functionality out of the main window.
Running instances and updating should be mutually exclusive.
Diffstat (limited to 'application/MainWindow.cpp')
-rw-r--r-- | application/MainWindow.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp index 08afbbb3..4ec0af86 100644 --- a/application/MainWindow.cpp +++ b/application/MainWindow.cpp @@ -561,14 +561,17 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow updateNewsLabel(); } + if(BuildConfig.UPDATER_ENABLED) { + bool updatesAllowed = MMC->updatesAreAllowed(); + updatesAllowedChanged(updatesAllowed); // set up the updater object. auto updater = MMC->updateChecker(); connect(updater.get(), &UpdateChecker::updateAvailable, this, &MainWindow::updateAvailable); connect(updater.get(), &UpdateChecker::noUpdateFound, this, &MainWindow::updateNotAvailable); // if automatic update checks are allowed, start one. - if (MMC->settings()->get("AutoUpdate").toBool()) + if (MMC->settings()->get("AutoUpdate").toBool() && updatesAllowed) { updater->checkForUpdate(MMC->settings()->get("UpdateChannel").toString(), false); } @@ -795,6 +798,15 @@ void MainWindow::repopulateAccountsMenu() accountMenu->addAction(manageAccountsAction); } +void MainWindow::updatesAllowedChanged(bool allowed) +{ + if(!BuildConfig.UPDATER_ENABLED) + { + return; + } + ui->actionCheckUpdate->setEnabled(allowed); +} + /* * Assumes the sender is a QAction */ @@ -896,6 +908,11 @@ void MainWindow::updateNewsLabel() void MainWindow::updateAvailable(GoUpdate::Status status) { + if(!MMC->updatesAreAllowed()) + { + updateNotAvailable(); + return; + } UpdateDialog dlg; UpdateAction action = (UpdateAction)dlg.exec(); switch (action) @@ -955,6 +972,10 @@ void MainWindow::notificationsChanged() void MainWindow::downloadUpdates(GoUpdate::Status status) { + if(!MMC->updatesAreAllowed()) + { + return; + } qDebug() << "Downloading updates."; ProgressDialog updateDlg(this); status.rootPath = MMC->root(); |