From 00fc7b1fa29fcf17c0b9e2c79c648403a88e1664 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Fri, 18 May 2007 02:41:10 +0000 Subject: [PATCH] Use bool return type for ARDOUR_UI::unload_session to indicate success/failure. git-svn-id: svn://localhost/ardour2/trunk@1860 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour_ui.cc | 18 ++---------------- gtk2_ardour/ardour_ui.h | 4 +++- gtk2_ardour/ardour_ui_dialogs.cc | 7 ++++--- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 6e0b1ce4f6..91978886f8 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -2033,20 +2033,13 @@ int ARDOUR_UI::load_session (const string & path, const string & snap_name, string* mix_template) { Session *new_session; - int x; session_loaded = false; if (!check_audioengine()) { return -1; } - x = unload_session (); - - if (x < 0) { - return -1; - } else if (x > 0) { - return 0; - } + if(!unload_session ()) return -1; /* if it already exists, we must have write access */ @@ -2094,7 +2087,6 @@ ARDOUR_UI::build_session (const string & path, const string & snap_name, nframes_t initial_length) { Session *new_session; - int x; if (!check_audioengine()) { return -1; @@ -2102,13 +2094,7 @@ ARDOUR_UI::build_session (const string & path, const string & snap_name, session_loaded = false; - x = unload_session (); - - if (x < 0) { - return -1; - } else if (x > 0) { - return 0; - } + if (!unload_session ()) return -1; _session_is_new = true; diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index ead335be6b..8e8753c87b 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -129,7 +129,9 @@ class ARDOUR_UI : public Gtkmm2ext::UI bool new_session(std::string path = string()); gint cmdline_new_session (string path); - int unload_session (); + + /// @return true if session was successfully unloaded. + bool unload_session (); void close_session(); int save_state_canfail (string state_name = ""); diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc index 8a50697e85..ff2a506558 100644 --- a/gtk2_ardour/ardour_ui_dialogs.cc +++ b/gtk2_ardour/ardour_ui_dialogs.cc @@ -162,13 +162,14 @@ ARDOUR_UI::connect_to_session (Session *s) point_zero_one_second_connection = Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::every_point_zero_one_seconds), 40); } -int +bool ARDOUR_UI::unload_session () { if (session && session->dirty()) { switch (ask_about_saving_session (_("close"))) { case -1: - return 1; + // cancel + return false; case 1: session->save_state (""); @@ -212,7 +213,7 @@ ARDOUR_UI::unload_session () update_buffer_load (); - return 0; + return true; } int