diff --git a/src/core/connection.cpp b/src/core/connection.cpp --- a/src/core/connection.cpp +++ b/src/core/connection.cpp @@ -176,19 +176,15 @@ serverAddress = connectionSettings.value(method, defaultAddressForTypeAndMethod(mConnectionType, method)).toString(); } - // create sockets if not yet done, note that this does not yet allow changing socket types on the fly - // but that's probably not something we need to support anyway - if (!mSocket) { - mSocket.reset(new QLocalSocket(this)); - connect(mSocket.data(), static_cast(&QLocalSocket::error), this, - [this](QLocalSocket::LocalSocketError) { - qCWarning(AKONADICORE_LOG) << mSocket->errorString() << mSocket->serverName(); - Q_EMIT socketError(mSocket->errorString()); - Q_EMIT socketDisconnected(); - }); - connect(mSocket.data(), &QLocalSocket::disconnected, this, &Connection::socketDisconnected); - connect(mSocket.data(), &QLocalSocket::readyRead, this, &Connection::handleIncomingData); - } + mSocket.reset(new QLocalSocket(this)); + connect(mSocket.data(), static_cast(&QLocalSocket::error), this, + [this](QLocalSocket::LocalSocketError) { + qCWarning(AKONADICORE_LOG) << mSocket->errorString() << mSocket->serverName(); + Q_EMIT socketError(mSocket->errorString()); + Q_EMIT socketDisconnected(); + }); + connect(mSocket.data(), &QLocalSocket::disconnected, this, &Connection::socketDisconnected); + connect(mSocket.data(), &QLocalSocket::readyRead, this, &Connection::handleIncomingData); // actually do connect qCDebug(AKONADICORE_LOG) << "connectToServer" << serverAddress; @@ -249,7 +245,6 @@ if (mSocket) { mSocket->close(); - mSocket->readAll(); mSocket.reset(); } } @@ -282,7 +277,6 @@ if (!cmd || (cmd->type() == Protocol::Command::Invalid)) { qCWarning(AKONADICORE_LOG) << "Invalid command, the world is going to end!"; mSocket->close(); - mSocket->readAll(); reconnect(); return; } @@ -340,14 +334,12 @@ } catch (const Akonadi::ProtocolException &e) { qCWarning(AKONADICORE_LOG) << "Protocol Exception:" << QString::fromUtf8(e.what()); mSocket->close(); - mSocket->readAll(); reconnect(); return; } if (!mSocket->waitForBytesWritten()) { qCWarning(AKONADICORE_LOG) << "Socket write timeout"; mSocket->close(); - mSocket->readAll(); reconnect(); return; }