summaryrefslogtreecommitdiff
path: root/gtk2_ardour/session_dialog.cc
diff options
context:
space:
mode:
authorColin Fletcher <colin.m.fletcher@googlemail.com>2014-06-06 13:25:13 +0100
committerColin Fletcher <colin.m.fletcher@googlemail.com>2014-06-12 23:20:06 +0100
commitbe7da2e9526c394b14d1b84129c400bc0dc0f96d (patch)
tree50cce03c4ad86034683afc3ffdfddcfd77f0e084 /gtk2_ardour/session_dialog.cc
parent83ce8dde6bdaba12a53b640ebe34c15407f0ac8b (diff)
Fix opening of recent sessions with mismatched directory & file names
When populating the list of recent sessions, and there's only one session file in the session folder, don't assume that the base name of the session file is the same as the name of the session directory. Allows loading sessions that were created with trailing spaces in their names from the recent sessions list, and also helps in the case that the session file (or directory) was renamed. There are actually two implementations of the 'recent sessions' chooser: this applies to both. I suppose a useful project one of these days would be to unify the two...
Diffstat (limited to 'gtk2_ardour/session_dialog.cc')
-rw-r--r--gtk2_ardour/session_dialog.cc14
1 files changed, 11 insertions, 3 deletions
diff --git a/gtk2_ardour/session_dialog.cc b/gtk2_ardour/session_dialog.cc
index ffac30e22c..a541c90c40 100644
--- a/gtk2_ardour/session_dialog.cc
+++ b/gtk2_ardour/session_dialog.cc
@@ -653,9 +653,10 @@ SessionDialog::redisplay_recent_sessions ()
float sr;
SampleFormat sf;
- std::string s = Glib::build_filename (dirname, state_file_names.front() + statefile_suffix);
+ std::string state_file_basename = state_file_names.front();
+
+ std::string s = Glib::build_filename (dirname, state_file_basename + statefile_suffix);
- row[recent_session_columns.visible_name] = Glib::path_get_basename (dirname);
row[recent_session_columns.fullpath] = dirname; /* just the dir, but this works too */
row[recent_session_columns.tip] = Glib::Markup::escape_text (dirname);
@@ -680,9 +681,13 @@ SessionDialog::redisplay_recent_sessions ()
++session_snapshot_count;
if (state_file_names.size() > 1) {
+ // multiple session files in the session directory - show the directory name.
+ // if there's not a session file with the same name as the session directory,
+ // opening the parent item will fail, but expanding it will show the session
+ // files that actually exist, and the right one can then be opened.
+ row[recent_session_columns.visible_name] = Glib::path_get_basename (dirname);
// add the children
-
for (std::vector<std::string>::iterator i2 = state_file_names.begin(); i2 != state_file_names.end(); ++i2) {
Gtk::TreeModel::Row child_row = *(recent_session_model->append (row.children()));
@@ -712,6 +717,9 @@ SessionDialog::redisplay_recent_sessions ()
++session_snapshot_count;
}
+ } else {
+ // only a single session file in the directory - show its actual name.
+ row[recent_session_columns.visible_name] = state_file_basename;
}
}