From 390c74457ea9824d1fb579f60145d500884338fb Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 1 May 2014 12:27:26 -0400 Subject: [PATCH] fix crash in butler when destroying before thread is started --- libs/ardour/ardour/butler.h | 1 + libs/ardour/butler.cc | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libs/ardour/ardour/butler.h b/libs/ardour/ardour/butler.h index efdaad1621..949668dab3 100644 --- a/libs/ardour/ardour/butler.h +++ b/libs/ardour/ardour/butler.h @@ -76,6 +76,7 @@ class LIBARDOUR_API Butler : public SessionHandleRef }; pthread_t thread; + bool have_thread; Glib::Threads::Mutex request_lock; Glib::Threads::Cond paused; bool should_run; diff --git a/libs/ardour/butler.cc b/libs/ardour/butler.cc index c9eb55a472..327665441e 100644 --- a/libs/ardour/butler.cc +++ b/libs/ardour/butler.cc @@ -43,6 +43,7 @@ namespace ARDOUR { Butler::Butler(Session& s) : SessionHandleRef (s) , thread() + , have_thread (false) , audio_dstream_capture_buffer_size(0) , audio_dstream_playback_buffer_size(0) , midi_dstream_buffer_size(0) @@ -126,16 +127,18 @@ Butler::start_thread() } //pthread_detach (thread); - + have_thread = true; return 0; } void Butler::terminate_thread () { - void* status; - queue_request (Request::Quit); - pthread_join (thread, &status); + if (have_thread) { + void* status; + queue_request (Request::Quit); + pthread_join (thread, &status); + } } void *