summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2020-03-24 13:20:24 -0600
committerPaul Davis <paul@linuxaudiosystems.com>2020-03-24 14:10:39 -0600
commite9be6c23a87e53b825357849576636bdb5e40787 (patch)
tree446268c54d79ee7be3f9918f65e3dafec6755ffa
parent5d4ad01b58531a520805420be4b076aa119f8869 (diff)
a better approach to the name of the "unnamed" indicator file; remove file after successful save
-rw-r--r--libs/ardour/ardour/session.h2
-rw-r--r--libs/ardour/session_state.cc15
2 files changed, 13 insertions, 4 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 0f27ac5029..6b01d0c990 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -2169,6 +2169,8 @@ private:
boost::optional<samplepos_t> _nominal_jack_transport_sample;
bool _had_destructive_tracks;
+
+ std::string unnamed_file_name () const;
};
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index b44b42294c..f82962ef3d 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -159,8 +159,6 @@ using namespace PBD;
#define DEBUG_UNDO_HISTORY(msg) DEBUG_TRACE (PBD::DEBUG::UndoHistory, string_compose ("%1: %2\n", __LINE__, msg));
-static const char* unnamed_file_name = X_(".unnamed");
-
void
Session::pre_engine_init (string fullpath)
{
@@ -584,7 +582,7 @@ Session::create (const string& session_template, BusProfile const * bus_profile,
}
if (unnamed) {
- PBD::ScopedFileDescriptor fd = g_open (Glib::build_filename (_path, unnamed_file_name).c_str(), O_CREAT|O_TRUNC|O_RDWR, 0666);
+ PBD::ScopedFileDescriptor fd = g_open (unnamed_file_name().c_str(), O_CREAT|O_TRUNC|O_RDWR, 0666);
}
if (ensure_subdirs ()) {
@@ -952,6 +950,9 @@ Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot
remove_pending_capture_state ();
}
+ /* remove unnamed file name, if any (it's not an error if it doesn't exist */
+ ::g_unlink (unnamed_file_name().c_str());
+
return 0;
}
@@ -5649,8 +5650,14 @@ Session::redo (uint32_t n)
_history.redo (n);
}
+std::string
+Session::unnamed_file_name() const
+{
+ return Glib::build_filename (_path, X_(".unnamed"));
+}
+
bool
Session::not_named() const
{
- return Glib::file_test (Glib::build_filename (_path, unnamed_file_name), Glib::FILE_TEST_EXISTS);
+ return Glib::file_test (unnamed_file_name(), Glib::FILE_TEST_EXISTS);
}