13
0

Do not allow ctrl chars in session names (2/2)

The GUI applies this to new sessions only, old sessions that
may now have illegal names can still be loaded.
This commit is contained in:
Robin Gareus 2020-06-09 20:19:10 +02:00
parent 72d45c154a
commit 50e96a2135
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 23 additions and 23 deletions

View File

@ -229,9 +229,9 @@ ARDOUR_UI::session_dialog_response_handler (int response, SessionDialog* session
session_path = session_dialog->session_folder(); session_path = session_dialog->session_folder();
char illegal = Session::session_name_is_legal (session_name); std::string const& illegal = Session::session_name_is_legal (session_name);
if (illegal) { if (!illegal.empty()) {
ArdourMessageDialog msg (*session_dialog, ArdourMessageDialog msg (*session_dialog,
string_compose (_("To ensure compatibility with various systems\n" string_compose (_("To ensure compatibility with various systems\n"
"session names may not contain a '%1' character"), "session names may not contain a '%1' character"),
@ -263,9 +263,9 @@ ARDOUR_UI::session_dialog_response_handler (int response, SessionDialog* session
return; /* back to main event loop */ return; /* back to main event loop */
} }
char illegal = Session::session_name_is_legal(session_name); std::string const& illegal = Session::session_name_is_legal (session_name);
if (illegal) { if (!illegal.empty()) {
ArdourMessageDialog msg (*session_dialog, string_compose(_("To ensure compatibility with various systems\n" ArdourMessageDialog msg (*session_dialog, string_compose(_("To ensure compatibility with various systems\n"
"session names may not contain a '%1' character"), illegal)); "session names may not contain a '%1' character"), illegal));
msg.run (); msg.run ();
@ -794,9 +794,9 @@ ARDOUR_UI::rename_session (bool for_unnamed)
bool do_rename = (name.length() != 0); bool do_rename = (name.length() != 0);
if (do_rename) { if (do_rename) {
char illegal = Session::session_name_is_legal (name); std::string const& illegal = Session::session_name_is_legal (name);
if (illegal) { if (!illegal.empty()) {
ArdourMessageDialog msg (string_compose (_("To ensure compatibility with various systems\n" ArdourMessageDialog msg (string_compose (_("To ensure compatibility with various systems\n"
"session names may not contain a '%1' character"), illegal)); "session names may not contain a '%1' character"), illegal));
msg.run (); msg.run ();
@ -1008,8 +1008,8 @@ ARDOUR_UI::process_snapshot_session_prompter (Prompter& prompter, bool switch_to
bool do_save = (snapname.length() != 0); bool do_save = (snapname.length() != 0);
if (do_save) { if (do_save) {
char illegal = Session::session_name_is_legal(snapname); std::string const& illegal = Session::session_name_is_legal (snapname);
if (illegal) { if (!illegal.empty()) {
ArdourMessageDialog msg (string_compose (_("To ensure compatibility with various systems\n" ArdourMessageDialog msg (string_compose (_("To ensure compatibility with various systems\n"
"snapshot names may not contain a '%1' character"), illegal)); "snapshot names may not contain a '%1' character"), illegal));
msg.run (); msg.run ();

View File

@ -732,21 +732,6 @@ StartupFSM::check_session_parameters (bool must_be_new)
/* session name is just a name */ /* session name is just a name */
} }
/* check if name is legal */
const char illegal = Session::session_name_is_legal (session_name);
if (illegal) {
ArdourMessageDialog msg (*session_dialog,
string_compose (_("To ensure compatibility with various systems\n"
"session names may not contain a '%1' character"),
illegal));
msg.run ();
ARDOUR_COMMAND_LINE::session_name = ""; // cancel that
return 1; /* keep running dialog */
}
/* check if the currently-exists status matches whether or not /* check if the currently-exists status matches whether or not
* it should be new * it should be new
*/ */
@ -780,6 +765,21 @@ StartupFSM::check_session_parameters (bool must_be_new)
session_is_new = true; session_is_new = true;
} }
/* check if name is legal (error for new sessions only) */
std::string const& illegal = Session::session_name_is_legal (session_name);
if (!illegal.empty() && session_is_new) {
ArdourMessageDialog msg (*session_dialog,
string_compose (_("To ensure compatibility with various systems\n"
"session names may not contain a '%1' character"),
illegal));
msg.run ();
ARDOUR_COMMAND_LINE::session_name = ""; // cancel that
return 1; /* keep running dialog */
}
float sr; float sr;
SampleFormat fmt; SampleFormat fmt;
string program_version; string program_version;