summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-07-25 17:16:32 +0200
committerRobin Gareus <robin@gareus.org>2016-07-25 17:16:32 +0200
commiteec294a97edce69ca71c972867ab708d5dd5625d (patch)
treed48202a8e6b5978ba1d6d5a83a574b3a91687460
parentac8f4baa002db37506a84088861b7a288dcdfae6 (diff)
the endless quest to plug memory leaks -- episode 378
-rw-r--r--libs/ardour/ardour/control_protocol_manager.h25
-rw-r--r--libs/ardour/control_protocol_manager.cc17
-rw-r--r--libs/ardour/tempo.cc9
-rw-r--r--libs/canvas/canvas/ruler.h14
-rw-r--r--libs/canvas/ruler.cc13
-rw-r--r--libs/evoral/src/ControlList.cpp7
-rw-r--r--libs/pbd/pthread_utils.cc2
7 files changed, 65 insertions, 22 deletions
diff --git a/libs/ardour/ardour/control_protocol_manager.h b/libs/ardour/ardour/control_protocol_manager.h
index dbbb0c3891..c6ea045ce1 100644
--- a/libs/ardour/ardour/control_protocol_manager.h
+++ b/libs/ardour/ardour/control_protocol_manager.h
@@ -36,20 +36,21 @@ class ControlProtocolDescriptor;
class Session;
class LIBARDOUR_API ControlProtocolInfo {
-public:
- ControlProtocolDescriptor* descriptor;
- ControlProtocol* protocol;
- std::string name;
- std::string path;
- bool requested;
- bool mandatory;
- bool supports_feedback;
- XMLNode* state;
-
- ControlProtocolInfo() : descriptor (0), protocol (0), requested(false),
+ public:
+ ControlProtocolDescriptor* descriptor;
+ ControlProtocol* protocol;
+ std::string name;
+ std::string path;
+ bool requested;
+ bool mandatory;
+ bool supports_feedback;
+ XMLNode* state;
+
+ ControlProtocolInfo() : descriptor (0), protocol (0), requested(false),
mandatory(false), supports_feedback(false), state (0)
{}
- ~ControlProtocolInfo() { delete state; }
+ ~ControlProtocolInfo();
+
};
class LIBARDOUR_API ControlProtocolManager : public PBD::Stateful, public ARDOUR::SessionHandlePtr
diff --git a/libs/ardour/control_protocol_manager.cc b/libs/ardour/control_protocol_manager.cc
index 2b0a4dce4c..a0a36c17dd 100644
--- a/libs/ardour/control_protocol_manager.cc
+++ b/libs/ardour/control_protocol_manager.cc
@@ -43,6 +43,22 @@ using namespace PBD;
ControlProtocolManager* ControlProtocolManager::_instance = 0;
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 ()
{
}
@@ -434,6 +450,7 @@ ControlProtocolManager::set_state (const XMLNode& node, int /*version*/)
ControlProtocolInfo* cpi = cpi_by_name (prop->value());
if (cpi) {
+ delete cpi->state;
cpi->state = new XMLNode (**citer);
if (active) {
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc
index 793d96c663..56f88d33d9 100644
--- a/libs/ardour/tempo.cc
+++ b/libs/ardour/tempo.cc
@@ -3471,6 +3471,7 @@ TempoMap::set_state (const XMLNode& node, int /*version*/)
catch (failed_constructor& err){
error << _("Tempo map: could not set new state, restoring old one.") << endmsg;
_metrics = old_metrics;
+ old_metrics.clear();
break;
}
@@ -3484,6 +3485,7 @@ TempoMap::set_state (const XMLNode& node, int /*version*/)
catch (failed_constructor& err) {
error << _("Tempo map: could not set new state, restoring old one.") << endmsg;
_metrics = old_metrics;
+ old_metrics.clear();
break;
}
}
@@ -3535,6 +3537,13 @@ TempoMap::set_state (const XMLNode& node, int /*version*/)
}
recompute_map (_metrics);
+
+ Metrics::const_iterator d = old_metrics.begin();
+ while (d != old_metrics.end()) {
+ delete (*d);
+ ++d;
+ }
+ old_metrics.clear ();
}
PropertyChanged (PropertyChange ());
diff --git a/libs/canvas/canvas/ruler.h b/libs/canvas/canvas/ruler.h
index 0a2e43587e..751ddcc104 100644
--- a/libs/canvas/canvas/ruler.h
+++ b/libs/canvas/canvas/ruler.h
@@ -60,14 +60,18 @@ public:
Ruler (Item*, const Metric& m);
Ruler (Item*, const Metric& m, Rect const&);
+ virtual ~Ruler () {
+ delete _font_description;
+ }
+
void set_range (double lower, double upper);
void set_font_description (Pango::FontDescription);
void set_metric (const Metric&);
void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
- void set_divide_colors (Color top, Color bottom);
- void set_divide_height (double);
+ void set_divide_colors (Color top, Color bottom);
+ void set_divide_height (double);
private:
const Metric* _metric;
@@ -76,9 +80,9 @@ private:
Coord _lower;
Coord _upper;
- double _divide_height;
- Color _divider_color_top;
- Color _divider_color_bottom;
+ double _divide_height;
+ Color _divider_color_top;
+ Color _divider_color_bottom;
Pango::FontDescription* _font_description;
mutable std::vector<Mark> marks;
diff --git a/libs/canvas/ruler.cc b/libs/canvas/ruler.cc
index 74755f6ecc..1c11def93a 100644
--- a/libs/canvas/ruler.cc
+++ b/libs/canvas/ruler.cc
@@ -36,7 +36,8 @@ Ruler::Ruler (Canvas* c, const Metric& m)
, _metric (&m)
, _lower (0)
, _upper (0)
- , _divide_height (-1.0)
+ , _divide_height (-1.0)
+ , _font_description (0)
, _need_marks (true)
{
}
@@ -46,7 +47,8 @@ Ruler::Ruler (Canvas* c, const Metric& m, Rect const& r)
, _metric (&m)
, _lower (0)
, _upper (0)
- , _divide_height (-1.0)
+ , _divide_height (-1.0)
+ , _font_description (0)
, _need_marks (true)
{
}
@@ -56,7 +58,8 @@ Ruler::Ruler (Item* parent, const Metric& m)
, _metric (&m)
, _lower (0)
, _upper (0)
- , _divide_height (-1.0)
+ , _divide_height (-1.0)
+ , _font_description (0)
, _need_marks (true)
{
}
@@ -66,7 +69,8 @@ Ruler::Ruler (Item* parent, const Metric& m, Rect const& r)
, _metric (&m)
, _lower (0)
, _upper (0)
- , _divide_height (-1.0)
+ , _divide_height (-1.0)
+ , _font_description (0)
, _need_marks (true)
{
}
@@ -85,6 +89,7 @@ void
Ruler::set_font_description (Pango::FontDescription fd)
{
begin_visual_change ();
+ delete _font_description;
_font_description = new Pango::FontDescription (fd);
end_visual_change ();
}
diff --git a/libs/evoral/src/ControlList.cpp b/libs/evoral/src/ControlList.cpp
index 2a013f2669..c665b69a5b 100644
--- a/libs/evoral/src/ControlList.cpp
+++ b/libs/evoral/src/ControlList.cpp
@@ -139,6 +139,7 @@ ControlList::~ControlList()
for (EventList::iterator x = _events.begin(); x != _events.end(); ++x) {
delete (*x);
}
+ _events.clear ();
delete _curve;
}
@@ -178,6 +179,9 @@ ControlList::copy_events (const ControlList& other)
{
{
Glib::Threads::RWLock::WriterLock lm (_lock);
+ for (EventList::iterator x = _events.begin(); x != _events.end(); ++x) {
+ delete (*x);
+ }
_events.clear ();
for (const_iterator i = other.begin(); i != other.end(); ++i) {
_events.push_back (new ControlEvent ((*i)->when, (*i)->value));
@@ -216,6 +220,9 @@ ControlList::clear ()
{
{
Glib::Threads::RWLock::WriterLock lm (_lock);
+ for (EventList::iterator x = _events.begin(); x != _events.end(); ++x) {
+ delete (*x);
+ }
_events.clear ();
unlocked_invalidate_insert_iterator ();
mark_dirty ();
diff --git a/libs/pbd/pthread_utils.cc b/libs/pbd/pthread_utils.cc
index 7cd25e42b8..5daa60ac42 100644
--- a/libs/pbd/pthread_utils.cc
+++ b/libs/pbd/pthread_utils.cc
@@ -146,7 +146,7 @@ pthread_set_name (const char *str)
{
/* copy string and delete it when exiting */
- thread_name.set (strdup (str));
+ thread_name.set (strdup (str)); // leaks
}
const char *