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

@ -46,7 +46,7 @@ GhostRegion::GhostRegion (ArdourCanvas::Group* parent, TimeAxisView& tv, TimeAxi
base_rect->property_y2() = (double) trackview.height; base_rect->property_y2() = (double) trackview.height;
base_rect->property_outline_what() = (guint32) 0; base_rect->property_outline_what() = (guint32) 0;
if(!is_automation_ghost()) { if (!is_automation_ghost()) {
base_rect->hide(); base_rect->hide();
} }
@ -59,15 +59,15 @@ 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
GhostRegion::set_duration (double units) GhostRegion::set_duration (double units)
{ {
base_rect->property_x2() = units; base_rect->property_x2() = units;
} }
void void
@ -79,7 +79,7 @@ GhostRegion::set_height ()
void void
GhostRegion::set_colors () GhostRegion::set_colors ()
{ {
if(is_automation_ghost()) { if (is_automation_ghost()) {
base_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_GhostTrackBase.get(); base_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_GhostTrackBase.get();
base_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GhostTrackBase.get(); base_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GhostTrackBase.get();
} }
@ -136,7 +136,7 @@ AudioGhostRegion::set_colors ()
GhostRegion::set_colors(); GhostRegion::set_colors();
guint fill_color; guint fill_color;
if(is_automation_ghost()) { if (is_automation_ghost()) {
fill_color = ARDOUR_UI::config()->canvasvar_GhostTrackWaveFill.get(); fill_color = ARDOUR_UI::config()->canvasvar_GhostTrackWaveFill.get();
} }
else { else {
@ -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,10 +218,11 @@ 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) {
return mtv->midi_view(); return mtv->midi_view();
} }
else { else {
@ -218,20 +231,22 @@ 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);
GhostRegion::set_colors(); GhostRegion::set_colors();
for(EventList::iterator it = events.begin(); it != events.end(); ++it) { for (EventList::iterator it = events.begin(); it != events.end(); ++it) {
if((note = dynamic_cast<MidiGhostRegion::Note*>(*it)) != 0) { if ((note = dynamic_cast<MidiGhostRegion::Note*>(*it)) != 0) {
note->rect->property_fill_color_rgba() = fill; note->rect->property_fill_color_rgba() = fill;
note->rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_GhostTrackMidiOutline.get(); note->rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_GhostTrackMidiOutline.get();
} }
@ -239,10 +254,11 @@ MidiGhostRegion::set_colors() {
} }
void void
MidiGhostRegion::update_range() { MidiGhostRegion::update_range()
{
MidiStreamView* mv = midi_view(); MidiStreamView* mv = midi_view();
if(!mv) { if (!mv) {
return; return;
} }
@ -250,11 +266,11 @@ MidiGhostRegion::update_range() {
uint8_t note_num; uint8_t note_num;
double y; double y;
for(EventList::iterator it = events.begin(); it != events.end(); ++it) { for (EventList::iterator it = events.begin(); it != events.end(); ++it) {
if((note = dynamic_cast<MidiGhostRegion::Note*>(*it)) != 0) { if ((note = dynamic_cast<MidiGhostRegion::Note*>(*it)) != 0) {
note_num = note->event->note()->note(); note_num = note->event->note()->note();
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 {
@ -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);
@ -277,15 +294,13 @@ 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;
} }
@ -517,9 +520,9 @@ MidiRegionView::set_y_position_and_height (double y, double h)
for (std::vector<CanvasMidiEvent*>::const_iterator i = _events.begin(); i != _events.end(); ++i) { for (std::vector<CanvasMidiEvent*>::const_iterator i = _events.begin(); i != _events.end(); ++i) {
CanvasNote* note = dynamic_cast<CanvasNote*>(*i); CanvasNote* note = dynamic_cast<CanvasNote*>(*i);
if (note && note->note()) { if (note && note->note()) {
if(note->note()->note() < midi_stream_view()->lowest_note() || if (note->note()->note() < midi_stream_view()->lowest_note() ||
note->note()->note() > midi_stream_view()->highest_note()) { note->note()->note() > midi_stream_view()->highest_note()) {
if(canvas_item_visible(note)) { if (canvas_item_visible(note)) {
note->hide(); note->hide();
} }
} }
@ -527,7 +530,7 @@ MidiRegionView::set_y_position_and_height (double y, double h)
const double y1 = midi_stream_view()->note_to_y(note->note()->note()); const double y1 = midi_stream_view()->note_to_y(note->note()->note());
const double y2 = y1 + floor(midi_stream_view()->note_height()); const double y2 = y1 + floor(midi_stream_view()->note_height());
if(!canvas_item_visible(note)) { if (!canvas_item_visible(note)) {
note->show(); note->show();
} }
@ -556,7 +559,7 @@ MidiRegionView::add_ghost (TimeAxisView& tv)
MidiTimeAxisView* mtv = dynamic_cast<MidiTimeAxisView*>(&tv); MidiTimeAxisView* mtv = dynamic_cast<MidiTimeAxisView*>(&tv);
MidiGhostRegion* ghost; MidiGhostRegion* ghost;
if(mtv && mtv->midi_view()) { if (mtv && mtv->midi_view()) {
/* if ghost is inserted into midi track, use a dedicated midi ghost canvas group. /* if ghost is inserted into midi track, use a dedicated midi ghost canvas group.
this is because it's nice to have midi notes on top of the note lines and this is because it's nice to have midi notes on top of the note lines and
audio waveforms under it. audio waveforms under it.
@ -572,7 +575,7 @@ MidiRegionView::add_ghost (TimeAxisView& tv)
ghosts.push_back (ghost); ghosts.push_back (ghost);
for (std::vector<CanvasMidiEvent*>::iterator i = _events.begin(); i != _events.end(); ++i) { for (std::vector<CanvasMidiEvent*>::iterator i = _events.begin(); i != _events.end(); ++i) {
if((note = dynamic_cast<CanvasNote*>(*i)) != 0) { if ((note = dynamic_cast<CanvasNote*>(*i)) != 0) {
ghost->add_note(note); ghost->add_note(note);
} }
} }
@ -683,8 +686,8 @@ MidiRegionView::add_note(const boost::shared_ptr<Note> note)
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->add_note(ev_rect); gr->add_note(ev_rect);
} }
} }

View file

@ -137,15 +137,11 @@ 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*
@ -267,7 +263,7 @@ MidiTimeAxisView::update_range()
MidiGhostRegion* mgr; MidiGhostRegion* mgr;
for(list<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) { for(list<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
if((mgr = dynamic_cast<MidiGhostRegion*>(*i)) != 0) { if ((mgr = dynamic_cast<MidiGhostRegion*>(*i)) != 0) {
mgr->update_range(); mgr->update_range();
} }
} }

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,7 +86,12 @@ StreamView::StreamView (RouteTimeAxisView& tv, ArdourCanvas::Group* group)
StreamView::~StreamView () StreamView::~StreamView ()
{ {
undisplay_diskstream (); undisplay_diskstream ();
delete canvas_group;
delete canvas_rect;
if (owns_canvas_group) {
delete canvas_group;
}
} }
void void
@ -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";
@ -396,7 +398,7 @@ Session::destroy ()
#ifdef TRACK_DESTRUCTION #ifdef TRACK_DESTRUCTION
cerr << "delete routes\n"; cerr << "delete routes\n";
#endif /* TRACK_DESTRUCTION */ #endif /* TRACK_DESTRUCTION */
{ {
RCUWriter<RouteList> writer (routes); RCUWriter<RouteList> writer (routes);
boost::shared_ptr<RouteList> r = writer.get_copy (); boost::shared_ptr<RouteList> r = writer.get_copy ();
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {