]> sigrok.org Git - pulseview.git/commitdiff
DecodeTrace: Perform delayed row initialization once the owner is set
authorSoeren Apel <redacted>
Wed, 12 Feb 2020 08:17:02 +0000 (09:17 +0100)
committerSoeren Apel <redacted>
Wed, 12 Feb 2020 08:17:02 +0000 (09:17 +0100)
pv/views/trace/decodetrace.cpp
pv/views/trace/decodetrace.hpp
pv/views/trace/tracetreeitem.hpp

index f4b9f3359ccbf35f41b845fb95842141c0e73afe..06db505596f0331932fca77d51e23c74323106db 100644 (file)
@@ -242,6 +242,17 @@ shared_ptr<data::SignalBase> 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<int, int> 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<mutex> lock(row_modification_mutex_);
 
        for (DecodeTraceRow& r : rows_)
index 215ae0ae95b52d58af1ac1f4a4026491ddcbea27..839b4df9f6863eb406f0a48de88d6925cf279dfe 100644 (file)
@@ -149,6 +149,12 @@ public:
 
        shared_ptr<SignalBase> 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.
index 932e2b8c932285b0967993e2b5564569df6c5026..51e2ba42914741178f245d6b0c4a947b9c3e0b4a 100644 (file)
@@ -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.