[Pkg-owncloud-commits] [owncloud-client] 42/83: Make FolderMan a member of the application

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat May 31 11:31:42 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 8a671c40d10d49d91b81e6b3dd4c3d0cd6964072
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Mon May 26 14:34:08 2014 +0200

    Make FolderMan a member of the application
    
    The goal here is that it is going to be destroyed with the application
    It need to be destoyed so the folder are destroyed, which is required
    for properly finishing the sync while exiting.
    
    It must not be destroyed after the application because the QSQLite plugin
    may be already destroyed in that case.
    
    Since the constructor of FolderMan is called earlier, we can't call the
    config file too early
    
     fixes 1793
---
 src/mirall/application.h |  3 +++
 src/mirall/folderman.cpp | 22 ++++++++++------------
 src/mirall/folderman.h   |  9 +++++----
 3 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/src/mirall/application.h b/src/mirall/application.h
index f6c6f96..36d3baa 100644
--- a/src/mirall/application.h
+++ b/src/mirall/application.h
@@ -28,6 +28,7 @@
 #include "mirall/connectionvalidator.h"
 #include "mirall/progressdispatcher.h"
 #include "mirall/clientproxy.h"
+#include "mirall/folderman.h"
 
 class QMessageBox;
 class QSystemTrayIcon;
@@ -107,6 +108,8 @@ private:
 
     QTimer _checkConnectionTimer;
 
+    FolderMan folderManager;
+
     friend class ownCloudGui; // for _startupNetworkError
 };
 
diff --git a/src/mirall/folderman.cpp b/src/mirall/folderman.cpp
index b6f170d..6c4b1b8 100644
--- a/src/mirall/folderman.cpp
+++ b/src/mirall/folderman.cpp
@@ -41,13 +41,6 @@ FolderMan::FolderMan(QObject *parent) :
     QObject(parent),
     _syncEnabled( true )
 {
-    // if QDir::mkpath would not be so stupid, I would not need to have this
-    // duplication of folderConfigPath() here
-    MirallConfigFile cfg;
-    QDir storageDir(cfg.configPath());
-    storageDir.mkpath(QLatin1String("folders"));
-    _folderConfigPath = cfg.configPath() + QLatin1String("folders");
-
     _folderChangeSignalMapper = new QSignalMapper(this);
     connect(_folderChangeSignalMapper, SIGNAL(mapped(const QString &)),
             this, SIGNAL(folderSyncStateChange(const QString &)));
@@ -55,15 +48,14 @@ FolderMan::FolderMan(QObject *parent) :
     _folderWatcherSignalMapper = new QSignalMapper(this);
     connect(_folderWatcherSignalMapper, SIGNAL(mapped(const QString&)),
             this, SLOT(slotScheduleSync(const QString&)));
+
+    ne_sock_init();
+    Q_ASSERT(!_instance);
+    _instance = this;
 }
 
 FolderMan *FolderMan::instance()
 {
-    if(!_instance) {
-        _instance = new FolderMan;
-        ne_sock_init();
-    }
-
     return _instance;
 }
 
@@ -71,6 +63,7 @@ FolderMan::~FolderMan()
 {
     qDeleteAll(_folderMap);
     ne_sock_exit();
+    _instance = 0;
 }
 
 Mirall::Folder::Map FolderMan::map()
@@ -144,6 +137,11 @@ int FolderMan::setupFolders()
 
   unloadAllFolders();
 
+  MirallConfigFile cfg;
+  QDir storageDir(cfg.configPath());
+  storageDir.mkpath(QLatin1String("folders"));
+  _folderConfigPath = cfg.configPath() + QLatin1String("folders");
+
   QDir dir( _folderConfigPath );
   //We need to include hidden files just in case the alias starts with '.'
   dir.setFilter(QDir::Files | QDir::Hidden);
diff --git a/src/mirall/folderman.h b/src/mirall/folderman.h
index 109b068..0f4a79d 100644
--- a/src/mirall/folderman.h
+++ b/src/mirall/folderman.h
@@ -30,12 +30,13 @@ class SyncResult;
 
 namespace Mirall {
 
+class Application;
+
 class OWNCLOUDSYNC_EXPORT FolderMan : public QObject
 {
     Q_OBJECT
 public:
     static FolderMan* instance();
-    ~FolderMan();
 
     int setupFolders();
 
@@ -144,10 +145,10 @@ private:
     QQueue<QString> _scheduleQueue;
     QMap<QString, FolderWatcher*> _folderWatchers;
 
-
-    explicit FolderMan(QObject *parent = 0);
     static FolderMan *_instance;
-
+    explicit FolderMan(QObject *parent = 0);
+    ~FolderMan();
+    friend class Mirall::Application;
 };
 
 } // namespace Mirall

-- 
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