From ea951bec1c4b84b739a9f435e0d17dbb99e4d724 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Mon, 23 Nov 2009 21:33:41 +0100
Subject: Test whether we have a session before sending stanzas.


diff --git a/Swiften/Client/Client.cpp b/Swiften/Client/Client.cpp
index 874e23b..3962281 100644
--- a/Swiften/Client/Client.cpp
+++ b/Swiften/Client/Client.cpp
@@ -89,6 +89,10 @@ void Client::closeConnection() {
 }
 
 void Client::send(boost::shared_ptr<Stanza> stanza) {
+	if (!isAvailable()) {
+		std::cerr << "Warning: Client: Trying to send a stanza while disconnected." << std::endl;
+		return;
+	}
 	session_->sendElement(stanza);
 }
 
@@ -189,6 +193,7 @@ void Client::handleSessionFinished(boost::shared_ptr<Error> error) {
 }
 
 void Client::handleNeedCredentials() {
+	assert(session_);
 	session_->sendCredentials(password_);
 }
 
-- 
cgit v0.10.2-6-g49f6