From 50e96a2135076b532e36625884c9ccbff2024d6b Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 9 Jun 2020 20:19:10 +0200 Subject: [PATCH] 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. --- gtk2_ardour/ardour_ui_session.cc | 16 ++++++++-------- gtk2_ardour/startup_fsm.cc | 30 +++++++++++++++--------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/gtk2_ardour/ardour_ui_session.cc b/gtk2_ardour/ardour_ui_session.cc index c183e127e5..d4e6943237 100644 --- a/gtk2_ardour/ardour_ui_session.cc +++ b/gtk2_ardour/ardour_ui_session.cc @@ -229,9 +229,9 @@ ARDOUR_UI::session_dialog_response_handler (int response, SessionDialog* session 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, string_compose (_("To ensure compatibility with various systems\n" "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 */ } - 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" "session names may not contain a '%1' character"), illegal)); msg.run (); @@ -794,9 +794,9 @@ ARDOUR_UI::rename_session (bool for_unnamed) bool do_rename = (name.length() != 0); 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" "session names may not contain a '%1' character"), illegal)); msg.run (); @@ -1008,8 +1008,8 @@ ARDOUR_UI::process_snapshot_session_prompter (Prompter& prompter, bool switch_to bool do_save = (snapname.length() != 0); if (do_save) { - char illegal = Session::session_name_is_legal(snapname); - if (illegal) { + std::string const& illegal = Session::session_name_is_legal (snapname); + if (!illegal.empty()) { ArdourMessageDialog msg (string_compose (_("To ensure compatibility with various systems\n" "snapshot names may not contain a '%1' character"), illegal)); msg.run (); diff --git a/gtk2_ardour/startup_fsm.cc b/gtk2_ardour/startup_fsm.cc index 78cc9ccf9f..a1fc5e6c02 100644 --- a/gtk2_ardour/startup_fsm.cc +++ b/gtk2_ardour/startup_fsm.cc @@ -732,21 +732,6 @@ StartupFSM::check_session_parameters (bool must_be_new) /* 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 * it should be new */ @@ -780,6 +765,21 @@ StartupFSM::check_session_parameters (bool must_be_new) 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; SampleFormat fmt; string program_version;