From 0cba5df52ef9e773aef1a301ca6a4cfe8199bfd1 Mon Sep 17 00:00:00 2001 From: Marcus Eggenberger Date: Fri, 3 Jun 2011 13:56:37 +0200 Subject: [PATCH] Fixes #960 - "Core crashes after deleting a Network without disconnecting the Network first" Note: this fixes the issue only in the 0.7 branch. Quassel Cores built from current git master will still crash. This is due to some unsave pointer handling in the new event system, which needs thorough fixing. --- src/core/coresession.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/core/coresession.cpp b/src/core/coresession.cpp index 3fd539ea..1e543e7d 100644 --- a/src/core/coresession.cpp +++ b/src/core/coresession.cpp @@ -481,7 +481,10 @@ void CoreSession::removeNetwork(NetworkId id) { return; if(net->connectionState() != Network::Disconnected) { - connect(net, SIGNAL(disconnected(NetworkId)), SLOT(destroyNetwork(NetworkId))); + // make sure we no longer receive data from the tcp buffer + disconnect(net, SIGNAL(displayMsg(NetworkId, Message::Type, BufferInfo::Type, const QString &, const QString &, const QString &, Message::Flags)), this, 0); + disconnect(net, SIGNAL(displayStatusMsg(QString)), this, 0); + connect(net, SIGNAL(disconnected(NetworkId)), this, SLOT(destroyNetwork(NetworkId))); net->disconnectFromIrc(); } else { destroyNetwork(id); @@ -492,6 +495,16 @@ void CoreSession::destroyNetwork(NetworkId id) { QList removedBuffers = Core::requestBufferIdsForNetwork(user(), id); Network *net = _networks.take(id); if(net && Core::removeNetwork(user(), id)) { + // make sure that all unprocessed RawMessages from this network are removed + QList::iterator messageIter = _messageQueue.begin(); + while(messageIter != _messageQueue.end()) { + if(messageIter->networkId == id) { + messageIter = _messageQueue.erase(messageIter); + } else { + messageIter++; + } + } + // remove buffers from syncer foreach(BufferId bufferId, removedBuffers) { _bufferSyncer->removeBuffer(bufferId); } -- 2.20.1