* fixed memory allocation bugs

* commented out a crash line in ardour_ui2.cc (added a warning message).
  (I thought, it may be fairly efficient to keep issues as code instead of putting
  them in the tracker where hardly ever one would notice the needle in the haystack)
* forgot to clear two other collections on MidiPatchManager::refresh()


git-svn-id: svn://localhost/ardour2/branches/3.0@4312 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Hans Baier 2008-12-12 06:57:38 +00:00
parent 6c1f365515
commit 30daaebaa2
6 changed files with 32 additions and 13 deletions

View File

@ -877,7 +877,8 @@ ARDOUR_UI::editor_realized ()
set_size_request_to_display_given_text (speed_display_box, _("-0.55"), 2, 2);
const guint32 FUDGE = 25; // Combo's are stupid - they steal space from the entry for the button
set_size_request_to_display_given_text (shuttle_style_button, _("sprung"), 2+FUDGE, 10);
reset_dpi();
cerr << "I commented out line line 881 in ardour_ui2.cc, because it made ardour crash somewhere in Gnome::Canvas::Text" << endl;
//reset_dpi();
}
void

View File

@ -5,16 +5,32 @@
using namespace Gnome::Canvas;
using namespace std;
void
CanvasFlag::set_text(string& a_text)
CanvasFlag::delete_allocated_objects()
{
if (_text) {
delete _text;
_text = 0;
}
_text = new Text(*this, 0.0, 0.0, a_text);
if (_line) {
delete _line;
_line = 0;
}
if (_rect) {
delete _rect;
_rect = 0;
}
}
void
CanvasFlag::set_text(string& a_text)
{
delete_allocated_objects();
_text = new Text(*this, 0.0, 0.0, Glib::ustring(a_text));
_text->property_justification() = Gtk::JUSTIFY_CENTER;
_text->property_fill_color_rgba() = _outline_color_rgba;
double flagwidth = _text->property_text_width() + 10.0;
@ -33,10 +49,6 @@ CanvasFlag::set_text(string& a_text)
CanvasFlag::~CanvasFlag()
{
delete _line;
delete _rect;
if(_text) {
delete _text;
}
delete_allocated_objects();
}

View File

@ -47,6 +47,8 @@ protected:
guint _fill_color_rgba;
private:
void delete_allocated_objects();
MidiRegionView& _region;
SimpleLine* _line;
SimpleRect* _rect;

View File

@ -658,7 +658,7 @@ MidiRegionView::find_and_insert_program_change_flags()
lsb = uint8_t(lsb_control->get_float(true, event_time));
}
//cerr << " got msb " << int(msb) << " and lsb " << int(lsb) << endl;
cerr << " got msb " << int(msb) << " and lsb " << int(lsb) << " thread_id: " << pthread_self() << endl;
patch = master_device->find_patch(
_custom_device_mode,
@ -668,9 +668,9 @@ MidiRegionView::find_and_insert_program_change_flags()
uint8_t(program_number)
);
//cerr << " got patch with name " << patch.name() << " number " << patch.number() << endl;
}
if (patch != 0) {
cerr << " got patch with name " << patch->name() << " number " << patch->number() << endl;
add_pgm_change(event_time, patch->name());
} else {
char buf[4];
@ -1000,7 +1000,7 @@ MidiRegionView::add_pgm_change(nframes_t time, string displaytext)
{
assert(time >= 0);
// dont display notes beyond the region bounds
// dont display program changes beyond the region bounds
if (time - _region->start() >= _region->length() || time < _region->start())
return;

View File

@ -195,7 +195,7 @@ void MidiTimeAxisView::model_changed()
_custom_device_mode_selector.clear_items();
for (std::list<std::string>::const_iterator i = device_modes.begin(); i != device_modes.end(); ++i) {
cerr << "found custom device mode " << *i << endl;
cerr << "found custom device mode " << *i << " thread_id: " << pthread_self() << endl;
_custom_device_mode_selector.append_text(*i);
}

View File

@ -50,6 +50,8 @@ void
MidiPatchManager::refresh()
{
_documents.clear();
_master_devices_by_model.clear();
_all_models.clear();
path path_to_patches = _session->session_directory().midi_patch_path();
@ -97,4 +99,6 @@ MidiPatchManager::drop_session ()
{
_session = 0;
_documents.clear();
_master_devices_by_model.clear();
_all_models.clear();
}