From 6d483b8b51b4efceacf2f48776af33550bf5d29e Mon Sep 17 00:00:00 2001 From: Marcus Comstedt Date: Sat, 22 Feb 2014 12:15:54 +0100 Subject: [PATCH] Don't join with non-threads. Fixes 323 --- pv/data/decoderstack.cpp | 12 ++++++++---- pv/sigsession.cpp | 6 ++++-- pv/storesession.cpp | 3 ++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/pv/data/decoderstack.cpp b/pv/data/decoderstack.cpp index 9b02f9e9..9707d8d2 100644 --- a/pv/data/decoderstack.cpp +++ b/pv/data/decoderstack.cpp @@ -67,8 +67,10 @@ DecoderStack::DecoderStack(const srd_decoder *const dec) : DecoderStack::~DecoderStack() { - _decode_thread.interrupt(); - _decode_thread.join(); + if (_decode_thread.joinable()) { + _decode_thread.interrupt(); + _decode_thread.join(); + } } const std::list< boost::shared_ptr >& @@ -168,8 +170,10 @@ void DecoderStack::begin_decode() shared_ptr logic_signal; shared_ptr data; - _decode_thread.interrupt(); - _decode_thread.join(); + if (_decode_thread.joinable()) { + _decode_thread.interrupt(); + _decode_thread.join(); + } clear(); diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index 10ea4ffb..b5387877 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -75,7 +75,8 @@ SigSession::~SigSession() { stop_capture(); - _sampling_thread.join(); + if (_sampling_thread.joinable()) + _sampling_thread.join(); if (_dev_inst) _device_manager.release_device(_dev_inst); @@ -200,7 +201,8 @@ void SigSession::stop_capture() sr_session_stop(); // Check that sampling stopped - _sampling_thread.join(); + if (_sampling_thread.joinable()) + _sampling_thread.join(); } set< shared_ptr > SigSession::get_data() const diff --git a/pv/storesession.cpp b/pv/storesession.cpp index ebb4b0ed..3d0f12fe 100644 --- a/pv/storesession.cpp +++ b/pv/storesession.cpp @@ -135,7 +135,8 @@ bool StoreSession::start() void StoreSession::wait() { - _thread.join(); + if (_thread.joinable()) + _thread.join(); } void StoreSession::cancel() -- 2.30.2