From 6d4d4ccc78ee94cd92f168b880a94d3265c1f13d Mon Sep 17 00:00:00 2001 From: Johannes Mueller Date: Wed, 17 Apr 2019 13:44:02 +0200 Subject: [PATCH] Fix crash when destroying session while control protocol is selected in preferences The GUI should be notified about the tearing down of the control surfaces *before* the protocols are actually destroyed. On ProtocolStatusChange ControlSurfacesOptions::selection_changed() might try to access protocol->has_editor() of a protocol that happens to be selected in the preferences GUI. I this protocol already has been destroyed, a crash will occur. --- libs/ardour/control_protocol_manager.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libs/ardour/control_protocol_manager.cc b/libs/ardour/control_protocol_manager.cc index 048ff3f7d5..88571e598f 100644 --- a/libs/ardour/control_protocol_manager.cc +++ b/libs/ardour/control_protocol_manager.cc @@ -181,12 +181,6 @@ ControlProtocolManager::drop_protocols () Glib::Threads::RWLock::WriterLock lm (protocols_lock); - for (list::iterator p = control_protocols.begin(); p != control_protocols.end(); ++p) { - delete *p; - } - - control_protocols.clear (); - for (list::iterator p = control_protocol_info.begin(); p != control_protocol_info.end(); ++p) { // mark existing protocols as requested // otherwise the ControlProtocol instances are not recreated in set_session @@ -196,6 +190,12 @@ ControlProtocolManager::drop_protocols () ProtocolStatusChange (*p); /* EMIT SIGNAL */ } } + + for (list::iterator p = control_protocols.begin(); p != control_protocols.end(); ++p) { + delete *p; + } + + control_protocols.clear (); } ControlProtocol*