]> sigrok.org Git - pulseview.git/commitdiff
Fix segfault and use bin class description
authorSoeren Apel <redacted>
Thu, 12 Dec 2019 21:33:03 +0000 (22:33 +0100)
committerSoeren Apel <redacted>
Thu, 12 Dec 2019 21:33:03 +0000 (22:33 +0100)
pv/data/decodesignal.cpp
pv/views/decoder_output/QHexView.cpp
pv/views/decoder_output/QHexView.hpp
pv/views/decoder_output/view.cpp

index ad5a27a9f254f6c041dcd2d75e8eda252382dbf3..33861ea55408d482ceb138c318545cdad5723497 100644 (file)
@@ -1426,7 +1426,7 @@ void DecodeSignal::binary_callback(srd_proto_data *pdata, void *decode_signal)
 
        DecodeBinaryClass* bin_class = nullptr;
        for (DecodeBinaryClass& bc : segment->binary_classes)
-               if ((bc.decoder->decoder() == decc) && (bc.info->bin_class_id == pdb->bin_class))
+               if ((bc.decoder->decoder() == decc) && (bc.info->bin_class_id == (uint32_t)pdb->bin_class))
                        bin_class = &bc;
 
        if (!bin_class) {
index 051e0b1f350f1044649aee98fff0bd11e9413fd6..2c99ba97e99ae3f58cec314605e0874957735064 100644 (file)
@@ -122,6 +122,7 @@ void QHexView::initialize_byte_iterator(size_t offset)
 {
        current_chunk_id_ = 0;
        current_chunk_offset_ = 0;
+       current_offset_ = offset;
 
        for (const DecodeBinaryDataChunk& chunk : data_->chunks)
                if (offset >= chunk.data.size()) {
@@ -142,7 +143,9 @@ uint8_t QHexView::get_next_byte(bool* is_next_chunk)
 
        uint8_t v = current_chunk_->data[current_chunk_offset_];
 
+       current_offset_++;
        current_chunk_offset_++;
+
        if (current_chunk_offset_ == current_chunk_->data.size()) {
                current_chunk_id_++;
                current_chunk_offset_ = 0;
@@ -237,7 +240,7 @@ void QHexView::paintEvent(QPaintEvent *event)
        for (size_t lineIdx = firstLineIdx, y = yStart; lineIdx < lastLineIdx; lineIdx++) {
 
                int x = posHex_;
-               for (size_t i = 0; i < BYTES_PER_LINE && ((lineIdx - firstLineIdx) * BYTES_PER_LINE + i) < data_size_; i++) {
+               for (size_t i = 0; (i < BYTES_PER_LINE) && (current_offset_ < data_size_); i++) {
                        size_t pos = (lineIdx * BYTES_PER_LINE + i) * 2;
 
                        // Fetch byte
@@ -283,7 +286,7 @@ void QHexView::paintEvent(QPaintEvent *event)
        for (size_t lineIdx = firstLineIdx, y = yStart; lineIdx < lastLineIdx; lineIdx++) {
 
                int x = posAscii_;
-               for (size_t i = 0; ((lineIdx - firstLineIdx) * BYTES_PER_LINE + i) < data_size_ && (i < BYTES_PER_LINE); i++) {
+               for (size_t i = 0; (i < BYTES_PER_LINE) && (current_offset_ < data_size_); i++) {
                        // Fetch byte
                        uint8_t ch = get_next_byte();
 
index 74b9da566fe9e7dd78eb99755109f36b72ff6659..fca3c7efa798a4e95f8f9c388464516a0bcd142a 100644 (file)
@@ -84,7 +84,7 @@ private:
        size_t charWidth_, charHeight_;
        size_t selectBegin_, selectEnd_, selectInit_, cursorPos_;
 
-       size_t current_chunk_id_, current_chunk_offset_;
+       size_t current_chunk_id_, current_chunk_offset_, current_offset_;
        const DecodeBinaryDataChunk* current_chunk_;
 
        vector<QColor> chunk_colors_;
index d8bbb03a0cbf8fb6fda68252bae79852bbc0f4f0..2476d7ceae153c09ce1a6964d4239b87d768eeb2 100644 (file)
@@ -226,7 +226,7 @@ void View::on_selected_decoder_changed(int index)
                uint32_t bin_classes = decoder_->get_binary_class_count();
                for (uint32_t i = 0; i < bin_classes; i++) {
                        const data::decode::DecodeBinaryClassInfo* class_info = decoder_->get_binary_class(i);
-                       class_selector_->addItem(class_info->name, QVariant::fromValue(i));
+                       class_selector_->addItem(class_info->description, QVariant::fromValue(i));
                }
 
                connect(signal_, SIGNAL(new_binary_data(unsigned int, void*, unsigned int)),