[Pkg-owncloud-commits] [owncloud-client] 198/332: FolderMan: Unload folder method added.

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Aug 14 21:06:59 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 997504c03cc6dee737097fd3f6e12be3d288c9a4
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Tue Jul 15 16:06:06 2014 +0200

    FolderMan: Unload folder method added.
    
    unloadFolder now correctly removes a folder from all maps and signal
    mappers.
---
 src/mirall/folderman.cpp | 28 +++++++++++++++++++++++++++-
 src/mirall/folderman.h   |  2 ++
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/src/mirall/folderman.cpp b/src/mirall/folderman.cpp
index 496608b..1acb038 100644
--- a/src/mirall/folderman.cpp
+++ b/src/mirall/folderman.cpp
@@ -69,6 +69,27 @@ Mirall::Folder::Map FolderMan::map()
     return _folderMap;
 }
 
+// Attention: this function deletes the folder object to which
+// the alias refers. Do NOT USE the folder pointer any more after
+// having this called.
+void FolderMan::unloadFolder( const QString& alias )
+{
+    Folder *f = 0;
+    if( _folderMap.contains(alias)) {
+        f = _folderMap[alias];
+    }
+    if( f ) {
+        _folderChangeSignalMapper->removeMappings(f);
+        if( _folderWatchers.contains(alias)) {
+            FolderWatcher *fw = _folderWatchers[alias];
+            _folderWatcherSignalMapper->removeMappings(fw);
+            _folderWatchers.remove(alias);
+        }
+        _folderMap.remove( alias );
+        delete f;
+    }
+}
+
 int FolderMan::unloadAllFolders()
 {
     int cnt = 0;
@@ -77,11 +98,13 @@ int FolderMan::unloadAllFolders()
     Folder::MapIterator i(_folderMap);
     while (i.hasNext()) {
         i.next();
-        delete _folderMap.take( i.key() );
+        unloadFolder(i.key());
         cnt++;
     }
     _currentSyncFolder.clear();
     _scheduleQueue.clear();
+
+    Q_ASSERT(_folderMap.count() == 0);
     return cnt;
 }
 
@@ -557,6 +580,9 @@ void FolderMan::removeFolder( const QString& alias )
             qDebug() << "Remove folder config file " << file.fileName();
             file.remove();
         }
+
+        unloadFolder( alias ); // now the folder object is gone.
+
         // FIXME: this is a temporar dirty fix against a crash happening because
         // the csync owncloud module still has static components. Activate the
         // delete once the module is fixed.
diff --git a/src/mirall/folderman.h b/src/mirall/folderman.h
index 82f6970..a78c547 100644
--- a/src/mirall/folderman.h
+++ b/src/mirall/folderman.h
@@ -101,6 +101,8 @@ public slots:
 
     void terminateSyncProcess( const QString& alias = QString::null );
 
+    /* unload and delete on folder object */
+    void unloadFolder( const QString& alias );
     /* delete all folder objects */
     int unloadAllFolders();
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list