From e32059da8bffc67806862bf78f762d67fb3e4848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Mon, 7 Dec 2009 19:23:22 +0100 Subject: Fixed segfault on disconnect. diff --git a/Swiften/Client/Client.cpp b/Swiften/Client/Client.cpp index e9de19a..27f3d9c 100644 --- a/Swiften/Client/Client.cpp +++ b/Swiften/Client/Client.cpp @@ -72,9 +72,10 @@ void Client::handleConnectorFinished(boost::shared_ptr connection) { void Client::disconnect() { if (session_) { session_->finish(); - session_.reset(); } - closeConnection(); + else { + closeConnection(); + } } void Client::closeConnection() { @@ -136,6 +137,7 @@ void Client::setCertificate(const String& certificate) { } void Client::handleSessionFinished(boost::shared_ptr error) { + session_.reset(); closeConnection(); if (error) { ClientError clientError; @@ -191,7 +193,6 @@ void Client::handleSessionFinished(boost::shared_ptr error) { } onError(clientError); } - session_.reset(); } void Client::handleNeedCredentials() { diff --git a/Swiften/Client/ClientSession.cpp b/Swiften/Client/ClientSession.cpp index 8427d27..16bda40 100644 --- a/Swiften/Client/ClientSession.cpp +++ b/Swiften/Client/ClientSession.cpp @@ -34,6 +34,9 @@ ClientSession::ClientSession( authenticator(NULL) { } +ClientSession::~ClientSession() { +} + void ClientSession::start() { stream->onStreamStartReceived.connect(boost::bind(&ClientSession::handleStreamStart, shared_from_this(), _1)); stream->onElementReceived.connect(boost::bind(&ClientSession::handleElement, shared_from_this(), _1)); diff --git a/Swiften/Client/ClientSession.h b/Swiften/Client/ClientSession.h index ef4d747..685672e 100644 --- a/Swiften/Client/ClientSession.h +++ b/Swiften/Client/ClientSession.h @@ -46,6 +46,7 @@ namespace Swift { Error(Type type) : type(type) {} }; + ~ClientSession(); static boost::shared_ptr create(const JID& jid, boost::shared_ptr stream) { return boost::shared_ptr(new ClientSession(jid, stream)); } -- cgit v0.10.2-6-g49f6