From 102081a389a7e7d36bbaaff1a32dec631bb70354 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 19 Dec 2012 17:07:27 +0000 Subject: [PATCH] fix crash reported by colinf when editing via >1 click on an audioclock. this caused pre_edit_string to be reset to an empty string on the non-first clicks, and then string::at() was used on it. both aspects fixed git-svn-id: svn://localhost/ardour2/branches/3.0@13682 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/audio_clock.cc | 46 ++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/gtk2_ardour/audio_clock.cc b/gtk2_ardour/audio_clock.cc index 18153ac785..c1d256fd02 100644 --- a/gtk2_ardour/audio_clock.cc +++ b/gtk2_ardour/audio_clock.cc @@ -569,28 +569,30 @@ AudioClock::show_edit_status (int length) void AudioClock::start_edit (Field f) { - pre_edit_string = _layout->get_text (); - if (!insert_map.empty()) { - edit_string = pre_edit_string; - } else { - edit_string.clear (); - _layout->set_text (""); + if (!editing) { + pre_edit_string = _layout->get_text (); + if (!insert_map.empty()) { + edit_string = pre_edit_string; + } else { + edit_string.clear (); + _layout->set_text (""); + } + + input_string.clear (); + editing = true; + edit_is_negative = false; + + if (f) { + input_string = get_field (f); + show_edit_status (merge_input_and_edit_string ()); + _layout->set_text (edit_string); + } + + queue_draw (); + + Keyboard::magic_widget_grab_focus (); + grab_focus (); } - - input_string.clear (); - editing = true; - edit_is_negative = false; - - if (f) { - input_string = get_field (f); - show_edit_status (merge_input_and_edit_string ()); - _layout->set_text (edit_string); - } - - queue_draw (); - - Keyboard::magic_widget_grab_focus (); - grab_focus (); } string @@ -1445,7 +1447,7 @@ AudioClock::on_key_press_event (GdkEventKey* ev) if (edit_is_negative) { edit_string.replace(0,1,"-"); } else { - if (pre_edit_string.at(0) == '-') { + if (!pre_edit_string.empty() && (pre_edit_string.at(0) == '-')) { edit_string.replace(0,1,"_"); } else { edit_string.replace(0,1," ");