X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcore%2Fsqlitestorage.cpp;h=fb9045241c88077054d274a31a92b848e76f0454;hb=76a276c472cb99032e2407d8e4bc2f2d693e8e67;hp=3176ec4b05318d8a8f472499504fc43f98cbda70;hpb=8ec76e512d20ce5d1dc76de556bb98a06b75d695;p=quassel.git diff --git a/src/core/sqlitestorage.cpp b/src/core/sqlitestorage.cpp index 3176ec4b..fb904524 100644 --- a/src/core/sqlitestorage.cpp +++ b/src/core/sqlitestorage.cpp @@ -619,13 +619,17 @@ QList SqliteStorage::requestMsgs(UserId user, BufferId bufferId, int la if(!bufferInfo.isValid()) return messagelist; - // we have to determine the real offset first - QSqlQuery *offsetQuery = cachedQuery("select_messagesOffset"); - offsetQuery->bindValue(":bufferid", bufferId.toInt()); - offsetQuery->bindValue(":messageid", offset); - offsetQuery->exec(); - offsetQuery->first(); - offset = offsetQuery->value(0).toInt(); + if(offset == -1) { + offset = 0; + } else { + // we have to determine the real offset first + QSqlQuery *offsetQuery = cachedQuery("select_messagesOffset"); + offsetQuery->bindValue(":bufferid", bufferId.toInt()); + offsetQuery->bindValue(":messageid", offset); + offsetQuery->exec(); + offsetQuery->first(); + offset = offsetQuery->value(0).toInt(); + } // now let's select the messages QSqlQuery *msgQuery = cachedQuery("select_messages");