Free some one time alloc of the UI (cleaner valgrind output)
authorRobin Gareus <robin@gareus.org>
Fri, 20 Jan 2017 10:48:59 +0000 (11:48 +0100)
committerRobin Gareus <robin@gareus.org>
Fri, 20 Jan 2017 12:53:37 +0000 (13:53 +0100)
No incremental leaks here..
* downcase (const char*) uses strdup, caller needs to free
* free allocated cursors when the editor is destroyed
* drop static editor lua-instance & bindings
* delete allocated gtk image/icons

gtk2_ardour/ardour_ui.cc
gtk2_ardour/editor.cc
gtk2_ardour/luainstance.cc
gtk2_ardour/luainstance.h
gtk2_ardour/mouse_cursors.cc
gtk2_ardour/mouse_cursors.h
gtk2_ardour/ui_config.cc

index d9ea44c3256821b4cf83f7c54dca3c7936be6c32..7f5ceeef1d55cc60a9f4051cea1bfc7bf600d850 100644 (file)
@@ -746,6 +746,7 @@ ARDOUR_UI::~ARDOUR_UI ()
                delete luawindow; luawindow = 0;
                delete editor; editor = 0;
                delete mixer; mixer = 0;
+               delete rc_option_editor; rc_option_editor = 0; // failed to wrap object warning
                delete nsm; nsm = 0;
                delete gui_object_state; gui_object_state = 0;
                delete main_window_visibility;
@@ -5566,7 +5567,7 @@ ARDOUR_UI::setup_toplevel_window (Gtk::Window& window, const string& name, void*
        }
 
        window.set_title (title.get_string());
-       window.set_wmclass (string_compose (X_("%1_%1"), downcase (PROGRAM_NAME), downcase (name)), PROGRAM_NAME);
+       window.set_wmclass (string_compose (X_("%1_%1"), downcase (std::string(PROGRAM_NAME)), downcase (name)), PROGRAM_NAME);
 
        window.set_flags (CAN_FOCUS);
        window.add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
index 880963956f2b6faec6f40a5a4bad488c64449ec6..0809ab61cb9fd6a5c67226600bf1f70cb1bfd341 100644 (file)
@@ -890,10 +890,21 @@ Editor::~Editor()
        delete _locations;
        delete _playlist_selector;
        delete _time_info_box;
+       delete selection;
+       delete cut_buffer;
+       delete _cursors;
+
+       LuaInstance::destroy_instance ();
 
        for (list<XMLNode *>::iterator i = selection_op_history.begin(); i != selection_op_history.end(); ++i) {
                delete *i;
        }
+       for (std::map<ARDOUR::FadeShape, Gtk::Image*>::const_iterator i = _xfade_in_images.begin(); i != _xfade_in_images.end (); ++i) {
+               delete i->second;
+       }
+       for (std::map<ARDOUR::FadeShape, Gtk::Image*>::const_iterator i = _xfade_out_images.begin(); i != _xfade_out_images.end (); ++i) {
+               delete i->second;
+       }
 }
 
 XMLNode*
index 1478f9790b13ac9af03efc9ec65722e96bfce005..567347f81ea66d8050b267dc84ed740d15df52a8 100644 (file)
@@ -833,6 +833,13 @@ LuaInstance::instance ()
        return _instance;
 }
 
+void
+LuaInstance::destroy_instance ()
+{
+       delete _instance;
+       _instance = 0;
+}
+
 LuaInstance::LuaInstance ()
 {
        lua.Print.connect (&_lua_print);
index 42917320974a5608efbd226bb5433e1b3a2f3e31..cad533e7534691bbe72c976abde8d18a7b602635 100644 (file)
@@ -79,6 +79,7 @@ class LuaInstance : public PBD::ScopedConnectionList, public ARDOUR::SessionHand
 {
 public:
        static LuaInstance* instance();
+       static void destroy_instance();
        ~LuaInstance();
 
        static void register_classes (lua_State* L);
index 68ad19ebb7243f5f72a203bb20f502e7a79db13f..afe743a7d3225d4eb3fd8fee1fbc779a11b9e21c 100644 (file)
@@ -72,6 +72,11 @@ MouseCursors::MouseCursors ()
 {
 }
 
+MouseCursors::~MouseCursors ()
+{
+       drop_all ();
+}
+
 void
 MouseCursors::drop_all ()
 {
index 8cd98ac32c9befb51d978c503bfc8d4bfcbab340..ed29840b68044cbedf7e402cf178e1fc60e825ad 100644 (file)
@@ -29,6 +29,7 @@ class MouseCursors
 {
 public:
        MouseCursors ();
+       ~MouseCursors ();
 
        void set_cursor_set (const std::string& name);
        std::string cursor_set() const { return _cursor_set; }
index 024357b2667de250fc93361de7338ca3c99a6281..3b45eb7a70683c766b49a3b5d5357b9959d8064b 100644 (file)
@@ -268,7 +268,7 @@ UIConfiguration::color_file_name (bool use_my, bool with_version) const
 
        basename += color_name;
        basename += "-";
-       basename += downcase(PROGRAM_NAME);
+       basename += downcase(std::string(PROGRAM_NAME));
 
        std::string rev (revision);
        std::size_t pos = rev.find_first_of("-");