]> sigrok.org Git - pulseview.git/commitdiff
DecodeOutputView: Use delayed view updater and cache current chunk
authorSoeren Apel <redacted>
Thu, 12 Dec 2019 22:18:23 +0000 (23:18 +0100)
committerSoeren Apel <redacted>
Thu, 12 Dec 2019 22:18:23 +0000 (23:18 +0100)
pv/views/decoder_output/QHexView.cpp
pv/views/decoder_output/QHexView.hpp
pv/views/decoder_output/view.cpp
pv/views/decoder_output/view.hpp

index 2c99ba97e99ae3f58cec314605e0874957735064..ef57fd4c700a31974734568779baadda279bf1b5 100644 (file)
@@ -133,7 +133,7 @@ void QHexView::initialize_byte_iterator(size_t offset)
                        break;
                }
 
-       current_chunk_ = &(data_->chunks[current_chunk_id_]);
+       current_chunk_ = data_->chunks[current_chunk_id_];
 }
 
 uint8_t QHexView::get_next_byte(bool* is_next_chunk)
@@ -141,15 +141,15 @@ uint8_t QHexView::get_next_byte(bool* is_next_chunk)
        if (is_next_chunk != nullptr)
                *is_next_chunk = (current_chunk_offset_ == 0);
 
-       uint8_t v = current_chunk_->data[current_chunk_offset_];
+       uint8_t v = current_chunk_.data[current_chunk_offset_];
 
        current_offset_++;
        current_chunk_offset_++;
 
-       if (current_chunk_offset_ == current_chunk_->data.size()) {
+       if (current_chunk_offset_ == current_chunk_.data.size()) {
                current_chunk_id_++;
                current_chunk_offset_ = 0;
-               current_chunk_ = &(data_->chunks[current_chunk_id_]);
+               current_chunk_ = data_->chunks[current_chunk_id_];
        }
 
        return v;
index fca3c7efa798a4e95f8f9c388464516a0bcd142a..37b7e4e4d7394320570fb653bbd0df078f5fe241 100644 (file)
@@ -85,7 +85,7 @@ private:
        size_t selectBegin_, selectEnd_, selectInit_, cursorPos_;
 
        size_t current_chunk_id_, current_chunk_offset_, current_offset_;
-       const DecodeBinaryDataChunk* current_chunk_;
+       DecodeBinaryDataChunk current_chunk_; // Cache locally so that we're not messed up when the vector is re-allocating its data
 
        vector<QColor> chunk_colors_;
 };
index 2476d7ceae153c09ce1a6964d4239b87d768eeb2..1f712da9be8eaf1d24d2c880e7add0c81a52944e 100644 (file)
@@ -276,7 +276,8 @@ void View::on_signal_name_changed(const QString &name)
 void View::on_new_binary_data(unsigned int segment_id, void* decoder, unsigned int bin_class_id)
 {
        if ((segment_id == current_segment_) && (decoder == decoder_) && (bin_class_id == bin_class_id_))
-               update_data();
+               if (!delayed_view_updater_.isActive())
+                       delayed_view_updater_.start();
 }
 
 void View::on_decoder_stacked(void* decoder)
@@ -315,6 +316,11 @@ void View::on_decoder_removed(void* decoder)
                decoder_selector_->removeItem(index);
 }
 
+void View::perform_delayed_view_update()
+{
+       update_data();
+}
+
 
 } // namespace decoder_output
 } // namespace views
index 23023efbe633d55bf3b326abcfc2af86a0f958d3..7644f82a6f5c0f8703be4b262d53e64ede1d3cfa 100644 (file)
@@ -74,6 +74,8 @@ private Q_SLOTS:
        void on_decoder_stacked(void* decoder);
        void on_decoder_removed(void* decoder);
 
+       virtual void perform_delayed_view_update();
+
 private:
        QComboBox *decoder_selector_, *format_selector_, *class_selector_;
        QStackedWidget *stacked_widget_;