From 447501045b6fe14fdeff95823e2ea85416da7a77 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Mon, 5 May 2014 20:37:36 +0200 Subject: [PATCH] Fix crash with KDE network detection If the network connection status changed during authentication phase, Quassel would crash. This is caused by some old bits of code that still assume that there's always a Peer around, which is no longer the case after splitting off the AuthHandler. This commit fixes that issue. Thanks to shadeslayer for the report and really useful backtrace. --- src/client/coreconnection.cpp | 6 ++++-- src/common/authhandler.cpp | 12 ++++++++++++ src/common/authhandler.h | 2 ++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/client/coreconnection.cpp b/src/client/coreconnection.cpp index 36503854..4928a8bf 100644 --- a/src/client/coreconnection.cpp +++ b/src/client/coreconnection.cpp @@ -211,8 +211,10 @@ bool CoreConnection::isLocalConnection() const return false; if (currentAccount().isInternal()) return true; - if (_peer->isLocal()) - return true; + if (_authHandler) + return _authHandler->isLocal(); + if (_peer) + return _peer->isLocal(); return false; } diff --git a/src/common/authhandler.cpp b/src/common/authhandler.cpp index 9148e214..7c2905dd 100644 --- a/src/common/authhandler.cpp +++ b/src/common/authhandler.cpp @@ -18,6 +18,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ +#include + #include "authhandler.h" AuthHandler::AuthHandler(QObject *parent) @@ -43,6 +45,16 @@ void AuthHandler::setSocket(QTcpSocket *socket) } +bool AuthHandler::isLocal() const +{ + if (socket()) { + if (socket()->peerAddress() == QHostAddress::LocalHost || socket()->peerAddress() == QHostAddress::LocalHostIPv6) + return true; + } + return false; +} + + // Some errors (e.g. connection refused) don't trigger a disconnected() from the socket, so send this explicitly // (but make sure it's only sent once!) void AuthHandler::onSocketError(QAbstractSocket::SocketError error) diff --git a/src/common/authhandler.h b/src/common/authhandler.h index cfed51e4..cc03588e 100644 --- a/src/common/authhandler.h +++ b/src/common/authhandler.h @@ -36,6 +36,8 @@ public: QTcpSocket *socket() const; + bool isLocal() const; + virtual void handle(const Protocol::RegisterClient &) { invalidMessage(); } virtual void handle(const Protocol::ClientDenied &) { invalidMessage(); } virtual void handle(const Protocol::ClientRegistered &) { invalidMessage(); } -- 2.20.1