added a mutex lock in Core::bufferInfo()
[quassel.git] / src / core / core.cpp
index 2024387..2e3da6d 100644 (file)
@@ -49,6 +49,10 @@ Core::Core()
   : storage(0)
 {
   startTime = QDateTime::currentDateTime();  // for uptime :)
   : storage(0)
 {
   startTime = QDateTime::currentDateTime();  // for uptime :)
+
+  connect(&_storageSyncTimer, SIGNAL(timeout()),
+         this, SLOT(syncStorage()));
+  _storageSyncTimer.start(10 * 60 * 1000); // in msecs
 }
 
 void Core::init() {
 }
 
 void Core::init() {
@@ -95,6 +99,11 @@ Core::~Core() {
   qDeleteAll(sessions);
 }
 
   qDeleteAll(sessions);
 }
 
+void Core::syncStorage() {
+  QMutexLocker locker(&mutex);
+  return instance()->storage->sync();
+}
+
 void Core::restoreState() {
   if(instance()->sessions.count()) {
     qWarning() << qPrintable(tr("Calling restoreState() even though active sessions exist!"));
 void Core::restoreState() {
   if(instance()->sessions.count()) {
     qWarning() << qPrintable(tr("Calling restoreState() even though active sessions exist!"));
@@ -144,7 +153,7 @@ NetworkId Core::networkId(UserId user, const QString &network) {
 }
 
 BufferInfo Core::bufferInfo(UserId user, const NetworkId &networkId, const QString &buffer) {
 }
 
 BufferInfo Core::bufferInfo(UserId user, const NetworkId &networkId, const QString &buffer) {
-  //QMutexLocker locker(&mutex);
+  QMutexLocker locker(&mutex);
   return instance()->storage->getBufferInfo(user, networkId, buffer);
 }
 
   return instance()->storage->getBufferInfo(user, networkId, buffer);
 }