CLOUD: Check whether Storage is working when replacing it

We do that in CloudManager::replaceStorage(), but I've tried to
eliminate such possibility by adding a check in the StorageWizardDialog.
This commit is contained in:
Alexander Tkachev 2016-07-20 15:00:44 +06:00
parent f743b31963
commit b1264df120
2 changed files with 31 additions and 1 deletions

View file

@ -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();