#include "ardour/filename_extensions.h"
#include "ardour/graph.h"
#include "ardour/midiport_manager.h"
+#include "ardour/scene_changer.h"
#include "ardour/midi_track.h"
#include "ardour/midi_ui.h"
#include "ardour/operations.h"
, _speakers (new Speakers)
, _order_hint (0)
, ignore_route_processor_changes (false)
+ , _scene_changer (0)
, _midi_ports (0)
, _mmc (0)
{
/* not strictly necessary, but doing it here allows the shared_ptr debugging to work */
playlists.reset ();
+ delete _scene_changer; _scene_changer = 0;
+
delete _mmc; _mmc = 0;
delete _midi_ports; _midi_ports = 0;
delete _locations; _locations = 0;
return cnt;
}
-string
-Session::generate_new_source_path_from_name (string path, string oldname, string newname, bool destructive)
-{
- string look_for;
- string old_basename = PBD::basename_nosuffix (oldname);
- string new_legalized = legalize_for_path (newname);
-
- /* note: we know (or assume) the old path is already valid */
-
- if (destructive) {
-
- /* destructive file sources have a name of the form:
-
- /path/to/Tnnnn-NAME(%[LR])?.wav
-
- the task here is to replace NAME with the new name.
- */
-
- string dir;
- string prefix;
- string::size_type dash;
-
- dir = Glib::path_get_dirname (path);
- path = Glib::path_get_basename (path);
-
- /* '-' is not a legal character for the NAME part of the path */
-
- if ((dash = path.find_last_of ('-')) == string::npos) {
- return "";
- }
-
- prefix = path.substr (0, dash);
-
- path += prefix;
- path += '-';
- path += new_legalized;
- path += native_header_format_extension (config.get_native_file_header_format(), DataType::AUDIO);
- path = Glib::build_filename (dir, path);
-
- } else {
-
- /* non-destructive file sources have a name of the form:
-
- /path/to/NAME-nnnnn(%[LR])?.ext
-
- the task here is to replace NAME with the new name.
- */
-
- string dir;
- string suffix;
- string::size_type dash;
- string::size_type postfix;
-
- dir = Glib::path_get_dirname (path);
- path = Glib::path_get_basename (path);
-
- /* '-' is not a legal character for the NAME part of the path */
-
- if ((dash = path.find_last_of ('-')) == string::npos) {
- return "";
- }
-
- suffix = path.substr (dash+1);
-
- // Suffix is now everything after the dash. Now we need to eliminate
- // the nnnnn part, which is done by either finding a '%' or a '.'
-
- postfix = suffix.find_last_of ("%");
- if (postfix == string::npos) {
- postfix = suffix.find_last_of ('.');
- }
-
- if (postfix != string::npos) {
- suffix = suffix.substr (postfix);
- } else {
- error << "Logic error in Session::change_source_path_by_name(), please report" << endl;
- return "";
- }
-
- const uint32_t limit = 10000;
- char buf[PATH_MAX+1];
-
- for (uint32_t cnt = 1; cnt <= limit; ++cnt) {
-
- snprintf (buf, sizeof(buf), "%s-%u%s", newname.c_str(), cnt, suffix.c_str());
-
- if (!matching_unsuffixed_filename_exists_in (dir, buf)) {
- path = Glib::build_filename (dir, buf);
- if (!source_by_path (path)) {
- break;
- }
- }
-
- path = "";
- }
-
- if (path.empty()) {
- fatal << string_compose (_("FATAL ERROR! Could not find a suitable version of %1 for a rename"),
- newname) << endl;
- /*NOTREACHED*/
- }
- }
-
- return path;
-}
-
/** Return the full path (in some session directory) for a new within-session source.
* \a name must be a session-unique name that does not contain slashes
* (e.g. as returned by new_*_source_name)
existing++;
break;
}
+
+ /* it is possible that we have the path already
+ * assigned to a source that has not yet been written
+ * (ie. the write source for a diskstream). we have to
+ * check this in order to make sure that our candidate
+ * path isn't used again, because that can lead to
+ * two Sources point to the same file with different
+ * notions of their removability.
+ */
+
+ string possible_path = Glib::build_filename (spath, buf);
+
+ if (source_by_path (possible_path)) {
+ existing++;
+ break;
+ }
}
if (existing == 0) {