summaryrefslogtreecommitdiff
path: root/libs/pbd
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2009-12-17 18:24:23 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2009-12-17 18:24:23 +0000
commitf6fdd8dcbf41f864e9f0cc32dabe81fe3533ddfe (patch)
tree5214c580b9e6c17a499fa587660dbf949e892bf2 /libs/pbd
parentda762129f19c28aff64f833b6ec09fba946faef6 (diff)
switch to using boost::signals2 instead of sigc++, at least for libardour. not finished yet, but compiles, loads sessions, records and can close a session without a crash
git-svn-id: svn://localhost/ardour2/branches/3.0@6372 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/pbd')
-rw-r--r--libs/pbd/controllable.cc38
-rw-r--r--libs/pbd/pbd/command.h1
-rw-r--r--libs/pbd/pbd/controllable.h23
-rw-r--r--libs/pbd/pbd/destructible.h22
-rw-r--r--libs/pbd/pbd/memento_command.h12
-rw-r--r--libs/pbd/pbd/statefuldestructible.h10
-rw-r--r--libs/pbd/pbd/undo.h11
-rw-r--r--libs/pbd/stateful.cc1
-rw-r--r--libs/pbd/undo.cc27
-rw-r--r--libs/pbd/wscript1
10 files changed, 61 insertions, 85 deletions
diff --git a/libs/pbd/controllable.cc b/libs/pbd/controllable.cc
index 35f7605541..369e2bd545 100644
--- a/libs/pbd/controllable.cc
+++ b/libs/pbd/controllable.cc
@@ -26,11 +26,11 @@
using namespace PBD;
using namespace std;
-sigc::signal<void,Controllable*> Controllable::Destroyed;
-sigc::signal<bool,Controllable*> Controllable::StartLearning;
-sigc::signal<void,Controllable*> Controllable::StopLearning;
-sigc::signal<void,Controllable*,int,int> Controllable::CreateBinding;
-sigc::signal<void,Controllable*> Controllable::DeleteBinding;
+boost::signals2::signal<void(Controllable*)> Controllable::Destroyed;
+boost::signals2::signal<bool(Controllable*)> Controllable::StartLearning;
+boost::signals2::signal<void(Controllable*)> Controllable::StopLearning;
+boost::signals2::signal<void(Controllable*,int,int)> Controllable::CreateBinding;
+boost::signals2::signal<void(Controllable*)> Controllable::DeleteBinding;
Glib::StaticRWLock Controllable::registry_lock = GLIBMM_STATIC_RW_LOCK_INIT;
Controllable::Controllables Controllable::registry;
@@ -41,45 +41,47 @@ Controllable::Controllable (const string& name, const string& uri)
, _uri (uri)
, _touching (false)
{
- add ();
+ add (*this);
}
void
-Controllable::add ()
+Controllable::add (Controllable& ctl)
{
+ using namespace boost;
+
Glib::RWLock::WriterLock lm (registry_lock);
- registry.insert (this);
+ registry.insert (&ctl);
- if (!_uri.empty()) {
+ if (!ctl.uri().empty()) {
pair<string,Controllable*> newpair;
- newpair.first = _uri;
- newpair.second = this;
+ newpair.first = ctl.uri();
+ newpair.second = &ctl;
registry_by_uri.insert (newpair);
}
- this->GoingAway.connect (mem_fun (this, &Controllable::remove));
+ /* Controllable::remove() is static - no need to manage this connection */
+
+ ctl.GoingAway.connect (boost::bind (&Controllable::remove, ref (ctl)));
}
void
-Controllable::remove ()
+Controllable::remove (Controllable& ctl)
{
Glib::RWLock::WriterLock lm (registry_lock);
for (Controllables::iterator i = registry.begin(); i != registry.end(); ++i) {
- if ((*i) == this) {
+ if ((*i) == &ctl) {
registry.erase (i);
break;
}
}
- if (!_uri.empty()) {
- ControllablesByURI::iterator i = registry_by_uri.find (_uri);
+ if (!ctl.uri().empty()) {
+ ControllablesByURI::iterator i = registry_by_uri.find (ctl.uri());
if (i != registry_by_uri.end()) {
registry_by_uri.erase (i);
}
}
-
-
}
void
diff --git a/libs/pbd/pbd/command.h b/libs/pbd/pbd/command.h
index 7af7f7bb98..5a7290bc89 100644
--- a/libs/pbd/pbd/command.h
+++ b/libs/pbd/pbd/command.h
@@ -1,3 +1,4 @@
+
/*
Copyright (C) 2006 Paul Davis
Author: Hans Fugal
diff --git a/libs/pbd/pbd/controllable.h b/libs/pbd/pbd/controllable.h
index 9750ebe56e..dbec03b396 100644
--- a/libs/pbd/pbd/controllable.h
+++ b/libs/pbd/pbd/controllable.h
@@ -24,8 +24,7 @@ v it under the terms of the GNU General Public License as published by
#include <set>
#include <map>
-#include <sigc++/trackable.h>
-#include <sigc++/signal.h>
+#include <boost/signals2.hpp>
#include <glibmm/thread.h>
#include "pbd/statefuldestructible.h"
@@ -45,16 +44,16 @@ class Controllable : public PBD::StatefulDestructible {
virtual void set_value (float) = 0;
virtual float get_value (void) const = 0;
- sigc::signal<void> LearningFinished;
- static sigc::signal<void,PBD::Controllable*,int,int> CreateBinding;
- static sigc::signal<void,PBD::Controllable*> DeleteBinding;
+ boost::signals2::signal<void()> LearningFinished;
+ static boost::signals2::signal<void(PBD::Controllable*,int,int)> CreateBinding;
+ static boost::signals2::signal<void(PBD::Controllable*)> DeleteBinding;
- static sigc::signal<bool,PBD::Controllable*> StartLearning;
- static sigc::signal<void,PBD::Controllable*> StopLearning;
+ static boost::signals2::signal<bool(PBD::Controllable*)> StartLearning;
+ static boost::signals2::signal<void(PBD::Controllable*)> StopLearning;
- static sigc::signal<void,Controllable*> Destroyed;
-
- sigc::signal<void> Changed;
+ static boost::signals2::signal<void(Controllable*)> Destroyed;
+
+ boost::signals2::signal<void()> Changed;
int set_state (const XMLNode&, int version);
XMLNode& get_state ();
@@ -73,8 +72,8 @@ class Controllable : public PBD::StatefulDestructible {
std::string _uri;
bool _touching;
- void add ();
- void remove ();
+ static void add (Controllable&);
+ static void remove (Controllable&);
typedef std::set<PBD::Controllable*> Controllables;
typedef std::map<std::string,PBD::Controllable*> ControllablesByURI;
diff --git a/libs/pbd/pbd/destructible.h b/libs/pbd/pbd/destructible.h
index 827feb8fe5..241d847aff 100644
--- a/libs/pbd/pbd/destructible.h
+++ b/libs/pbd/pbd/destructible.h
@@ -20,26 +20,20 @@
#ifndef __pbd_destructible_h__
#define __pbd_destructible_h__
-#include <sigc++/signal.h>
+#include <boost/signals2.hpp>
namespace PBD {
-/* be very very careful using this class. it does not inherit from sigc::trackable and thus
- should only be used in multiple-inheritance situations involving another type
- that does inherit from sigc::trackable (or sigc::trackable itself)
-*/
-
-class ThingWithGoingAway {
- public:
- virtual ~ThingWithGoingAway () {}
- sigc::signal<void> GoingAway;
-};
-
-class Destructible : public sigc::trackable, public ThingWithGoingAway {
+class Destructible {
public:
+ Destructible() : refs_dropped (false){}
virtual ~Destructible () {}
- void drop_references () const { GoingAway(); }
+
+ boost::signals2::signal<void ()> GoingAway;
+ void drop_references () { if (!refs_dropped) { GoingAway(); } refs_dropped = true; }
+ private:
+ bool refs_dropped;
};
}
diff --git a/libs/pbd/pbd/memento_command.h b/libs/pbd/pbd/memento_command.h
index c1e5d75f9c..c5e8b19272 100644
--- a/libs/pbd/pbd/memento_command.h
+++ b/libs/pbd/pbd/memento_command.h
@@ -26,7 +26,6 @@
#include "pbd/command.h"
#include "pbd/stacktrace.h"
#include "pbd/xml++.h"
-#include "pbd/shiva.h"
#include <sigc++/slot.h>
#include <typeinfo>
@@ -42,16 +41,20 @@ public:
MementoCommand(obj_T& a_object, XMLNode* a_before, XMLNode* a_after)
: obj(a_object), before(a_before), after(a_after)
{
- /* catch destruction of the object */
- new PBD::PairedShiva< obj_T,MementoCommand<obj_T> > (obj, *this);
+ /* if the object dies, make sure that we die and that everyone knows about it */
+ obj_death_connection = obj.GoingAway.connect (boost::bind (&MementoCommand::object_died, this));
}
~MementoCommand () {
- GoingAway(); /* EMIT SIGNAL */
+ drop_references ();
delete before;
delete after;
}
+ void object_died () {
+ delete this;
+ }
+
void operator() () {
if (after) {
obj.set_state(*after, Stateful::current_state_version);
@@ -94,6 +97,7 @@ protected:
obj_T& obj;
XMLNode* before;
XMLNode* after;
+ boost::signals2::scoped_connection obj_death_connection;
};
#endif // __lib_pbd_memento_h__
diff --git a/libs/pbd/pbd/statefuldestructible.h b/libs/pbd/pbd/statefuldestructible.h
index 49a33ff438..36eb43147c 100644
--- a/libs/pbd/pbd/statefuldestructible.h
+++ b/libs/pbd/pbd/statefuldestructible.h
@@ -29,16 +29,6 @@ class StatefulDestructible : public Stateful, public Destructible
{
};
-/* be very very careful using this class. it does not inherit from sigc::trackable and thus
- should only be used in multiple-inheritance situations involving another type
- that does inherit from sigc::trackable (or sigc::trackable itself)
-*/
-
-class StatefulThingWithGoingAway : public Stateful, public ThingWithGoingAway
-{
-};
-
}
-
#endif /* __pbd_stateful_destructible_h__ */
diff --git a/libs/pbd/pbd/undo.h b/libs/pbd/pbd/undo.h
index 0e48bea962..6340ef04b9 100644
--- a/libs/pbd/pbd/undo.h
+++ b/libs/pbd/pbd/undo.h
@@ -26,12 +26,13 @@
#include <sigc++/slot.h>
#include <sigc++/bind.h>
#include <sys/time.h>
+
+#include "pbd/scoped_connections.h"
#include "pbd/command.h"
-#include "pbd/shiva.h"
typedef sigc::slot<void> UndoAction;
-class UndoTransaction : public Command
+class UndoTransaction : public Command, public PBD::ScopedConnectionList
{
public:
UndoTransaction ();
@@ -61,7 +62,6 @@ class UndoTransaction : public Command
private:
std::list<Command*> actions;
- std::list<PBD::ProxyShiva<Command,UndoTransaction>*> shivas;
struct timeval _timestamp;
bool _clearing;
@@ -71,10 +71,9 @@ class UndoTransaction : public Command
~UndoTransaction ();
void about_to_explicitly_delete ();
-
};
-class UndoHistory : public sigc::trackable
+class UndoHistory : public PBD::ScopedConnectionList
{
public:
UndoHistory();
@@ -107,7 +106,7 @@ class UndoHistory : public sigc::trackable
void set_depth (uint32_t);
- sigc::signal<void> Changed;
+ boost::signals2::signal<void()> Changed;
private:
bool _clearing;
diff --git a/libs/pbd/stateful.cc b/libs/pbd/stateful.cc
index 58be141a27..596402576e 100644
--- a/libs/pbd/stateful.cc
+++ b/libs/pbd/stateful.cc
@@ -21,6 +21,7 @@
#include <unistd.h>
#include "pbd/stateful.h"
+#include "pbd/destructible.h"
#include "pbd/filesystem.h"
#include "pbd/xml++.h"
#include "pbd/error.h"
diff --git a/libs/pbd/undo.cc b/libs/pbd/undo.cc
index a0e98f9a13..78c16291b7 100644
--- a/libs/pbd/undo.cc
+++ b/libs/pbd/undo.cc
@@ -46,7 +46,7 @@ UndoTransaction::UndoTransaction (const UndoTransaction& rhs)
UndoTransaction::~UndoTransaction ()
{
- GoingAway ();
+ drop_references ();
clear ();
}
@@ -78,9 +78,11 @@ void
UndoTransaction::add_command (Command *const action)
{
/* catch death of command (e.g. caused by death of object to
- which it refers.
+ which it refers. command_death() is a normal static function
+ so there is no need to manage this connection.
*/
- shivas.push_back (new PBD::ProxyShiva<Command,UndoTransaction> (*action, *this, &command_death));
+
+ scoped_connect (action->GoingAway, boost::bind (&command_death, this, action));
actions.push_back (action);
}
@@ -90,21 +92,6 @@ UndoTransaction::remove_command (Command* const action)
actions.remove (action);
}
-void
-UndoTransaction::about_to_explicitly_delete ()
-{
- /* someone is going to call our destructor and its not Shiva,
- the god of destruction and chaos. This happens when an UndoHistory
- is pruning itself. we must remove Shivas to avoid the god
- striking us down a second time, unnecessarily and illegally.
- */
-
- for (list<PBD::ProxyShiva<Command,UndoTransaction>*>::iterator i = shivas.begin(); i != shivas.end(); ++i) {
- delete *i;
- }
- shivas.clear ();
-}
-
bool
UndoTransaction::empty () const
{
@@ -188,7 +175,6 @@ UndoHistory::set_depth (uint32_t d)
while (cnt--) {
ut = UndoList.front();
UndoList.pop_front ();
- ut->about_to_explicitly_delete ();
delete ut;
}
}
@@ -199,7 +185,7 @@ UndoHistory::add (UndoTransaction* const ut)
{
uint32_t current_depth = UndoList.size();
- ut->GoingAway.connect (bind (mem_fun (*this, &UndoHistory::remove), ut));
+ scoped_connect (ut->GoingAway, boost::bind (&UndoHistory::remove, this, ut));
/* if the current undo history is larger than or equal to the currently
requested depth, then pop off at least 1 element to make space
@@ -214,7 +200,6 @@ UndoHistory::add (UndoTransaction* const ut)
UndoTransaction* ut;
ut = UndoList.front ();
UndoList.pop_front ();
- ut->about_to_explicitly_delete ();
delete ut;
}
}
diff --git a/libs/pbd/wscript b/libs/pbd/wscript
index 84c18cc899..aacbd990ad 100644
--- a/libs/pbd/wscript
+++ b/libs/pbd/wscript
@@ -73,6 +73,7 @@ def build(bld):
pool.cc
pthread_utils.cc
receiver.cc
+ scoped_connections.cc
search_path.cc
shortpath.cc
stacktrace.cc