X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fclient.cpp;h=73316ca42fe54ebce5def20b5a0de5db711032b9;hp=6b941c65f34eaf947a0c4c1a0e68cb0c8dca943f;hb=c0ca17fde48836a5d2e7ea9ceaaabcdd7225d9b8;hpb=017582b02dcf25ed4027c54fbcd652004b103f91 diff --git a/src/client/client.cpp b/src/client/client.cpp index 6b941c65..73316ca4 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -85,10 +85,10 @@ Buffer *Client::buffer(uint bufferUid) { Buffer *Client::buffer(BufferInfo id) { Buffer *buff = buffer(id.uid()); - + if(!buff) { Client *client = Client::instance(); - Buffer *buff = new Buffer(id, client); + buff = new Buffer(id, client); connect(buff, SIGNAL(userInput(BufferInfo, QString)), client, SLOT(userInput(BufferInfo, QString))); @@ -102,7 +102,7 @@ Buffer *Client::buffer(BufferInfo id) { client->_buffers[id.uid()] = buff; emit client->bufferUpdated(buff); } - + Q_ASSERT(buff); return buff; } @@ -144,10 +144,6 @@ Client::Client(QObject *parent) } Client::~Client() { -// since we're now the parent of buffers this should be no longer needed - -// foreach(Buffer *buf, buffers.values()) delete buf; // this is done by disconnectFromCore()! FIXME? -// Q_ASSERT(!buffers.count()); } void Client::init() { @@ -203,7 +199,6 @@ bool Client::isConnected() { void Client::connectToCore(const QVariantMap &conn) { // TODO implement SSL coreConnectionInfo = conn; - if(isConnected()) { emit coreConnectionError(tr("Already connected to Core!")); return; @@ -237,16 +232,9 @@ void Client::connectToCore(const QVariantMap &conn) { } void Client::disconnectFromCore() { - if(clientMode == RemoteCore) { - socket->close(); - //QAbstractSocket *sock = qobject_cast(socket); - //Q_ASSERT(sock); - //sock->disconnectFromHost(); - } else { - socket->close(); - //disconnectFromLocalCore(); + socket->close(); + if(clientMode == LocalCore) coreSocketDisconnected(); - } } void Client::coreSocketConnected() { @@ -267,17 +255,17 @@ void Client::coreSocketDisconnected() { /* 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 bufferInfos. - // So we cannot simply go through the array in a loop (or use qDeleteAll) for deletion... - while(!_buffers.empty()) { - delete _buffers.take(_buffers.keys()[0]); + + foreach(Buffer *buffer, _buffers.values()) { + delete buffer; } Q_ASSERT(_buffers.empty()); - while(!_networkInfo.empty()) { - delete _networkInfo.take(_networkInfo.keys()[0]); + foreach(NetworkInfo *networkinfo, _networkInfo.values()) { + delete networkinfo; } - + Q_ASSERT(_networkInfo.empty()); + coreConnectionInfo.clear(); sessionData.clear(); layoutQueue.clear();