X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fclient.cpp;h=85096c7b0640bf17314f3205d60c9cc8e2bbbcab;hp=938d107218e59bb17724aa333ee1b220a5d84028;hb=4bdda41a706b963c0163d38764acb3ffea52f256;hpb=9693b5238b76e6348413d68fa8c6ffc8c64fc12f diff --git a/src/client/client.cpp b/src/client/client.cpp index 938d1072..85096c7b 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -114,9 +114,9 @@ void Client::init() { Client::~Client() { //delete mainUi; //delete _bufferModel; - foreach(Buffer *buf, buffers.values()) delete buf; + foreach(Buffer *buf, buffers.values()) delete buf; // this is done by disconnectFromCore()! ClientProxy::destroy(); - + Q_ASSERT(!buffers.count()); } BufferTreeModel *Client::bufferModel() { @@ -150,14 +150,6 @@ void Client::disconnectFromCore() { disconnectFromLocalCore(); coreSocketDisconnected(); } - /* Clear internal data. Hopefully nothing relies on it at this point. */ - coreConnectionInfo.clear(); - sessionData.clear(); - //foreach(Buffer *buf, buffers.values()) delete buf; - qDebug() << "barfoo"; - _bufferModel->clear(); - //qDeleteAll(buffers); - qDebug() << "foobar"; } void Client::coreSocketConnected() { @@ -173,6 +165,21 @@ void Client::coreSocketConnected() { void Client::coreSocketDisconnected() { connectedToCore = false; emit disconnected(); + /* Clear internal data. Hopefully nothing relies on it at this point. */ + _bufferModel->clear(); + // Buffers, if deleted, send a signal that causes their removal from buffers and bufferIds. + // So we cannot simply go through the array in a loop (or use qDeleteAll) for deletion... + while(buffers.count()) { delete buffers.take(buffers.keys()[0]); } + Q_ASSERT(!buffers.count()); // should be empty now! + Q_ASSERT(!bufferIds.count()); + coreConnectionInfo.clear(); + sessionData.clear(); + nicks.clear(); + netConnected.clear(); + netsAwaitingInit.clear(); + ownNick.clear(); + layoutQueue.clear(); + layoutTimer->stop(); } void Client::recvCoreState(const QVariant &state) { @@ -308,6 +315,7 @@ Buffer * Client::buffer(BufferId id) { connect(b, SIGNAL(userInput(BufferId, QString)), client, SLOT(userInput(BufferId, QString))); connect(b, SIGNAL(bufferUpdated(Buffer *)), client, SIGNAL(bufferUpdated(Buffer *))); connect(b, SIGNAL(bufferDestroyed(Buffer *)), client, SIGNAL(bufferDestroyed(Buffer *))); + connect(b, SIGNAL(bufferDestroyed(Buffer *)), client, SLOT(removeBuffer(Buffer *))); buffers[id] = b; emit client->bufferUpdated(b); } @@ -318,6 +326,11 @@ QList Client::allBufferIds() { return buffers.keys(); } +void Client::removeBuffer(Buffer *b) { + buffers.remove(b->bufferId()); + bufferIds.remove(b->bufferId().uid()); +} + void Client::recvNetworkState(QString net, QVariant state) { netsAwaitingInit.removeAll(net); netConnected[net] = true;