diff options
-rw-r--r-- | backends/cloud/cloudmanager.cpp | 9 | ||||
-rw-r--r-- | gui/storagewizarddialog.cpp | 23 |
2 files changed, 31 insertions, 1 deletions
diff --git a/backends/cloud/cloudmanager.cpp b/backends/cloud/cloudmanager.cpp index 8b7230fb5c..ed48ec5079 100644 --- a/backends/cloud/cloudmanager.cpp +++ b/backends/cloud/cloudmanager.cpp @@ -128,7 +128,14 @@ void CloudManager::replaceStorage(Storage *storage, uint32 index) { freeStorages(); if (!storage) error("CloudManager::replaceStorage: NULL storage passed"); if (index >= kStorageTotal) error("CloudManager::replaceStorage: invalid index passed"); - delete _activeStorage; + if (_activeStorage != nullptr && _activeStorage->isWorking()) { + warning("CloudManager::replaceStorage: replacing Storage while the other is working"); + if (_activeStorage->isDownloading()) _activeStorage->cancelDownload(); + if (_activeStorage->isSyncing()) _activeStorage->cancelSync(); + removeStorage(_activeStorage); + } else { + delete _activeStorage; + } _activeStorage = storage; _currentStorageIndex = index; save(); diff --git a/gui/storagewizarddialog.cpp b/gui/storagewizarddialog.cpp index 393b8263ef..a8574ab7d2 100644 --- a/gui/storagewizarddialog.cpp +++ b/gui/storagewizarddialog.cpp @@ -74,6 +74,29 @@ StorageWizardDialog::StorageWizardDialog(uint32 storageId): void StorageWizardDialog::open() { Dialog::open(); + + if (CloudMan.isWorking()) { + bool doClose = true; + + MessageDialog alert(_("The other Storage is working. Do you want to interrupt it?"), _("Yes"), _("No")); + if (alert.runModal() == GUI::kMessageOK) { + if (CloudMan.isDownloading()) CloudMan.cancelDownload(); + if (CloudMan.isSyncing()) CloudMan.cancelSync(); + + // I believe it still would return `true` here, but just in case + if (CloudMan.isWorking()) { + MessageDialog alert2(_("Wait until current Storage finishes up and try again.")); + alert2.runModal(); + } else + doClose = false; + } + + if (doClose) { + close(); + return; + } + } + #ifdef USE_SDL_NET _stopServerOnClose = !LocalServer.isRunning(); LocalServer.start(); |