From: Soeren Apel Date: Thu, 12 Dec 2019 22:18:23 +0000 (+0100) Subject: DecodeOutputView: Use delayed view updater and cache current chunk X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=516d21289dafa7ce9b5352454a0eda31999c5efc;p=pulseview.git DecodeOutputView: Use delayed view updater and cache current chunk --- diff --git a/pv/views/decoder_output/QHexView.cpp b/pv/views/decoder_output/QHexView.cpp index 2c99ba97..ef57fd4c 100644 --- a/pv/views/decoder_output/QHexView.cpp +++ b/pv/views/decoder_output/QHexView.cpp @@ -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; diff --git a/pv/views/decoder_output/QHexView.hpp b/pv/views/decoder_output/QHexView.hpp index fca3c7ef..37b7e4e4 100644 --- a/pv/views/decoder_output/QHexView.hpp +++ b/pv/views/decoder_output/QHexView.hpp @@ -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 chunk_colors_; }; diff --git a/pv/views/decoder_output/view.cpp b/pv/views/decoder_output/view.cpp index 2476d7ce..1f712da9 100644 --- a/pv/views/decoder_output/view.cpp +++ b/pv/views/decoder_output/view.cpp @@ -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 diff --git a/pv/views/decoder_output/view.hpp b/pv/views/decoder_output/view.hpp index 23023efb..7644f82a 100644 --- a/pv/views/decoder_output/view.hpp +++ b/pv/views/decoder_output/view.hpp @@ -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_;