Session: Improve signal handling during device selection
[pulseview.git] / pv / session.cpp
index c885d37aaeea5edf3cd385712b227b95d55df105..e2b6dd7174a0bcdfcadef6ab0041454ab4a2a8c0 100644 (file)
@@ -138,6 +138,13 @@ void Session::set_device(shared_ptr<devices::Device> device)
        if (device_)
                device_->close();
 
+       device_.reset();
+
+       // Remove all traces
+       signals_.clear();
+       decode_traces_.clear();
+       signals_changed();
+
        device_ = std::move(device);
        device_->open();
        device_->session()->add_datafeed_callback([=]
@@ -145,8 +152,6 @@ void Session::set_device(shared_ptr<devices::Device> device)
                        data_feed_in(device, packet);
                });
 
-       decode_traces_.clear();
-
        update_signals();
        device_selected();
 }
@@ -581,7 +586,7 @@ void Session::feed_in_analog(shared_ptr<Analog> analog)
                if (iter != cur_analog_segments_.end())
                        segment = (*iter).second;
                else {
-                       // If no segment was found, this means we havn't
+                       // If no segment was found, this means we haven't
                        // created one yet. i.e. this is the first packet
                        // in the sweep containing this segment.
                        sweep_beginning = true;