son't try to select non-existent notes after editing (and thus crash).
[ardour.git] / gtk2_ardour / time_axis_view.cc
index 5aa114f2865c5cb4592c22959197c7297a79a300..84eab4a6efd86f359e82785246303f49910707f5 100644 (file)
@@ -58,7 +58,7 @@
 #include "tooltips.h"
 #include "ui_config.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace Gtk;
@@ -88,8 +88,7 @@ TimeAxisView::setup_sizes()
 }
 
 TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisView* rent, Canvas& /*canvas*/)
-       : AxisView (sess)
-       , controls_table (5, 4)
+       : controls_table (5, 4)
        , controls_button_size_group (Gtk::SizeGroup::create (Gtk::SIZE_GROUP_BOTH))
        , _name_editing (false)
        , height (0)
@@ -739,24 +738,20 @@ TimeAxisView::popup_display_menu (guint32 when)
        conditionally_add_to_selection ();
 
        build_display_menu ();
-       display_menu->popup (1, when);
+
+       if (!display_menu->items().empty()) {
+               display_menu->popup (1, when);
+       }
 }
 
 void
 TimeAxisView::set_selected (bool yn)
 {
-#if 0
-       /* end any name edit in progress */
-       if (can_edit_name()) {
-               end_name_edit (string(), 0);
-       }
-#endif
-
-       if (yn == _selected) {
+       if (yn == selected()) {
                return;
        }
 
-       Selectable::set_selected (yn);
+       AxisView::set_selected (yn);
 
        if (_selected) {
                time_axis_frame.set_shadow_type (Gtk::SHADOW_IN);
@@ -937,6 +932,8 @@ TimeAxisView::order_selection_trims (ArdourCanvas::Item *item, bool put_start_on
        }
 }
 
+// retuned rect is pushed back into the used_selection_rects list
+// in TimeAxisView::show_selection() which is the only caller.
 SelectionRect *
 TimeAxisView::get_selection_rect (uint32_t id)
 {
@@ -946,7 +943,9 @@ TimeAxisView::get_selection_rect (uint32_t id)
 
        for (list<SelectionRect*>::iterator i = used_selection_rects.begin(); i != used_selection_rects.end(); ++i) {
                if ((*i)->id == id) {
-                       return (*i);
+                       SelectionRect* ret = (*i);
+                       used_selection_rects.erase (i);
+                       return ret;
                }
        }