From: Joel Holdsworth Date: Mon, 2 Feb 2015 03:18:46 +0000 (-0700) Subject: Session: Simplified logic of set_device X-Git-Tag: pulseview-0.3.0~222 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=1dccc4ad96fd764c30b64502e3de570ff6cc04ba;p=pulseview.git Session: Simplified logic of set_device --- diff --git a/pv/session.cpp b/pv/session.cpp index 70637437..5f2bc8ea 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -123,30 +123,26 @@ void Session::set_device(shared_ptr device) // Ensure we are not capturing before setting the device stop_capture(); - // Are we setting a session device? - const auto session_device = - dynamic_pointer_cast(device); - - // Did we have a session device selected previously? - const auto prev_session_device = - dynamic_pointer_cast(device_); - if (device_) { session_->remove_datafeed_callbacks(); - if (!prev_session_device) { + + // Did we have a hardware device selected previously? + if (!dynamic_pointer_cast(device_)) { device_->close(); session_->remove_devices(); } } - if (session_device) - session_ = session_device->parent(); - decode_traces_.clear(); if (device) { - if (!session_device) - { + // Are we setting a session device? + const auto session_device = + dynamic_pointer_cast(device); + + if (session_device) + session_ = session_device->parent(); + else { session_ = device_manager_.context()->create_session(); try {