- string markername;
- if (session) {
- session->locations()->next_available_name(markername,"mark");
- Location *location = new Location (where, where, markername, Location::IsMark);
- session->begin_reversible_command (_("add marker"));
- XMLNode &before = session->locations()->get_state();
- session->locations()->add (location, true);
- XMLNode &after = session->locations()->get_state();
- session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
- session->commit_reversible_command ();
+ string markername, markerprefix;
+ int flags = (is_cd ? Location::IsCDMarker|Location::IsMark : Location::IsMark);
+
+ if (is_xrun) {
+ markerprefix = "xrun";
+ flags = Location::IsMark;
+ } else {
+ markerprefix = "mark";
+ }
+
+ if (_session) {
+ _session->locations()->next_available_name(markername, markerprefix);
+ if (!is_xrun && !choose_new_marker_name(markername)) {
+ return;
+ }
+ Location *location = new Location (where, where, markername, (Location::Flags) flags);
+ _session->begin_reversible_command (_("add marker"));
+ XMLNode &before = _session->locations()->get_state();
+ _session->locations()->add (location, true);
+ XMLNode &after = _session->locations()->get_state();
+ _session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
+ _session->commit_reversible_command ();
+
+ /* find the marker we just added */
+
+ LocationMarkers *lam = find_location_markers (location);
+ if (lam) {
+ /* make it the selected marker */
+ selection->set (lam->start);
+ }