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 ()
{
GoingAway (this);
/*GoingAway (this);
delete base_rect;
delete group;
delete group;*/
}
void
@ -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,7 +218,8 @@ MidiGhostRegion::set_samples_per_unit (double spu)
}
MidiStreamView*
MidiGhostRegion::midi_view() {
MidiGhostRegion::midi_view()
{
MidiTimeAxisView* mtv;
if ((mtv = dynamic_cast<MidiTimeAxisView*>(&trackview)) != 0) {
@ -218,13 +231,15 @@ 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);
@ -239,7 +254,8 @@ MidiGhostRegion::set_colors() {
}
void
MidiGhostRegion::update_range() {
MidiGhostRegion::update_range()
{
MidiStreamView* mv = midi_view();
if (!mv) {
@ -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);
@ -278,14 +295,12 @@ MidiGhostRegion::add_note(ArdourCanvas::CanvasNote* n) {
MidiStreamView* mv = midi_view();
if (mv) {
uint8_t note_num = n->note()->note();
double y;
const uint8_t note_num = n->note()->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() {
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) {
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;
}

View file

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

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,8 +86,13 @@ StreamView::StreamView (RouteTimeAxisView& tv, ArdourCanvas::Group* group)
StreamView::~StreamView ()
{
undisplay_diskstream ();
delete canvas_rect;
if (owns_canvas_group) {
delete canvas_group;
}
}
void
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) {
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";