From: Manuel Nickschas Date: Wed, 20 Feb 2008 17:53:55 +0000 (+0000) Subject: This should fix duplicate messages that would occur when new messages arrived while... X-Git-Tag: 0.2.0-alpha1~17 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=4d159822323116d1a7c7464b2624da7b65035fd6 This should fix duplicate messages that would occur when new messages arrived while the backlog was still being requested. Breaks core protocol, because somebody *cough* forgot to serialize the MsgId of Message objects... --- diff --git a/src/client/buffer.cpp b/src/client/buffer.cpp index a6687ce8..d4ac2364 100644 --- a/src/client/buffer.cpp +++ b/src/client/buffer.cpp @@ -54,6 +54,10 @@ void Buffer::appendMsg(const Message &msg) { } void Buffer::prependMsg(const Message &msg) { + // check for duplicate first + if(contents().count() > 0 && msg.msgId() >= contents().first()->msgId()) { + return; + } updateActivityLevel(msg); layoutQueue.append(msg); } diff --git a/src/common/message.cpp b/src/common/message.cpp index 91e1f493..4b2dc4d3 100644 --- a/src/common/message.cpp +++ b/src/common/message.cpp @@ -176,7 +176,7 @@ QString Message::formattedToHtml(const QString &f) { */ QDataStream &operator<<(QDataStream &out, const Message &msg) { - out << (quint32)msg.timestamp().toTime_t() << (quint32)msg.type() << (quint8)msg.flags() + out << msg.msgId() << (quint32)msg.timestamp().toTime_t() << (quint32)msg.type() << (quint8)msg.flags() << msg.bufferInfo() << msg.sender().toUtf8() << msg.text().toUtf8(); return out; } @@ -187,7 +187,7 @@ QDataStream &operator>>(QDataStream &in, Message &msg) { quint32 ts; QByteArray s, m; BufferInfo buf; - in >> ts >> t >> f >> buf >> s >> m; + in >> msg._msgId >> ts >> t >> f >> buf >> s >> m; msg._type = (Message::Type)t; msg._flags = (quint8)f; msg._bufferInfo = buf; diff --git a/src/common/types.h b/src/common/types.h index 949306b8..e2acbeb3 100644 --- a/src/common/types.h +++ b/src/common/types.h @@ -37,6 +37,8 @@ class SignedId { inline bool operator==(const SignedId &other) const { return id == other.id; } inline bool operator!=(const SignedId &other) const { return id != other.id; } inline bool operator<(const SignedId &other) const { return id < other.id; } + inline bool operator>(const SignedId &other) const { return id > other.id; } + inline bool operator>=(const SignedId &other) const { return id >= other.id; } inline bool operator==(int i) const { return id == i; } inline bool operator!=(int i) const { return id != i; } inline bool operator<(int i) const { return id < i; } diff --git a/version.inc b/version.inc index 3c51ba90..f6a0f4be 100644 --- a/version.inc +++ b/version.inc @@ -5,14 +5,14 @@ quasselVersion = "0.2.0-pre"; quasselDate = "2008-02-20"; - quasselBuild = 564; + quasselBuild = 563; //! Minimum client build number the core needs - clientBuildNeeded = 559; + clientBuildNeeded = 563; clientVersionNeeded = quasselVersion; //! Minimum core build number the client needs - coreBuildNeeded = 559; + coreBuildNeeded = 563; coreVersionNeeded = quasselVersion; }