- if (loc && !_have_captured) {
-
- /* first capture.
-
- note: later captures that extend the session length get
- handled because of playlist length changes.
- */
-
- add_undo (sigc::retype_return<void>(sigc::bind (mem_fun (*loc, &Location::set_end), loc->end())));
- add_redo (sigc::retype_return<void>(sigc::bind (mem_fun (*loc, &Location::set_end), _transport_frame)));
+ if (_transport_frame < loc->end()) {
+
+ /* stopped recording before current end */
+
+ if (config.get_end_marker_is_free()) {
+
+ /* first capture for this session, move end back to where we are */
+
+ change_end = true;
+ }
+
+ } else if (_transport_frame > loc->end()) {
+
+ /* stopped recording after the current end, extend it */
+
+ change_end = true;
+ }
+
+ if (change_end) {
+ XMLNode &before = loc->get_state();
+ loc->set_end(_transport_frame);
+ XMLNode &after = loc->get_state();
+ add_command (new MementoCommand<Location>(*loc, &before, &after));