summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2012-03-06 08:59:26 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-03-06 08:59:26 (GMT)
commit54b16ff807d7f70ac7633292d773b7affece1c43 (patch)
tree566cecbcb46a0c67c48a1251361bee93b409d848 /Swiften/AdHoc/OutgoingAdHocCommandSession.cpp
parent3b308419485ce1ad50ee14488595a555777ef731 (diff)
downloadswift-54b16ff807d7f70ac7633292d773b7affece1c43.zip
swift-54b16ff807d7f70ac7633292d773b7affece1c43.tar.bz2
don't crash if an AdHoc is deleted while inflight
Diffstat (limited to 'Swiften/AdHoc/OutgoingAdHocCommandSession.cpp')
-rw-r--r--Swiften/AdHoc/OutgoingAdHocCommandSession.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/Swiften/AdHoc/OutgoingAdHocCommandSession.cpp b/Swiften/AdHoc/OutgoingAdHocCommandSession.cpp
index ecc6cd0..cd6b4a3 100644
--- a/Swiften/AdHoc/OutgoingAdHocCommandSession.cpp
+++ b/Swiften/AdHoc/OutgoingAdHocCommandSession.cpp
@@ -17,6 +17,10 @@ OutgoingAdHocCommandSession::OutgoingAdHocCommandSession(const JID& to, const st
}
+OutgoingAdHocCommandSession::~OutgoingAdHocCommandSession() {
+ connection_.disconnect();
+}
+
void OutgoingAdHocCommandSession::handleResponse(boost::shared_ptr<Command> payload, ErrorPayload::ref error) {
if (error) {
onError(error);
@@ -58,7 +62,7 @@ bool OutgoingAdHocCommandSession::getIsMultiStage() const {
void OutgoingAdHocCommandSession::start() {
boost::shared_ptr<GenericRequest<Command> > commandRequest = boost::make_shared< GenericRequest<Command> >(IQ::Set, to_, boost::make_shared<Command>(commandNode_), iqRouter_);
- commandRequest->onResponse.connect(boost::bind(&OutgoingAdHocCommandSession::handleResponse, this, _1, _2));
+ connection_ = commandRequest->onResponse.connect(boost::bind(&OutgoingAdHocCommandSession::handleResponse, this, _1, _2));
commandRequest->send();
}
@@ -84,7 +88,8 @@ void OutgoingAdHocCommandSession::submitForm(Form::ref form, Command::Action act
boost::shared_ptr<Command> command(boost::make_shared<Command>(commandNode_, sessionID_, action));
command->setForm(form);
boost::shared_ptr<GenericRequest<Command> > commandRequest = boost::make_shared< GenericRequest<Command> >(IQ::Set, to_, command, iqRouter_);
- commandRequest->onResponse.connect(boost::bind(&OutgoingAdHocCommandSession::handleResponse, this, _1, _2));
+ connection_.disconnect();
+ connection_ = commandRequest->onResponse.connect(boost::bind(&OutgoingAdHocCommandSession::handleResponse, this, _1, _2));
commandRequest->send();
}