From a071b431314816ce47b00918d8baddc0ec546eb1 Mon Sep 17 00:00:00 2001 From: Michael Marley Date: Fri, 5 Sep 2014 22:16:05 -0400 Subject: [PATCH] Do not emit messages if storing them in the DB failed If a message is not stored in the database, then some of its IDs (networkId at least) will be invalid. If this message is sent to clients, it will cause a nameless empty buffer to appear in the desktop client and will cause Quasseldroid to crash (of course.) Better behavior would be to simply not emit the message, since it can't be displayed properly anyway. --- src/core/coresession.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/core/coresession.cpp b/src/core/coresession.cpp index bd09d439..dba0b6f0 100644 --- a/src/core/coresession.cpp +++ b/src/core/coresession.cpp @@ -318,8 +318,8 @@ void CoreSession::processMessages() bufferInfo = Core::bufferInfo(user(), rawMsg.networkId, BufferInfo::StatusBuffer, ""); } Message msg(bufferInfo, rawMsg.type, rawMsg.text, rawMsg.sender, rawMsg.flags); - Core::storeMessage(msg); - emit displayMsg(msg); + if(Core::storeMessage(msg)) + emit displayMsg(msg); } else { QHash > bufferInfoCache; @@ -361,10 +361,11 @@ void CoreSession::processMessages() messages << msg; } - Core::storeMessages(messages); - // FIXME: extend protocol to a displayMessages(MessageList) - for (int i = 0; i < messages.count(); i++) { - emit displayMsg(messages[i]); + if(Core::storeMessages(messages)) { + // FIXME: extend protocol to a displayMessages(MessageList) + for (int i = 0; i < messages.count(); i++) { + emit displayMsg(messages[i]); + } } } _processMessages = false; -- 2.20.1