Fix crash when rapidly switching snapshots

ARDOUR_UI::load_session() calls flush_pending() which runs
gtk_main_iteration()s until idle.

If a user selects another snapshot from the sidebar, load_session()
is called again (from a call to load session)
This commit is contained in:
Robin Gareus 2017-07-01 03:10:50 +02:00
parent d421e56fc0
commit 2b1b0aa240
3 changed files with 17 additions and 0 deletions

View File

@ -62,6 +62,7 @@
#include "pbd/openuri.h"
#include "pbd/stl_delete.h"
#include "pbd/types_convert.h"
#include "pbd/unwind.h"
#include "pbd/file_utils.h"
#include "pbd/localtime_r.h"
#include "pbd/pthread_utils.h"
@ -263,6 +264,7 @@ 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 ))
, secondary_clock (new MainClock (X_("secondary"), X_("secondary"), false))
@ -3614,6 +3616,18 @@ ARDOUR_UI::close_session()
int
ARDOUR_UI::load_session (const std::string& path, const std::string& snap_name, std::string mix_template)
{
/* load_session calls flush_pending() which allows
* GUI interaction and potentially loading another session
* (that was easy via snapshot sidebar).
* Recursing into load_session() from load_session() and recusive
* event loops causes all kind of crashes.
*/
assert (!session_load_in_progress);
if (session_load_in_progress) {
return -1;
}
PBD::Unwinder<bool> lsu (session_load_in_progress, true);
Session *new_session;
int unload_status;
int retval = -1;

View File

@ -188,6 +188,7 @@ public:
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; }

View File

@ -89,7 +89,9 @@ EditorSnapshots::selection_changed ()
return;
}
_display.set_sensitive (false);
ARDOUR_UI::instance()->load_session (_session->path(), string (snap_name));
_display.set_sensitive (true);
}
}