assert(index < (int)stack_.size());
// Find the decoder in the stack
- auto iter = stack_.begin();
- for (int i = 0; i < index; i++, iter++)
- assert(iter != stack_.end());
+ auto iter = stack_.begin() + index;
+ assert(iter != stack_.end());
+
+ shared_ptr<Decoder> dec = *iter;
- decoder_removed(iter->get());
+ decoder_removed(dec.get());
// Delete the element
stack_.erase(iter);
shared_ptr<sigrok::Context> Session::sr_context;
Session::Session(DeviceManager &device_manager, QString name) :
+ shutting_down_(false),
device_manager_(device_manager),
default_name_(name),
name_(name),
Session::~Session()
{
+ shutting_down_ = true;
+
// Stop and join to the thread
stop_capture();
}
void Session::remove_generated_signal(shared_ptr<data::SignalBase> signal)
{
+ if (shutting_down_)
+ return;
+
signalbases_.erase(std::remove_if(signalbases_.begin(), signalbases_.end(),
[&](shared_ptr<data::SignalBase> s) { return s == signal; }),
signalbases_.end());
void Session::remove_decode_signal(shared_ptr<data::DecodeSignal> signal)
{
+ if (shutting_down_)
+ return;
+
signalbases_.erase(std::remove_if(signalbases_.begin(), signalbases_.end(),
[&](shared_ptr<data::SignalBase> s) { return s == signal; }),
signalbases_.end());
#endif
private:
+ bool shutting_down_;
+
DeviceManager &device_manager_;
shared_ptr<devices::Device> device_;
QString default_name_, name_;
void View::remove_signalbase(const shared_ptr<data::SignalBase> signalbase)
{
ViewBase::remove_signalbase(signalbase);
+
+ shared_ptr<Signal> signal = get_signal_by_signalbase(signalbase);
+
+ if (signal)
+ remove_trace(signal);
}
#ifdef ENABLE_DECODE
for (auto i = decode_traces_.begin(); i != decode_traces_.end(); i++)
if ((*i)->base() == signal) {
decode_traces_.erase(i);
- signals_changed();
- return;
+ break;
}
ViewBase::remove_decode_signal(signal);
}
#endif
+void View::remove_trace(shared_ptr<Trace> trace)
+{
+ TraceTreeItemOwner *const owner = trace->owner();
+ assert(owner);
+ owner->remove_child_item(trace);
+
+ for (auto i = signals_.begin(); i != signals_.end(); i++)
+ if ((*i) == trace) {
+ signals_.erase(i);
+ break;
+ }
+
+ if (!header_was_shrunk_)
+ resize_header_to_fit();
+
+ update_layout();
+
+ header_->update();
+ viewport_->update();
+}
+
shared_ptr<Signal> View::get_signal_under_mouse_cursor() const
{
return signal_under_mouse_cursor_;
#ifdef ENABLE_DECODE
traces.insert(decode_traces_.begin(), decode_traces_.end());
#endif
-
set< shared_ptr<Trace> > add_traces;
set_difference(traces.begin(), traces.end(),
prev_traces.begin(), prev_traces.end(),
// Add and position the pending top levels items
int offset = v_extents().second;
for (shared_ptr<TraceTreeItem> item : new_top_level_items) {
+ // items may already have gained an owner when they were added to a group above
+ if (item->owner())
+ continue;
+
add_child_item(item);
// Position the item after the last item or at the top if there is none
virtual void remove_decode_signal(shared_ptr<data::DecodeSignal> signal);
#endif
+ void remove_trace(shared_ptr<Trace> trace);
+
shared_ptr<Signal> get_signal_under_mouse_cursor() const;
/**