From 09ed9c44e7988067796da2febeb7a5edf1282f93 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sun, 14 Aug 2016 08:33:23 -0400 Subject: change PBD::Transmitter code to use PBD::Signal<> not sigc::signal<>, since the latter is not thread safe --- libs/pbd/pbd/receiver.h | 2 +- libs/pbd/pbd/transmitter.h | 14 +++++++------- libs/pbd/receiver.cc | 18 ++++++------------ 3 files changed, 14 insertions(+), 20 deletions(-) (limited to 'libs/pbd') diff --git a/libs/pbd/pbd/receiver.h b/libs/pbd/pbd/receiver.h index e7f3f25b0b..2f44deb93f 100644 --- a/libs/pbd/pbd/receiver.h +++ b/libs/pbd/pbd/receiver.h @@ -42,7 +42,7 @@ class LIBPBD_API Receiver : public sigc::trackable virtual void receive (Transmitter::Channel, const char *) = 0; private: - std::vector connections; + PBD::ScopedConnectionList connections; }; #endif // __libmisc_receiver_h__ diff --git a/libs/pbd/pbd/transmitter.h b/libs/pbd/pbd/transmitter.h index a765f9e370..47ab9c7e3e 100644 --- a/libs/pbd/pbd/transmitter.h +++ b/libs/pbd/pbd/transmitter.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include "pbd/libpbd_visibility.h" @@ -41,7 +41,7 @@ class LIBPBD_API Transmitter : public std::stringstream Transmitter (Channel); - sigc::signal &sender() { + PBD::Signal2 &sender() { return *send; } @@ -53,12 +53,12 @@ class LIBPBD_API Transmitter : public std::stringstream private: Channel channel; - sigc::signal *send; + PBD::Signal2 *send; - sigc::signal info; - sigc::signal warning; - sigc::signal error; - sigc::signal fatal; + PBD::Signal2 info; + PBD::Signal2 warning; + PBD::Signal2 error; + PBD::Signal2 fatal; }; /* for EGCS 2.91.66, if this function is not compiled within the same diff --git a/libs/pbd/receiver.cc b/libs/pbd/receiver.cc index b0655721ad..689665c84a 100644 --- a/libs/pbd/receiver.cc +++ b/libs/pbd/receiver.cc @@ -37,23 +37,17 @@ Receiver::~Receiver () void Receiver::hangup () { - vector::iterator i; - - for (i = connections.begin(); i != connections.end (); i++) { - (*i)->disconnect (); - delete *i; - } - - connections.erase (connections.begin(), connections.end()); + connections.drop_connections (); } void Receiver::listen_to (Transmitter &transmitter) { - sigc::connection *c = new sigc::connection; - - (*c) = transmitter.sender().connect(mem_fun(*this, &Receiver::receive)); + /* odd syntax here because boost's placeholders (_1, _2) are in an + anonymous namespace which causes ambiguity with sigc++ (and will also + do so with std::placeholder in the C++11 future + */ + transmitter.sender().connect_same_thread (connections, boost::bind (&Receiver::receive, this, boost::arg<1>(), boost::arg<2>())); - connections.push_back (c); } -- cgit v1.2.3