From: Christian Kamm Date: Tue, 8 Dec 2015 13:37:37 +0000 (+0100) Subject: AccountWizard: Don't crash when sync is running #4221 X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~1387^2~9 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=179b25d28923f26a208a5fd93e1137ae6bc9342c;p=nextcloud-desktop.git AccountWizard: Don't crash when sync is running #4221 Running FolderMan::setupFolders() is redundant and just a leftover from before multiaccount. --- diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index 128494002..ee1d73cf6 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -118,7 +118,7 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent) : connect(ui->selectiveSyncApply, SIGNAL(clicked()), _model, SLOT(slotApplySelectiveSync())); connect(ui->selectiveSyncCancel, SIGNAL(clicked()), _model, SLOT(resetFolders())); - connect(FolderMan::instance(), SIGNAL(folderListLoaded(Folder::Map)), _model, SLOT(resetFolders())); + connect(FolderMan::instance(), SIGNAL(folderListChanged(Folder::Map)), _model, SLOT(resetFolders())); connect(this, SIGNAL(folderChanged()), _model, SLOT(resetFolders())); diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 2d4622bf3..1182ecdd4 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -286,23 +286,39 @@ void Application::slotCrash() void Application::slotownCloudWizardDone( int res ) { + AccountManager *accountMan = AccountManager::instance(); FolderMan *folderMan = FolderMan::instance(); + + // During the wizard, scheduling of new syncs is disabled + folderMan->setSyncEnabled(true); + if( res == QDialog::Accepted ) { - int cnt = folderMan->setupFolders(); - qDebug() << "Set up " << cnt << " folders."; - // We have some sort of configuration. Enable autostart - Utility::setLaunchOnStartup(_theme->appName(), _theme->appNameGUI(), true); - if (cnt == 0) { - // The folder configuration was skipped - _gui->slotShowSettings(); + // Open the settings page for the new account if no folders + // were configured. Using the last account for this check is + // not exactly correct, but good enough. + if (!accountMan->accounts().isEmpty()) { + AccountStatePtr newAccount = accountMan->accounts().last(); + bool hasFolder = false; + foreach (Folder* folder, folderMan->map()) { + if (folder->accountState() == newAccount.data()) { + hasFolder = true; + break; + } + } + + if (!hasFolder) { + _gui->slotShowSettings(); + } } - } - folderMan->setSyncEnabled( true ); - if( res == QDialog::Accepted ) { + + // Check connectivity of the newly created account _checkConnectionTimer.start(); slotCheckConnection(); - } + // The very first time an account is configured: enabled autostart + // TODO: Doing this every time the account wizard finishes will annoy users. + Utility::setLaunchOnStartup(_theme->appName(), _theme->appNameGUI(), true); + } } void Application::setupLogging() diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index 18759a6f3..6ad1fa07b 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -216,7 +216,7 @@ int FolderMan::setupFolders() settings->endGroup(); // } - emit folderListLoaded(_folderMap); + emit folderListChanged(_folderMap); return _folderMap.size(); } @@ -245,7 +245,7 @@ int FolderMan::setupFoldersMigration() } } - emit folderListLoaded(_folderMap); + emit folderListChanged(_folderMap); // return the number of valid folders. return _folderMap.size(); @@ -775,6 +775,8 @@ Folder* FolderMan::addFolder(AccountState* accountState, const FolderDefinition& if(folder && accountState) { folder->setAccountState(accountState); folder->saveToSettings(); + emit folderSyncStateChange(folder); + emit folderListChanged(_folderMap); } return folder; } diff --git a/src/gui/folderman.h b/src/gui/folderman.h index b63e750d8..b120ea5b3 100644 --- a/src/gui/folderman.h +++ b/src/gui/folderman.h @@ -139,7 +139,7 @@ signals: */ void scheduleQueueChanged(); - void folderListLoaded(const Folder::Map &); + void folderListChanged(const Folder::Map &); public slots: void slotRemoveFolder( Folder* );