Prefer testing the session instead of using a global variable
authorRobin Gareus <robin@gareus.org>
Thu, 6 Dec 2018 01:23:53 +0000 (02:23 +0100)
committerRobin Gareus <robin@gareus.org>
Thu, 6 Dec 2018 01:24:31 +0000 (02:24 +0100)
gtk2_ardour/ardour_ui.cc
gtk2_ardour/ardour_ui.h
gtk2_ardour/ardour_ui_dialogs.cc
gtk2_ardour/editor.cc
gtk2_ardour/session_dialog.cc

index 2de87e0904f1c53b1f5e687737c8d552bc47a26b..6dd659420c84eff9c5ff9039dfb0ddbcec4c558b 100644 (file)
@@ -272,7 +272,6 @@ libxml_structured_error_func (void* /* parsing_context*/,
 
 ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
        : Gtkmm2ext::UI (PROGRAM_NAME, X_("gui"), argcp, argvp)
-       , session_loaded (false)
        , session_load_in_progress (false)
        , gui_object_state (new GUIObjectState)
        , primary_clock   (new MainClock (X_("primary"),   X_("transport"), true ))
@@ -3547,8 +3546,6 @@ ARDOUR_UI::load_session (const std::string& path, const std::string& snap_name,
                }
        }
 
-       session_loaded = false;
-
        loading_message (string_compose (_("Please wait while %1 loads your session"), PROGRAM_NAME));
 
        try {
@@ -3658,8 +3655,6 @@ ARDOUR_UI::load_session (const std::string& path, const std::string& snap_name,
 
        set_session (new_session);
 
-       session_loaded = true;
-
        if (_session) {
                _session->set_clean ();
        }
@@ -3703,7 +3698,6 @@ ARDOUR_UI::build_session (const std::string& path, const std::string& snap_name,
        Session *new_session;
        int x;
 
-       session_loaded = false;
        x = unload_session ();
 
        if (x < 0) {
@@ -3768,8 +3762,6 @@ ARDOUR_UI::build_session (const std::string& path, const std::string& snap_name,
 
        set_session (new_session);
 
-       session_loaded = true;
-
        new_session->save_state(new_session->name());
 
        return 0;
index d570dc79bb2d3abef156da56e60b4b78aa226a93..62a81a6a00ab0e493104c1f2556282af8934f928 100644 (file)
@@ -195,7 +195,6 @@ public:
        void finish();
 
        int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
-       bool session_loaded;
        bool session_load_in_progress;
        int build_session (const std::string& path, const std::string& snapshot, ARDOUR::BusProfile*);
        bool session_is_new() const { return _session_is_new; }
index ed0319b614c13dd5230bf60199a7707a5ac1f8b9..7a8366517e6165ec7f2829b47eb7fdedb9c31849 100644 (file)
@@ -337,10 +337,9 @@ ARDOUR_UI::unload_session (bool hide_stuff)
 
        blink_connection.disconnect ();
 
-       delete _session;
+       ARDOUR::Session* session_to_delete = _session;
        _session = 0;
-
-       session_loaded = false;
+       delete session_to_delete;
 
        update_title ();
 
index ef301370c6aeb6acb4ce35044dfaf070be8225c1..b0b58d6c7f18efd676f7770a84bd8d5d4c6656ac 100644 (file)
@@ -983,7 +983,7 @@ Editor::set_entered_track (TimeAxisView* tav)
 void
 Editor::instant_save ()
 {
-       if (!constructed || !ARDOUR_UI::instance()->session_loaded || no_save_instant) {
+       if (!constructed || no_save_instant) {
                return;
        }
 
index 489e52fac62153e0fecec629a8f1394039567f9d..6959d23d66d4f110699a383971af3b6e073cc2d2 100644 (file)
@@ -666,7 +666,7 @@ SessionDialog::setup_new_session_page ()
        //determine the text in the new folder selector
        if (!ARDOUR_COMMAND_LINE::session_name.empty()) {
                new_folder_chooser.set_current_folder (poor_mans_glob (Glib::path_get_dirname (ARDOUR_COMMAND_LINE::session_name)));
-       } else if (ARDOUR_UI::instance()->session_loaded) {
+       } else if (ARDOUR_UI::instance()->the_session ()) {
                // point the new session file chooser at the parent directory of the current session
                string session_parent_dir = Glib::path_get_dirname(ARDOUR_UI::instance()->the_session()->path());
                new_folder_chooser.set_current_folder (session_parent_dir);