Really unload folders before reconfiguring.

This commit is contained in:
Klaas Freitag 2013-06-03 17:26:48 +02:00
parent 7c1f91abdd
commit 49b4c341ae
3 changed files with 22 additions and 11 deletions

View file

@ -79,20 +79,28 @@ void FolderMan::slotReparseConfiguration()
setupKnownFolders(); setupKnownFolders();
} }
int FolderMan::unloadAllFolders()
int FolderMan::setupKnownFolders()
{ {
qDebug() << "* Setup folders from " << _folderConfigPath;
// first terminate sync jobs. // first terminate sync jobs.
terminateCurrentSync(); terminateCurrentSync();
int cnt = 0;
// clear the list of existing folders. // clear the list of existing folders.
Folder::MapIterator i(_folderMap); Folder::MapIterator i(_folderMap);
while (i.hasNext()) { while (i.hasNext()) {
i.next(); i.next();
delete _folderMap.take( i.key() ); delete _folderMap.take( i.key() );
cnt++;
} }
return cnt;
}
int FolderMan::setupKnownFolders()
{
qDebug() << "* Setup folders from " << _folderConfigPath;
unloadAllFolders();
QDir dir( _folderConfigPath ); QDir dir( _folderConfigPath );
dir.setFilter(QDir::Files); dir.setFilter(QDir::Files);

View file

@ -104,6 +104,9 @@ public slots:
void terminateSyncProcess( const QString& alias = QString::null ); void terminateSyncProcess( const QString& alias = QString::null );
/* delete all folder objects */
int unloadAllFolders();
// if enabled is set to false, no new folders will start to sync. // if enabled is set to false, no new folders will start to sync.
// the current one will finish. // the current one will finish.
void setSyncEnabled( bool ); void setSyncEnabled( bool );

View file

@ -128,7 +128,7 @@ void OwncloudSetupWizard::slotAssistantFinished( int result )
bool acceptCfg = true; bool acceptCfg = true;
if( urlHasChanged ) { if( urlHasChanged ) {
_folderMan->terminateSyncProcess( QString::null ); // terminate the current sync. _folderMan->unloadAllFolders();
bool startFromScratch = _ocWizard->field( "OCSyncFromScratch" ).toBool(); bool startFromScratch = _ocWizard->field( "OCSyncFromScratch" ).toBool();
if( startFromScratch ) { if( startFromScratch ) {