fixing a big oopsie that would cause the creation of a new empty buffer on any observ...
authorMarcus Eggenberger <egs@quassel-irc.org>
Tue, 30 Dec 2008 12:55:18 +0000 (13:55 +0100)
committerMarcus Eggenberger <egs@quassel-irc.org>
Tue, 30 Dec 2008 12:55:18 +0000 (13:55 +0100)
This caused the backlog replay to not work properly

src/client/clientbacklogmanager.cpp
src/core/core.h
src/core/coresession.cpp
src/core/sqlitestorage.cpp
src/core/sqlitestorage.h
src/core/storage.h

index b698f4f..742d305 100644 (file)
@@ -38,9 +38,6 @@ ClientBacklogManager::ClientBacklogManager(QObject *parent)
 void ClientBacklogManager::receiveBacklog(BufferId bufferId, MsgId first, MsgId last, int limit, int additional, QVariantList msgs) {
   Q_UNUSED(first) Q_UNUSED(last) Q_UNUSED(limit) Q_UNUSED(additional)
 
-  if(msgs.isEmpty())
-    return;
-
   emit messagesReceived(bufferId, msgs.count());
 
   MessageList msglist;
index 8945b0e..1aa2fa3 100644 (file)
@@ -208,10 +208,11 @@ class Core : public QObject {
    *  \param networkId The network id
    *  \param type      The type of the buffer (StatusBuffer, Channel, etc.)
    *  \param buffer    The buffer name (if empty, the net's status buffer is returned)
+   *  \param create    Whether or not the buffer should be created if it doesnt exist
    *  \return The BufferInfo corresponding to the given network and buffer name, or 0 if not found
    */
-  static inline BufferInfo bufferInfo(UserId user, const NetworkId &networkId, BufferInfo::Type type, const QString &buffer = "") {
-    return instance()->storage->getBufferInfo(user, networkId, type, buffer);
+  static inline BufferInfo bufferInfo(UserId user, const NetworkId &networkId, BufferInfo::Type type, const QString &buffer = "", bool create = true) {
+    return instance()->storage->bufferInfo(user, networkId, type, buffer, create);
   }
 
   //! Get the unique BufferInfo for a bufferId
index 1e21b64..8237d25 100644 (file)
@@ -89,6 +89,7 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent)
 
   // init BacklogManager
   p->synchronize(_backlogManager);
+  p->dumpSyncMap(_backlogManager);
 
   // init IrcListHelper
   p->synchronize(ircListHelper());
@@ -381,7 +382,7 @@ void CoreSession::destroyNetwork(NetworkId id) {
 }
 
 void CoreSession::renameBuffer(const NetworkId &networkId, const QString &newName, const QString &oldName) {
-  BufferInfo bufferInfo = Core::bufferInfo(user(), networkId, BufferInfo::QueryBuffer, oldName);
+  BufferInfo bufferInfo = Core::bufferInfo(user(), networkId, BufferInfo::QueryBuffer, oldName, false);
   _bufferSyncer->renameBuffer(bufferInfo.bufferId(), newName);
 }
 
index 2876d5c..cbcacf7 100644 (file)
@@ -691,7 +691,7 @@ void SqliteStorage::createBuffer(UserId user, const NetworkId &networkId, Buffer
   watchQuery(query);
 }
 
-BufferInfo SqliteStorage::getBufferInfo(UserId user, const NetworkId &networkId, BufferInfo::Type type, const QString &buffer) {
+BufferInfo SqliteStorage::bufferInfo(UserId user, const NetworkId &networkId, BufferInfo::Type type, const QString &buffer, bool create) {
   QSqlQuery query(logDb());
   query.prepare(queryString("select_bufferByName"));
   query.bindValue(":networkid", networkId.toInt());
@@ -700,6 +700,9 @@ BufferInfo SqliteStorage::getBufferInfo(UserId user, const NetworkId &networkId,
   safeExec(query);
 
   if(!query.first()) {
+    if(!create)
+      return BufferInfo();
+
     createBuffer(user, networkId, type, buffer);
     safeExec(query);
     if(!query.first()) {
index 6ad80fe..25f25a5 100644 (file)
@@ -74,7 +74,7 @@ public slots:
   virtual void setPersistentChannelKey(UserId user, const NetworkId &networkId, const QString &channel, const QString &key);
 
   /* Buffer handling */
-  virtual BufferInfo getBufferInfo(UserId user, const NetworkId &networkId, BufferInfo::Type type, const QString &buffer = "");
+  virtual BufferInfo bufferInfo(UserId user, const NetworkId &networkId, BufferInfo::Type type, const QString &buffer = "", bool create = true);
   virtual BufferInfo getBufferInfo(UserId user, const BufferId &bufferId);
   virtual QList<BufferInfo> requestBuffers(UserId user);
   virtual QList<BufferId> requestBufferIdsForNetwork(UserId user, NetworkId networkId);
index 9612a59..5b86f87 100644 (file)
@@ -230,9 +230,10 @@ public slots:
    *  \param networkId The network id
    *  \param type      The type of the buffer (StatusBuffer, Channel, etc.)
    *  \param buffer  The buffer name (if empty, the net's status buffer is returned)
+   *  \param create    Whether or not the buffer should be created if it doesnt exist
    *  \return The BufferInfo corresponding to the given network and buffer name, or an invalid BufferInfo if not found
    */
-  virtual BufferInfo getBufferInfo(UserId user, const NetworkId &networkId, BufferInfo::Type type, const QString &buffer = "") = 0;
+  virtual BufferInfo bufferInfo(UserId user, const NetworkId &networkId, BufferInfo::Type type, const QString &buffer = "", bool create = true) = 0;
 
   //! Get the unique BufferInfo for a bufferId
   /** \param user      The core user who owns this buffername