2002-05-26 13:02:17 +00:00
|
|
|
// Boost.Signals library
|
|
|
|
//
|
|
|
|
// Copyright (C) 2001 Doug Gregor (gregod@cs.rpi.edu)
|
|
|
|
//
|
|
|
|
// Permission to copy, use, sell and distribute this software is granted
|
|
|
|
// provided this copyright notice appears in all copies.
|
|
|
|
// Permission to modify the code and to distribute modified code is granted
|
|
|
|
// provided this copyright notice appears in all copies, and a notice
|
|
|
|
// that the code was modified is included with the copyright notice.
|
|
|
|
//
|
|
|
|
// This software is provided "as is" without express or implied warranty,
|
|
|
|
// and with no claim as to its suitability for any purpose.
|
|
|
|
|
|
|
|
// For more information, see http://www.boost.org
|
|
|
|
|
|
|
|
#include <boost/signals/connection.hpp>
|
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
namespace boost {
|
2002-06-18 15:39:27 +00:00
|
|
|
namespace BOOST_SIGNALS_NAMESPACE {
|
2002-05-26 13:02:17 +00:00
|
|
|
void connection::disconnect() const
|
|
|
|
{
|
|
|
|
if (this->connected()) {
|
|
|
|
// Make sure we have a reference to the basic_connection object,
|
|
|
|
// because 'this' may disappear
|
|
|
|
shared_ptr<detail::basic_connection> local_con = con;
|
|
|
|
|
|
|
|
void (*signal_disconnect)(void*, void*) = local_con->signal_disconnect;
|
|
|
|
|
|
|
|
// Note that this connection no longer exists
|
|
|
|
// Order is important here: we could get into an infinite loop if this
|
|
|
|
// isn't cleared before we try the disconnect.
|
|
|
|
local_con->signal_disconnect = 0;
|
|
|
|
|
|
|
|
// Disconnect signal
|
|
|
|
signal_disconnect(local_con->signal, local_con->signal_data);
|
|
|
|
|
|
|
|
// Disconnect all bound objects
|
2002-06-18 15:39:27 +00:00
|
|
|
typedef std::list<BOOST_SIGNALS_NAMESPACE::detail::bound_object>::iterator iterator;
|
2002-05-26 13:02:17 +00:00
|
|
|
for (iterator i = local_con->bound_objects.begin();
|
|
|
|
i != local_con->bound_objects.end(); ++i) {
|
2002-07-28 23:38:39 +00:00
|
|
|
assert(i->disconnect);
|
2002-05-26 13:02:17 +00:00
|
|
|
i->disconnect(i->obj, i->data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // end namespace boost
|
|
|
|
} // end namespace boost
|
|
|
|
|
|
|
|
#ifndef BOOST_MSVC
|
|
|
|
// Explicit instantiations to keep everything in the library
|
2002-06-18 15:39:27 +00:00
|
|
|
template class std::list<boost::BOOST_SIGNALS_NAMESPACE::detail::bound_object>;
|
2002-05-26 13:02:17 +00:00
|
|
|
#endif
|