Clean up weird formatting from underlays patch.

Fix several memory (valgrind) errors in a vain attempt to fix crash on session close.


git-svn-id: svn://localhost/ardour2/branches/3.0@3105 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2008-02-22 01:45:29 +00:00
parent 2921166139
commit faf4e1d8e8
10 changed files with 101 additions and 72 deletions

View file

@ -59,9 +59,9 @@ GhostRegion::GhostRegion (ArdourCanvas::Group* parent, TimeAxisView& tv, TimeAxi
GhostRegion::~GhostRegion () GhostRegion::~GhostRegion ()
{ {
GoingAway (this); /*GoingAway (this);
delete base_rect; delete base_rect;
delete group; delete group;*/
} }
void void
@ -157,47 +157,59 @@ AudioGhostRegion::set_colors ()
* no range controller in these tracks. maybe show the whole range. * no range controller in these tracks. maybe show the whole range.
*/ */
MidiGhostRegion::MidiGhostRegion(TimeAxisView& tv, TimeAxisView& source_tv, double initial_unit_pos) MidiGhostRegion::MidiGhostRegion(TimeAxisView& tv, TimeAxisView& source_tv, double initial_unit_pos)
: GhostRegion(tv.ghost_group, tv, source_tv, initial_unit_pos) { : GhostRegion(tv.ghost_group, tv, source_tv, initial_unit_pos)
{
base_rect->lower_to_bottom(); base_rect->lower_to_bottom();
} }
MidiGhostRegion::MidiGhostRegion(MidiStreamView& msv, TimeAxisView& source_tv, double initial_unit_pos) MidiGhostRegion::MidiGhostRegion(MidiStreamView& msv, TimeAxisView& source_tv, double initial_unit_pos)
: GhostRegion(msv.midi_underlay_group, msv.trackview(), source_tv, initial_unit_pos) { : GhostRegion(msv.midi_underlay_group, msv.trackview(), source_tv, initial_unit_pos)
{
base_rect->lower_to_bottom(); base_rect->lower_to_bottom();
} }
MidiGhostRegion::~MidiGhostRegion()
{
//clear_events();
}
MidiGhostRegion::Event::Event(ArdourCanvas::CanvasMidiEvent* e) MidiGhostRegion::Event::Event(ArdourCanvas::CanvasMidiEvent* e)
: event(e) { : event(e)
{
} }
MidiGhostRegion::Note::Note(ArdourCanvas::CanvasNote* n, ArdourCanvas::Group* g) MidiGhostRegion::Note::Note(ArdourCanvas::CanvasNote* n, ArdourCanvas::Group* g)
: Event(n) { : Event(n)
{
rect = new ArdourCanvas::SimpleRect(*g, n->x1(), n->y1(), n->x2(), n->y2()); rect = new ArdourCanvas::SimpleRect(*g, n->x1(), n->y1(), n->x2(), n->y2());
} }
MidiGhostRegion::Note::~Note() { MidiGhostRegion::Note::~Note()
delete rect; {
//delete rect;
} }
void void
MidiGhostRegion::Note::x_changed() { MidiGhostRegion::Note::x_changed()
{
rect->property_x1() = event->x1(); rect->property_x1() = event->x1();
rect->property_x2() = event->x2(); rect->property_x2() = event->x2();
} }
MidiGhostRegion::Hit::Hit(ArdourCanvas::CanvasHit* h, ArdourCanvas::Group*) MidiGhostRegion::Hit::Hit(ArdourCanvas::CanvasHit* h, ArdourCanvas::Group*)
: Event(h) { : Event(h)
{
cerr << "Hit ghost item does not work yet" << endl; cerr << "Hit ghost item does not work yet" << endl;
} }
MidiGhostRegion::Hit::~Hit() { MidiGhostRegion::Hit::~Hit()
{
} }
void void
MidiGhostRegion::Hit::x_changed() { MidiGhostRegion::Hit::x_changed()
{
} }
void void
@ -206,7 +218,8 @@ MidiGhostRegion::set_samples_per_unit (double spu)
} }
MidiStreamView* MidiStreamView*
MidiGhostRegion::midi_view() { MidiGhostRegion::midi_view()
{
MidiTimeAxisView* mtv; MidiTimeAxisView* mtv;
if ((mtv = dynamic_cast<MidiTimeAxisView*>(&trackview)) != 0) { if ((mtv = dynamic_cast<MidiTimeAxisView*>(&trackview)) != 0) {
@ -218,13 +231,15 @@ MidiGhostRegion::midi_view() {
} }
void void
MidiGhostRegion::set_height() { MidiGhostRegion::set_height()
{
GhostRegion::set_height(); GhostRegion::set_height();
update_range(); update_range();
} }
void void
MidiGhostRegion::set_colors() { MidiGhostRegion::set_colors()
{
MidiGhostRegion::Note* note; MidiGhostRegion::Note* note;
guint fill = source_track_color(200); guint fill = source_track_color(200);
@ -239,7 +254,8 @@ MidiGhostRegion::set_colors() {
} }
void void
MidiGhostRegion::update_range() { MidiGhostRegion::update_range()
{
MidiStreamView* mv = midi_view(); MidiStreamView* mv = midi_view();
if (!mv) { if (!mv) {
@ -268,7 +284,8 @@ MidiGhostRegion::update_range() {
} }
void void
MidiGhostRegion::add_note(ArdourCanvas::CanvasNote* n) { MidiGhostRegion::add_note(ArdourCanvas::CanvasNote* n)
{
Note* note = new Note(n, group); Note* note = new Note(n, group);
events.push_back(note); events.push_back(note);
@ -278,14 +295,12 @@ MidiGhostRegion::add_note(ArdourCanvas::CanvasNote* n) {
MidiStreamView* mv = midi_view(); MidiStreamView* mv = midi_view();
if (mv) { if (mv) {
uint8_t note_num = n->note()->note(); const uint8_t note_num = n->note()->note();
double y;
if (note_num < mv->lowest_note() || note_num > mv->highest_note()) { if (note_num < mv->lowest_note() || note_num > mv->highest_note()) {
note->rect->hide(); note->rect->hide();
} } else {
else { const double y = mv->note_to_y(note_num);
y = mv->note_to_y(note_num);
note->rect->property_y1() = y; note->rect->property_y1() = y;
note->rect->property_y2() = y + mv->note_height(); note->rect->property_y2() = y + mv->note_height();
} }
@ -293,15 +308,18 @@ MidiGhostRegion::add_note(ArdourCanvas::CanvasNote* n) {
} }
void void
MidiGhostRegion::add_hit(ArdourCanvas::CanvasHit* h) { MidiGhostRegion::add_hit(ArdourCanvas::CanvasHit* h)
{
//events.push_back(new Hit(h, group)); //events.push_back(new Hit(h, group));
} }
void void
MidiGhostRegion::clear_events() { MidiGhostRegion::clear_events()
{
for (EventList::iterator it = events.begin(); it != events.end(); ++it) { for (EventList::iterator it = events.begin(); it != events.end(); ++it) {
delete *it; delete *it;
} }
events.clear(); events.clear();
} }

View file

@ -103,6 +103,7 @@ public:
MidiGhostRegion(TimeAxisView& tv, TimeAxisView& source_tv, double initial_unit_pos); MidiGhostRegion(TimeAxisView& tv, TimeAxisView& source_tv, double initial_unit_pos);
MidiGhostRegion(MidiStreamView& msv, TimeAxisView& source_tv, double initial_unit_pos); MidiGhostRegion(MidiStreamView& msv, TimeAxisView& source_tv, double initial_unit_pos);
~MidiGhostRegion();
MidiStreamView* midi_view(); MidiStreamView* midi_view();

View file

@ -381,17 +381,16 @@ MidiRegionView::create_note_at(double x, double y, double dur)
void void
MidiRegionView::clear_events() MidiRegionView::clear_events()
{ {
for (std::vector<CanvasMidiEvent*>::iterator i = _events.begin(); i != _events.end(); ++i)
delete *i;
MidiGhostRegion* gr; MidiGhostRegion* gr;
for (vector<GhostRegion*>::iterator g = ghosts.begin(); g != ghosts.end(); ++g) { for (vector<GhostRegion*>::iterator g = ghosts.begin(); g != ghosts.end(); ++g) {
if ((gr = dynamic_cast<MidiGhostRegion*>(*g)) != 0) { if ((gr = dynamic_cast<MidiGhostRegion*>(*g)) != 0) {
gr->clear_events(); gr->clear_events();
} }
} }
for (std::vector<CanvasMidiEvent*>::iterator i = _events.begin(); i != _events.end(); ++i)
delete *i;
_events.clear(); _events.clear();
} }
@ -465,12 +464,16 @@ MidiRegionView::redisplay_model()
MidiRegionView::~MidiRegionView () MidiRegionView::~MidiRegionView ()
{ {
in_destructor = true; in_destructor = true;
RegionViewGoingAway (this); /* EMIT_SIGNAL */
if (_active_notes) if (_active_notes)
end_write(); end_write();
_selection.clear();
clear_events(); clear_events();
delete _note_group;
RegionViewGoingAway (this); /* EMIT_SIGNAL */ delete _delta_command;
} }

View file

@ -137,16 +137,12 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session& sess, boost::shar
MidiTimeAxisView::~MidiTimeAxisView () MidiTimeAxisView::~MidiTimeAxisView ()
{ {
if(_piano_roll_header) {
delete _piano_roll_header; delete _piano_roll_header;
_piano_roll_header = 0; _piano_roll_header = 0;
}
if(_range_scroomer) {
delete _range_scroomer; delete _range_scroomer;
_range_scroomer = 0; _range_scroomer = 0;
} }
}
MidiStreamView* MidiStreamView*
MidiTimeAxisView::midi_view() MidiTimeAxisView::midi_view()

View file

@ -530,7 +530,8 @@ RegionView::move (double x_delta, double y_delta)
} }
void void
RegionView::remove_ghost_in (TimeAxisView& tv) { RegionView::remove_ghost_in (TimeAxisView& tv)
{
for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) { for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
if (&(*i)->trackview == &tv) { if (&(*i)->trackview == &tv) {
delete *i; delete *i;

View file

@ -89,7 +89,6 @@ class RegionView : public TimeAxisViewItem
void enable_display(bool yn) { _enable_display = yn; } void enable_display(bool yn) { _enable_display = yn; }
static sigc::signal<void,RegionView*> RegionViewGoingAway; static sigc::signal<void,RegionView*> RegionViewGoingAway;
sigc::signal<void> GoingAway;
protected: protected:

View file

@ -47,6 +47,7 @@ using namespace Editing;
StreamView::StreamView (RouteTimeAxisView& tv, ArdourCanvas::Group* group) StreamView::StreamView (RouteTimeAxisView& tv, ArdourCanvas::Group* group)
: _trackview (tv) : _trackview (tv)
, owns_canvas_group(group == 0)
, canvas_group(group ? group : new ArdourCanvas::Group(*_trackview.canvas_display)) , canvas_group(group ? group : new ArdourCanvas::Group(*_trackview.canvas_display))
, canvas_rect(new ArdourCanvas::SimpleRect (*canvas_group)) , canvas_rect(new ArdourCanvas::SimpleRect (*canvas_group))
, _samples_per_unit(_trackview.editor.get_current_zoom()) , _samples_per_unit(_trackview.editor.get_current_zoom())
@ -85,8 +86,13 @@ StreamView::StreamView (RouteTimeAxisView& tv, ArdourCanvas::Group* group)
StreamView::~StreamView () StreamView::~StreamView ()
{ {
undisplay_diskstream (); undisplay_diskstream ();
delete canvas_rect;
if (owns_canvas_group) {
delete canvas_group; delete canvas_group;
} }
}
void void
StreamView::attach () StreamView::attach ()
@ -170,8 +176,9 @@ StreamView::remove_region_view (boost::weak_ptr<Region> weak_r)
for (list<RegionView *>::iterator i = region_views.begin(); i != region_views.end(); ++i) { for (list<RegionView *>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
if (((*i)->region()) == r) { if (((*i)->region()) == r) {
delete *i; RegionView* rv = *i;
region_views.erase (i); region_views.erase (i);
delete rv;
break; break;
} }
} }
@ -180,8 +187,11 @@ StreamView::remove_region_view (boost::weak_ptr<Region> weak_r)
void void
StreamView::undisplay_diskstream () StreamView::undisplay_diskstream ()
{ {
for (RegionViewList::iterator i = region_views.begin(); i != region_views.end(); ++i) { for (RegionViewList::iterator i = region_views.begin(); i != region_views.end() ; ) {
RegionViewList::iterator next = i;
++next;
delete *i; delete *i;
i = next;
} }
region_views.clear(); region_views.clear();

View file

@ -127,6 +127,7 @@ protected:
virtual void color_handler () = 0; virtual void color_handler () = 0;
RouteTimeAxisView& _trackview; RouteTimeAxisView& _trackview;
bool owns_canvas_group;
ArdourCanvas::Group* canvas_group; ArdourCanvas::Group* canvas_group;
ArdourCanvas::SimpleRect* canvas_rect; /* frame around the whole thing */ ArdourCanvas::SimpleRect* canvas_rect; /* frame around the whole thing */

View file

@ -108,8 +108,6 @@ RegionFactory::create (Session& session, XMLNode& node, bool yn)
boost::shared_ptr<Region> boost::shared_ptr<Region>
RegionFactory::create (const SourceList& srcs, nframes_t start, nframes_t length, const string& name, layer_t layer, Region::Flag flags, bool announce) RegionFactory::create (const SourceList& srcs, nframes_t start, nframes_t length, const string& name, layer_t layer, Region::Flag flags, bool announce)
{ {
cerr << "CREATE REGION " << name << " " << start << " * " << length << endl;
if (srcs.empty()) { if (srcs.empty()) {
return boost::shared_ptr<Region>(); return boost::shared_ptr<Region>();
} }

View file

@ -334,6 +334,8 @@ Session::destroy ()
AudioDiskstream::free_working_buffers(); AudioDiskstream::free_working_buffers();
Route::SyncOrderKeys.clear();
#undef TRACK_DESTRUCTION #undef TRACK_DESTRUCTION
#ifdef TRACK_DESTRUCTION #ifdef TRACK_DESTRUCTION
cerr << "delete named selections\n"; cerr << "delete named selections\n";