From: Soeren Apel Date: Wed, 12 Feb 2020 08:17:02 +0000 (+0100) Subject: DecodeTrace: Perform delayed row initialization once the owner is set X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=a653b83dba6862ddf273c4ca52da6d9451a3dd53;p=pulseview.git DecodeTrace: Perform delayed row initialization once the owner is set --- diff --git a/pv/views/trace/decodetrace.cpp b/pv/views/trace/decodetrace.cpp index f4b9f335..06db5055 100644 --- a/pv/views/trace/decodetrace.cpp +++ b/pv/views/trace/decodetrace.cpp @@ -242,6 +242,17 @@ shared_ptr DecodeTrace::base() const return base_; } +void DecodeTrace::set_owner(TraceTreeItemOwner *owner) +{ + Trace::set_owner(owner); + + // The owner is set in trace::View::signals_changed(), which is a slot. + // So after this trace was added to the view, we won't have an owner + // that we need to initialize in update_rows(). Once we do, we call it + // from on_decode_reset(). + on_decode_reset(); +} + pair DecodeTrace::v_extents() const { // Make an empty decode trace appear symmetrical @@ -1378,6 +1389,9 @@ void DecodeTrace::initialize_row_widgets(DecodeTraceRow* r, unsigned int row_id) void DecodeTrace::update_rows() { + if (!owner_) + return; + lock_guard lock(row_modification_mutex_); for (DecodeTraceRow& r : rows_) diff --git a/pv/views/trace/decodetrace.hpp b/pv/views/trace/decodetrace.hpp index 215ae0ae..839b4df9 100644 --- a/pv/views/trace/decodetrace.hpp +++ b/pv/views/trace/decodetrace.hpp @@ -149,6 +149,12 @@ public: shared_ptr base() const; + /** + * Sets the owner this trace in the view trace hierachy. + * @param The new owner of the trace. + */ + virtual void set_owner(TraceTreeItemOwner *owner); + /** * Computes the vertical extents of the contents of this row item. * @return A pair containing the minimum and maximum y-values. diff --git a/pv/views/trace/tracetreeitem.hpp b/pv/views/trace/tracetreeitem.hpp index 932e2b8c..51e2ba42 100644 --- a/pv/views/trace/tracetreeitem.hpp +++ b/pv/views/trace/tracetreeitem.hpp @@ -94,7 +94,7 @@ public: * Sets the owner this trace in the view trace hierachy. * @param The new owner of the trace. */ - void set_owner(TraceTreeItemOwner *owner); + virtual void set_owner(TraceTreeItemOwner *owner); /** * Gets the visual y-offset of the axis.