]> sigrok.org Git - pulseview.git/commitdiff
HexView: Don't send out an extra byte when exporting all data
authorSoeren Apel <redacted>
Tue, 14 Jan 2020 18:04:34 +0000 (19:04 +0100)
committerSoeren Apel <redacted>
Sat, 18 Jan 2020 22:01:54 +0000 (23:01 +0100)
pv/views/decoder_output/QHexView.cpp
pv/views/decoder_output/view.cpp

index 0104de1590930f63f3773cd31ca5ab11e63c02ec..59fe779f57640dd77339e88582af1711560be7b4 100644 (file)
@@ -142,7 +142,7 @@ pair<size_t, size_t> QHexView::get_selection() const
                // Nothing is currently selected
                start = 0;
                end = data_size_;
-       } else
+       } if (end < data_size_)
                end++;
 
        return std::make_pair(start, end);
index 9e69622de959dfa98e5204f3c3d93bc6f0a0c968..0f127c8751d72340530f0a940a407c255f725115 100644 (file)
@@ -265,6 +265,8 @@ void View::save_data() const
                pair<size_t, size_t> selection = hex_view_->get_selection();
 
                vector<uint8_t> data;
+               data.resize(selection.second - selection.first + 1);
+
                signal_->get_merged_binary_data_chunks_by_offset(current_segment_, decoder_,
                        bin_class_id_, selection.first, selection.second, &data);
 
@@ -303,6 +305,8 @@ void View::save_data_as_hex_dump(bool with_offset, bool with_ascii) const
                pair<size_t, size_t> selection = hex_view_->get_selection();
 
                vector<uint8_t> data;
+               data.resize(selection.second - selection.first + 1);
+
                signal_->get_merged_binary_data_chunks_by_offset(current_segment_, decoder_,
                        bin_class_id_, selection.first, selection.second, &data);