Remove static Destroyed(*), prefer StatefulDestructable API

This also add a debug-dump method to show remaining registered
Controllables.
This commit is contained in:
Robin Gareus 2019-03-23 14:32:00 +01:00
parent ff8bd935cf
commit da114c5a4d
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 15 additions and 7 deletions

View File

@ -29,7 +29,6 @@
using namespace PBD;
using namespace std;
PBD::Signal1<void,Controllable*> Controllable::Destroyed;
PBD::Signal1<bool, boost::weak_ptr<PBD::Controllable> > Controllable::StartLearning;
PBD::Signal1<void, boost::weak_ptr<PBD::Controllable> > Controllable::StopLearning;
PBD::Signal1<void, boost::weak_ptr<PBD::Controllable> > Controllable::GUIFocusChanged;
@ -104,6 +103,7 @@ Controllable::add (Controllable& ctl)
Glib::Threads::RWLock::WriterLock lm (registry_lock);
registry.insert (&ctl);
ctl.DropReferences.connect_same_thread (registry_connections, boost::bind (&Controllable::remove, &ctl));
ctl.Destroyed.connect_same_thread (registry_connections, boost::bind (&Controllable::remove, &ctl));
}
void
@ -128,3 +128,15 @@ Controllable::by_id (const ID& id)
}
return boost::shared_ptr<Controllable>();
}
void
Controllable::dump_registry ()
{
Glib::Threads::RWLock::ReaderLock lm (registry_lock);
unsigned int cnt = 0;
cout << "-- List Of Registered Controllables\n";
for (Controllables::iterator i = registry.begin(); i != registry.end(); ++i, ++cnt) {
cout << "CTRL: " << (*i)->name() << "\n";
}
cout << "Total number of registered sontrollables: " << cnt << "\n";
}

View File

@ -22,7 +22,6 @@
#include <string>
#include <set>
#include <map>
#include "pbd/libpbd_visibility.h"
#include "pbd/signals.h"
@ -62,7 +61,6 @@ public:
};
Controllable (const std::string& name, Flag f = Flag (0));
virtual ~Controllable() { Destroyed (this); }
/* We express Controllable values in one of three ways:
* 1. `user' --- as presented to the user (e.g. dB, Hz, etc.)
@ -129,8 +127,6 @@ public:
static PBD::Signal1<bool, boost::weak_ptr<PBD::Controllable> > StartLearning;
static PBD::Signal1<void, boost::weak_ptr<PBD::Controllable> > StopLearning;
static PBD::Signal1<void,Controllable*> Destroyed;
static PBD::Signal1<void, boost::weak_ptr<PBD::Controllable> > GUIFocusChanged;
PBD::Signal2<void,bool,PBD::Controllable::GroupControlDisposition> Changed;
@ -138,7 +134,7 @@ public:
int set_state (const XMLNode&, int version);
virtual XMLNode& get_state ();
std::string name() const { return _name; }
std::string name() const { return _name; }
bool touching () const { return _touching; }
PBD::Signal0<void> TouchChanged;
@ -154,6 +150,7 @@ public:
void set_flags (Flag f);
static boost::shared_ptr<Controllable> by_id (const PBD::ID&);
static void dump_registry ();
static const std::string xml_node_name;
@ -178,7 +175,6 @@ private:
static void add (Controllable&);
static void remove (Controllable*);
};
/* a utility class for the occasions when you need but do not have