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_outline_what() = (guint32) 0;
if(!is_automation_ghost()) {
if (!is_automation_ghost()) {
base_rect->hide();
}
@ -59,15 +59,15 @@ GhostRegion::GhostRegion (ArdourCanvas::Group* parent, TimeAxisView& tv, TimeAxi
GhostRegion::~GhostRegion ()
{
GoingAway (this);
/*GoingAway (this);
delete base_rect;
delete group;
delete group;*/
}
void
GhostRegion::set_duration (double units)
{
base_rect->property_x2() = units;
base_rect->property_x2() = units;
}
void
@ -79,7 +79,7 @@ GhostRegion::set_height ()
void
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_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GhostTrackBase.get();
}
@ -136,7 +136,7 @@ AudioGhostRegion::set_colors ()
GhostRegion::set_colors();
guint fill_color;
if(is_automation_ghost()) {
if (is_automation_ghost()) {
fill_color = ARDOUR_UI::config()->canvasvar_GhostTrackWaveFill.get();
}
else {
@ -157,47 +157,59 @@ AudioGhostRegion::set_colors ()
* no range controller in these tracks. maybe show the whole range.
*/
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();
}
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();
}
MidiGhostRegion::~MidiGhostRegion()
{
//clear_events();
}
MidiGhostRegion::Event::Event(ArdourCanvas::CanvasMidiEvent* e)
: event(e) {
: event(e)
{
}
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());
}
MidiGhostRegion::Note::~Note() {
delete rect;
MidiGhostRegion::Note::~Note()
{
//delete rect;
}
void
MidiGhostRegion::Note::x_changed() {
MidiGhostRegion::Note::x_changed()
{
rect->property_x1() = event->x1();
rect->property_x2() = event->x2();
}
MidiGhostRegion::Hit::Hit(ArdourCanvas::CanvasHit* h, ArdourCanvas::Group*)
: Event(h) {
: Event(h)
{
cerr << "Hit ghost item does not work yet" << endl;
}
MidiGhostRegion::Hit::~Hit() {
MidiGhostRegion::Hit::~Hit()
{
}
void
MidiGhostRegion::Hit::x_changed() {
MidiGhostRegion::Hit::x_changed()
{
}
void
@ -206,10 +218,11 @@ MidiGhostRegion::set_samples_per_unit (double spu)
}
MidiStreamView*
MidiGhostRegion::midi_view() {
MidiGhostRegion::midi_view()
{
MidiTimeAxisView* mtv;
if((mtv = dynamic_cast<MidiTimeAxisView*>(&trackview)) != 0) {
if ((mtv = dynamic_cast<MidiTimeAxisView*>(&trackview)) != 0) {
return mtv->midi_view();
}
else {
@ -218,20 +231,22 @@ MidiGhostRegion::midi_view() {
}
void
MidiGhostRegion::set_height() {
MidiGhostRegion::set_height()
{
GhostRegion::set_height();
update_range();
}
void
MidiGhostRegion::set_colors() {
MidiGhostRegion::set_colors()
{
MidiGhostRegion::Note* note;
guint fill = source_track_color(200);
GhostRegion::set_colors();
for(EventList::iterator it = events.begin(); it != events.end(); ++it) {
if((note = dynamic_cast<MidiGhostRegion::Note*>(*it)) != 0) {
for (EventList::iterator it = events.begin(); it != events.end(); ++it) {
if ((note = dynamic_cast<MidiGhostRegion::Note*>(*it)) != 0) {
note->rect->property_fill_color_rgba() = fill;
note->rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_GhostTrackMidiOutline.get();
}
@ -239,10 +254,11 @@ MidiGhostRegion::set_colors() {
}
void
MidiGhostRegion::update_range() {
MidiGhostRegion::update_range()
{
MidiStreamView* mv = midi_view();
if(!mv) {
if (!mv) {
return;
}
@ -250,11 +266,11 @@ MidiGhostRegion::update_range() {
uint8_t note_num;
double y;
for(EventList::iterator it = events.begin(); it != events.end(); ++it) {
if((note = dynamic_cast<MidiGhostRegion::Note*>(*it)) != 0) {
for (EventList::iterator it = events.begin(); it != events.end(); ++it) {
if ((note = dynamic_cast<MidiGhostRegion::Note*>(*it)) != 0) {
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();
}
else {
@ -268,7 +284,8 @@ MidiGhostRegion::update_range() {
}
void
MidiGhostRegion::add_note(ArdourCanvas::CanvasNote* n) {
MidiGhostRegion::add_note(ArdourCanvas::CanvasNote* n)
{
Note* note = new Note(n, group);
events.push_back(note);
@ -277,15 +294,13 @@ MidiGhostRegion::add_note(ArdourCanvas::CanvasNote* n) {
MidiStreamView* mv = midi_view();
if(mv) {
uint8_t note_num = n->note()->note();
double y;
if (mv) {
const uint8_t note_num = n->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();
}
else {
y = mv->note_to_y(note_num);
} else {
const double y = mv->note_to_y(note_num);
note->rect->property_y1() = y;
note->rect->property_y2() = y + mv->note_height();
}
@ -293,15 +308,18 @@ MidiGhostRegion::add_note(ArdourCanvas::CanvasNote* n) {
}
void
MidiGhostRegion::add_hit(ArdourCanvas::CanvasHit* h) {
MidiGhostRegion::add_hit(ArdourCanvas::CanvasHit* h)
{
//events.push_back(new Hit(h, group));
}
void
MidiGhostRegion::clear_events() {
for(EventList::iterator it = events.begin(); it != events.end(); ++it) {
MidiGhostRegion::clear_events()
{
for (EventList::iterator it = events.begin(); it != events.end(); ++it) {
delete *it;
}
events.clear();
}

View file

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

View file

@ -381,17 +381,16 @@ MidiRegionView::create_note_at(double x, double y, double dur)
void
MidiRegionView::clear_events()
{
for (std::vector<CanvasMidiEvent*>::iterator i = _events.begin(); i != _events.end(); ++i)
delete *i;
MidiGhostRegion* gr;
for(vector<GhostRegion*>::iterator g = ghosts.begin(); g != ghosts.end(); ++g) {
if((gr = dynamic_cast<MidiGhostRegion*>(*g)) != 0) {
for (vector<GhostRegion*>::iterator g = ghosts.begin(); g != ghosts.end(); ++g) {
if ((gr = dynamic_cast<MidiGhostRegion*>(*g)) != 0) {
gr->clear_events();
}
}
for (std::vector<CanvasMidiEvent*>::iterator i = _events.begin(); i != _events.end(); ++i)
delete *i;
_events.clear();
}
@ -465,12 +464,16 @@ MidiRegionView::redisplay_model()
MidiRegionView::~MidiRegionView ()
{
in_destructor = true;
RegionViewGoingAway (this); /* EMIT_SIGNAL */
if (_active_notes)
end_write();
_selection.clear();
clear_events();
RegionViewGoingAway (this); /* EMIT_SIGNAL */
delete _note_group;
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) {
CanvasNote* note = dynamic_cast<CanvasNote*>(*i);
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()) {
if(canvas_item_visible(note)) {
if (canvas_item_visible(note)) {
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 y2 = y1 + floor(midi_stream_view()->note_height());
if(!canvas_item_visible(note)) {
if (!canvas_item_visible(note)) {
note->show();
}
@ -556,7 +559,7 @@ MidiRegionView::add_ghost (TimeAxisView& tv)
MidiTimeAxisView* mtv = dynamic_cast<MidiTimeAxisView*>(&tv);
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.
this is because it's nice to have midi notes on top of the note lines and
audio waveforms under it.
@ -572,7 +575,7 @@ MidiRegionView::add_ghost (TimeAxisView& tv)
ghosts.push_back (ghost);
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);
}
}
@ -683,8 +686,8 @@ MidiRegionView::add_note(const boost::shared_ptr<Note> note)
MidiGhostRegion* gr;
for(vector<GhostRegion*>::iterator g = ghosts.begin(); g != ghosts.end(); ++g) {
if((gr = dynamic_cast<MidiGhostRegion*>(*g)) != 0) {
for (vector<GhostRegion*>::iterator g = ghosts.begin(); g != ghosts.end(); ++g) {
if ((gr = dynamic_cast<MidiGhostRegion*>(*g)) != 0) {
gr->add_note(ev_rect);
}
}

View file

@ -137,15 +137,11 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session& sess, boost::shar
MidiTimeAxisView::~MidiTimeAxisView ()
{
if(_piano_roll_header) {
delete _piano_roll_header;
_piano_roll_header = 0;
}
delete _piano_roll_header;
_piano_roll_header = 0;
if(_range_scroomer) {
delete _range_scroomer;
_range_scroomer = 0;
}
delete _range_scroomer;
_range_scroomer = 0;
}
MidiStreamView*
@ -267,7 +263,7 @@ MidiTimeAxisView::update_range()
MidiGhostRegion* mgr;
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();
}
}

View file

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

View file

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

View file

@ -47,6 +47,7 @@ using namespace Editing;
StreamView::StreamView (RouteTimeAxisView& tv, ArdourCanvas::Group* group)
: _trackview (tv)
, owns_canvas_group(group == 0)
, canvas_group(group ? group : new ArdourCanvas::Group(*_trackview.canvas_display))
, canvas_rect(new ArdourCanvas::SimpleRect (*canvas_group))
, _samples_per_unit(_trackview.editor.get_current_zoom())
@ -85,7 +86,12 @@ StreamView::StreamView (RouteTimeAxisView& tv, ArdourCanvas::Group* group)
StreamView::~StreamView ()
{
undisplay_diskstream ();
delete canvas_group;
delete canvas_rect;
if (owns_canvas_group) {
delete canvas_group;
}
}
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) {
if (((*i)->region()) == r) {
delete *i;
RegionView* rv = *i;
region_views.erase (i);
delete rv;
break;
}
}
@ -180,8 +187,11 @@ StreamView::remove_region_view (boost::weak_ptr<Region> weak_r)
void
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;
i = next;
}
region_views.clear();

View file

@ -127,6 +127,7 @@ protected:
virtual void color_handler () = 0;
RouteTimeAxisView& _trackview;
bool owns_canvas_group;
ArdourCanvas::Group* canvas_group;
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>
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()) {
return boost::shared_ptr<Region>();
}

View file

@ -334,6 +334,8 @@ Session::destroy ()
AudioDiskstream::free_working_buffers();
Route::SyncOrderKeys.clear();
#undef TRACK_DESTRUCTION
#ifdef TRACK_DESTRUCTION
cerr << "delete named selections\n";
@ -396,7 +398,7 @@ Session::destroy ()
#ifdef TRACK_DESTRUCTION
cerr << "delete routes\n";
#endif /* TRACK_DESTRUCTION */
{
{
RCUWriter<RouteList> writer (routes);
boost::shared_ptr<RouteList> r = writer.get_copy ();
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {