From ef4bbae02e194e9f254b7d31918b25aadc46c1ae Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 1 Jun 2022 16:26:51 +0200 Subject: [PATCH] Fix logic in nth_mixer_scene (amend 00bd313e6e03) _mixer_scenes[nth] may not exist, size check condition needs to happen first. Writer lock is only required when changing the vector. --- libs/ardour/session.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 512a3499b1..feb6dd246e 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -7525,7 +7525,10 @@ boost::shared_ptr Session::nth_mixer_scene (size_t nth, bool create_if_missing) { Glib::Threads::RWLock::ReaderLock lm (_mixer_scenes_lock); - if (create_if_missing && (!_mixer_scenes[nth] || _mixer_scenes.size() <= nth) ) { + if (create_if_missing) { + if (_mixer_scenes.size() > nth && _mixer_scenes[nth]) { + return _mixer_scenes[nth]; + } lm.release (); Glib::Threads::RWLock::WriterLock lw (_mixer_scenes_lock); if (_mixer_scenes.size() <= nth) {