From b1264df120b6594a79d99cbb1cc5ef944fa2e448 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Wed, 20 Jul 2016 15:00:44 +0600 Subject: 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. --- backends/cloud/cloudmanager.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'backends/cloud') 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(); -- cgit v1.2.3