* fixed memory allocation bugs
authorHans Baier <hansfbaier@googlemail.com>
Fri, 12 Dec 2008 06:57:38 +0000 (06:57 +0000)
committerHans Baier <hansfbaier@googlemail.com>
Fri, 12 Dec 2008 06:57:38 +0000 (06:57 +0000)
* 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

gtk2_ardour/ardour_ui2.cc
gtk2_ardour/canvas-flag.cc
gtk2_ardour/canvas-flag.h
gtk2_ardour/midi_region_view.cc
gtk2_ardour/midi_time_axis.cc
libs/ardour/midi_patch_manager.cc

index 47218e518b28d476b93ff3a63659b0d6b85d109d..d294df8036342be6f18c404d76757828ab6d9783 100644 (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
index 232035e4cf914f361c02af95d21627f6b71f009d..c40bf456483d5d65e0235fa513ef9c88b6aac1e2 100644 (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();
 }
 
index eb50798e8e1078b69263dc510562328bb67817e7..23fba78fee6451ae2cfeabb63ef3d8f51df9387e 100644 (file)
@@ -47,6 +47,8 @@ protected:
        guint                             _fill_color_rgba;
        
 private:
+       void delete_allocated_objects();
+       
        MidiRegionView&                   _region;
        SimpleLine*                       _line;
        SimpleRect*                       _rect;
index 5cd1f641271d52b0776275eb187519ab4ac75117..606366721008dff9944b9b09fd35b89f42b8f622 100644 (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;
        
index a8f6e3a6f43d77e078aa948cc2ec7a00db8af168..47733f9efbd39d8f0c54ab1a1e000dce4a8f379d 100644 (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);
        }
 
index bb57f4b10f5bf5af7be181bec02120c2a20bef91..cb1ba771f4bfe297645e1e8bc0f29045959330af 100644 (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();
 }