mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 07:14:56 +01:00
the endless quest to plug memory leaks -- episode 378
This commit is contained in:
parent
ac8f4baa00
commit
eec294a97e
7 changed files with 64 additions and 21 deletions
|
|
@ -36,20 +36,21 @@ class ControlProtocolDescriptor;
|
||||||
class Session;
|
class Session;
|
||||||
|
|
||||||
class LIBARDOUR_API ControlProtocolInfo {
|
class LIBARDOUR_API ControlProtocolInfo {
|
||||||
public:
|
public:
|
||||||
ControlProtocolDescriptor* descriptor;
|
ControlProtocolDescriptor* descriptor;
|
||||||
ControlProtocol* protocol;
|
ControlProtocol* protocol;
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string path;
|
std::string path;
|
||||||
bool requested;
|
bool requested;
|
||||||
bool mandatory;
|
bool mandatory;
|
||||||
bool supports_feedback;
|
bool supports_feedback;
|
||||||
XMLNode* state;
|
XMLNode* state;
|
||||||
|
|
||||||
ControlProtocolInfo() : descriptor (0), protocol (0), requested(false),
|
ControlProtocolInfo() : descriptor (0), protocol (0), requested(false),
|
||||||
mandatory(false), supports_feedback(false), state (0)
|
mandatory(false), supports_feedback(false), state (0)
|
||||||
{}
|
{}
|
||||||
~ControlProtocolInfo() { delete state; }
|
~ControlProtocolInfo();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class LIBARDOUR_API ControlProtocolManager : public PBD::Stateful, public ARDOUR::SessionHandlePtr
|
class LIBARDOUR_API ControlProtocolManager : public PBD::Stateful, public ARDOUR::SessionHandlePtr
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,22 @@ using namespace PBD;
|
||||||
ControlProtocolManager* ControlProtocolManager::_instance = 0;
|
ControlProtocolManager* ControlProtocolManager::_instance = 0;
|
||||||
const string ControlProtocolManager::state_node_name = X_("ControlProtocols");
|
const string ControlProtocolManager::state_node_name = X_("ControlProtocols");
|
||||||
|
|
||||||
|
|
||||||
|
ControlProtocolInfo::~ControlProtocolInfo ()
|
||||||
|
{
|
||||||
|
if (protocol && descriptor) {
|
||||||
|
descriptor->destroy (descriptor, protocol);
|
||||||
|
protocol = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete state; state = 0;
|
||||||
|
|
||||||
|
if (descriptor) {
|
||||||
|
delete (Glib::Module*) descriptor->module;
|
||||||
|
descriptor = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ControlProtocolManager::ControlProtocolManager ()
|
ControlProtocolManager::ControlProtocolManager ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -434,6 +450,7 @@ ControlProtocolManager::set_state (const XMLNode& node, int /*version*/)
|
||||||
ControlProtocolInfo* cpi = cpi_by_name (prop->value());
|
ControlProtocolInfo* cpi = cpi_by_name (prop->value());
|
||||||
|
|
||||||
if (cpi) {
|
if (cpi) {
|
||||||
|
delete cpi->state;
|
||||||
cpi->state = new XMLNode (**citer);
|
cpi->state = new XMLNode (**citer);
|
||||||
|
|
||||||
if (active) {
|
if (active) {
|
||||||
|
|
|
||||||
|
|
@ -3471,6 +3471,7 @@ TempoMap::set_state (const XMLNode& node, int /*version*/)
|
||||||
catch (failed_constructor& err){
|
catch (failed_constructor& err){
|
||||||
error << _("Tempo map: could not set new state, restoring old one.") << endmsg;
|
error << _("Tempo map: could not set new state, restoring old one.") << endmsg;
|
||||||
_metrics = old_metrics;
|
_metrics = old_metrics;
|
||||||
|
old_metrics.clear();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3484,6 +3485,7 @@ TempoMap::set_state (const XMLNode& node, int /*version*/)
|
||||||
catch (failed_constructor& err) {
|
catch (failed_constructor& err) {
|
||||||
error << _("Tempo map: could not set new state, restoring old one.") << endmsg;
|
error << _("Tempo map: could not set new state, restoring old one.") << endmsg;
|
||||||
_metrics = old_metrics;
|
_metrics = old_metrics;
|
||||||
|
old_metrics.clear();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3535,6 +3537,13 @@ TempoMap::set_state (const XMLNode& node, int /*version*/)
|
||||||
}
|
}
|
||||||
|
|
||||||
recompute_map (_metrics);
|
recompute_map (_metrics);
|
||||||
|
|
||||||
|
Metrics::const_iterator d = old_metrics.begin();
|
||||||
|
while (d != old_metrics.end()) {
|
||||||
|
delete (*d);
|
||||||
|
++d;
|
||||||
|
}
|
||||||
|
old_metrics.clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyChanged (PropertyChange ());
|
PropertyChanged (PropertyChange ());
|
||||||
|
|
|
||||||
|
|
@ -60,14 +60,18 @@ public:
|
||||||
Ruler (Item*, const Metric& m);
|
Ruler (Item*, const Metric& m);
|
||||||
Ruler (Item*, const Metric& m, Rect const&);
|
Ruler (Item*, const Metric& m, Rect const&);
|
||||||
|
|
||||||
|
virtual ~Ruler () {
|
||||||
|
delete _font_description;
|
||||||
|
}
|
||||||
|
|
||||||
void set_range (double lower, double upper);
|
void set_range (double lower, double upper);
|
||||||
void set_font_description (Pango::FontDescription);
|
void set_font_description (Pango::FontDescription);
|
||||||
void set_metric (const Metric&);
|
void set_metric (const Metric&);
|
||||||
|
|
||||||
void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
|
void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
|
||||||
|
|
||||||
void set_divide_colors (Color top, Color bottom);
|
void set_divide_colors (Color top, Color bottom);
|
||||||
void set_divide_height (double);
|
void set_divide_height (double);
|
||||||
private:
|
private:
|
||||||
const Metric* _metric;
|
const Metric* _metric;
|
||||||
|
|
||||||
|
|
@ -76,9 +80,9 @@ private:
|
||||||
|
|
||||||
Coord _lower;
|
Coord _lower;
|
||||||
Coord _upper;
|
Coord _upper;
|
||||||
double _divide_height;
|
double _divide_height;
|
||||||
Color _divider_color_top;
|
Color _divider_color_top;
|
||||||
Color _divider_color_bottom;
|
Color _divider_color_bottom;
|
||||||
|
|
||||||
Pango::FontDescription* _font_description;
|
Pango::FontDescription* _font_description;
|
||||||
mutable std::vector<Mark> marks;
|
mutable std::vector<Mark> marks;
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,8 @@ Ruler::Ruler (Canvas* c, const Metric& m)
|
||||||
, _metric (&m)
|
, _metric (&m)
|
||||||
, _lower (0)
|
, _lower (0)
|
||||||
, _upper (0)
|
, _upper (0)
|
||||||
, _divide_height (-1.0)
|
, _divide_height (-1.0)
|
||||||
|
, _font_description (0)
|
||||||
, _need_marks (true)
|
, _need_marks (true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -46,7 +47,8 @@ Ruler::Ruler (Canvas* c, const Metric& m, Rect const& r)
|
||||||
, _metric (&m)
|
, _metric (&m)
|
||||||
, _lower (0)
|
, _lower (0)
|
||||||
, _upper (0)
|
, _upper (0)
|
||||||
, _divide_height (-1.0)
|
, _divide_height (-1.0)
|
||||||
|
, _font_description (0)
|
||||||
, _need_marks (true)
|
, _need_marks (true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -56,7 +58,8 @@ Ruler::Ruler (Item* parent, const Metric& m)
|
||||||
, _metric (&m)
|
, _metric (&m)
|
||||||
, _lower (0)
|
, _lower (0)
|
||||||
, _upper (0)
|
, _upper (0)
|
||||||
, _divide_height (-1.0)
|
, _divide_height (-1.0)
|
||||||
|
, _font_description (0)
|
||||||
, _need_marks (true)
|
, _need_marks (true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -66,7 +69,8 @@ Ruler::Ruler (Item* parent, const Metric& m, Rect const& r)
|
||||||
, _metric (&m)
|
, _metric (&m)
|
||||||
, _lower (0)
|
, _lower (0)
|
||||||
, _upper (0)
|
, _upper (0)
|
||||||
, _divide_height (-1.0)
|
, _divide_height (-1.0)
|
||||||
|
, _font_description (0)
|
||||||
, _need_marks (true)
|
, _need_marks (true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -85,6 +89,7 @@ void
|
||||||
Ruler::set_font_description (Pango::FontDescription fd)
|
Ruler::set_font_description (Pango::FontDescription fd)
|
||||||
{
|
{
|
||||||
begin_visual_change ();
|
begin_visual_change ();
|
||||||
|
delete _font_description;
|
||||||
_font_description = new Pango::FontDescription (fd);
|
_font_description = new Pango::FontDescription (fd);
|
||||||
end_visual_change ();
|
end_visual_change ();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -139,6 +139,7 @@ ControlList::~ControlList()
|
||||||
for (EventList::iterator x = _events.begin(); x != _events.end(); ++x) {
|
for (EventList::iterator x = _events.begin(); x != _events.end(); ++x) {
|
||||||
delete (*x);
|
delete (*x);
|
||||||
}
|
}
|
||||||
|
_events.clear ();
|
||||||
|
|
||||||
delete _curve;
|
delete _curve;
|
||||||
}
|
}
|
||||||
|
|
@ -178,6 +179,9 @@ ControlList::copy_events (const ControlList& other)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Glib::Threads::RWLock::WriterLock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
|
for (EventList::iterator x = _events.begin(); x != _events.end(); ++x) {
|
||||||
|
delete (*x);
|
||||||
|
}
|
||||||
_events.clear ();
|
_events.clear ();
|
||||||
for (const_iterator i = other.begin(); i != other.end(); ++i) {
|
for (const_iterator i = other.begin(); i != other.end(); ++i) {
|
||||||
_events.push_back (new ControlEvent ((*i)->when, (*i)->value));
|
_events.push_back (new ControlEvent ((*i)->when, (*i)->value));
|
||||||
|
|
@ -216,6 +220,9 @@ ControlList::clear ()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Glib::Threads::RWLock::WriterLock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
|
for (EventList::iterator x = _events.begin(); x != _events.end(); ++x) {
|
||||||
|
delete (*x);
|
||||||
|
}
|
||||||
_events.clear ();
|
_events.clear ();
|
||||||
unlocked_invalidate_insert_iterator ();
|
unlocked_invalidate_insert_iterator ();
|
||||||
mark_dirty ();
|
mark_dirty ();
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ pthread_set_name (const char *str)
|
||||||
{
|
{
|
||||||
/* copy string and delete it when exiting */
|
/* copy string and delete it when exiting */
|
||||||
|
|
||||||
thread_name.set (strdup (str));
|
thread_name.set (strdup (str)); // leaks
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue