forked from Ivasoft/DSView
fix: search the decoded data crashed sometimes
This commit is contained in:
@@ -138,12 +138,14 @@ bool RowData::push_annotation(Annotation *a)
|
||||
}
|
||||
|
||||
|
||||
bool RowData::get_annotation(Annotation &ann, uint64_t index)
|
||||
bool RowData::get_annotation(Annotation *ann, uint64_t index)
|
||||
{
|
||||
assert(ann);
|
||||
|
||||
std::lock_guard<std::mutex> lock(_global_visitor_mutex);
|
||||
|
||||
if (index < _annotations.size()) {
|
||||
ann = *_annotations[index];
|
||||
*ann = *_annotations[index]; //clone
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
return _item_count;
|
||||
}
|
||||
|
||||
bool get_annotation(pv::data::decode::Annotation &ann, uint64_t index);
|
||||
bool get_annotation(pv::data::decode::Annotation *ann, uint64_t index);
|
||||
|
||||
/**
|
||||
* Extracts sorted annotations between two period into a vector.
|
||||
|
||||
@@ -67,10 +67,11 @@ QVariant DecoderModel::data(const QModelIndex &index, int role) const
|
||||
|
||||
if (role == Qt::TextAlignmentRole) {
|
||||
return int(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
} else if (role == Qt::DisplayRole) {
|
||||
}
|
||||
else if (role == Qt::DisplayRole) {
|
||||
if (_decoder_stack) {
|
||||
pv::data::decode::Annotation ann;
|
||||
if (_decoder_stack->list_annotation(ann, index.column(), index.row())) {
|
||||
if (_decoder_stack->list_annotation(&ann, index.column(), index.row())) {
|
||||
return ann.annotations().at(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ uint64_t DecoderStack::list_annotation_size(uint16_t row_index)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool DecoderStack::list_annotation(pv::data::decode::Annotation &ann,
|
||||
bool DecoderStack::list_annotation(pv::data::decode::Annotation *ann,
|
||||
uint16_t row_index, uint64_t col_index)
|
||||
{
|
||||
for (auto i = _rows.begin(); i != _rows.end(); i++) {
|
||||
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
uint64_t list_annotation_size(uint16_t row_index);
|
||||
|
||||
|
||||
bool list_annotation(decode::Annotation &ann,
|
||||
bool list_annotation(decode::Annotation *ann,
|
||||
uint16_t row_index, uint64_t col_index);
|
||||
|
||||
|
||||
|
||||
@@ -546,9 +546,10 @@ void ProtocolDock::item_clicked(const QModelIndex &index)
|
||||
pv::data::DecoderModel *decoder_model = _session->get_decoder_model();
|
||||
|
||||
auto decoder_stack = decoder_model->getDecoderStack();
|
||||
|
||||
if (decoder_stack) {
|
||||
pv::data::decode::Annotation ann;
|
||||
if (decoder_stack->list_annotation(ann, index.column(), index.row())) {
|
||||
if (decoder_stack->list_annotation(&ann, index.column(), index.row())) {
|
||||
const auto &decode_sigs = _session->get_decode_signals();
|
||||
|
||||
for(auto d : decode_sigs) {
|
||||
@@ -559,6 +560,7 @@ void ProtocolDock::item_clicked(const QModelIndex &index)
|
||||
_session->show_region(ann.start_sample(), ann.end_sample(), false);
|
||||
}
|
||||
}
|
||||
|
||||
_table_view->resizeRowToContents(index.row());
|
||||
if (index.column() != _model_proxy.filterKeyColumn()) {
|
||||
_model_proxy.setFilterKeyColumn(index.column());
|
||||
@@ -638,20 +640,26 @@ void ProtocolDock::nav_table_view()
|
||||
}
|
||||
}
|
||||
QModelIndex index = _model_proxy.mapToSource(_model_proxy.index(row_index, _model_proxy.filterKeyColumn()));
|
||||
if(index.isValid()){
|
||||
_table_view->scrollTo(index);
|
||||
_table_view->setCurrentIndex(index);
|
||||
|
||||
if(index.isValid()){
|
||||
|
||||
pv::data::decode::Annotation ann;
|
||||
decoder_stack->list_annotation(ann, index.column(), index.row());
|
||||
const auto &decode_sigs = _session->get_decode_signals();
|
||||
|
||||
for(auto d : decode_sigs) {
|
||||
d->decoder()->set_mark_index(-1);
|
||||
}
|
||||
decoder_stack->set_mark_index((ann.start_sample()+ann.end_sample())/2);
|
||||
_view.set_all_update(true);
|
||||
_view.update();
|
||||
if (decoder_stack->list_annotation(&ann, index.column(), index.row()))
|
||||
{
|
||||
_table_view->scrollTo(index);
|
||||
_table_view->setCurrentIndex(index);
|
||||
|
||||
const auto &decode_sigs = _session->get_decode_signals();
|
||||
|
||||
for(auto d : decode_sigs) {
|
||||
d->decoder()->set_mark_index(-1);
|
||||
}
|
||||
|
||||
decoder_stack->set_mark_index((ann.start_sample()+ann.end_sample())/2);
|
||||
_view.set_all_update(true);
|
||||
_view.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -686,22 +694,30 @@ void ProtocolDock::search_pre()
|
||||
uint64_t row = matchingIndex.row() + 1;
|
||||
uint64_t col = matchingIndex.column();
|
||||
pv::data::decode::Annotation ann;
|
||||
bool ann_valid;
|
||||
bool ann_valid = false;
|
||||
|
||||
while(i < _str_list.size()) {
|
||||
QString nxt = _str_list.at(i);
|
||||
|
||||
do {
|
||||
ann_valid = decoder_stack->list_annotation(ann, col, row);
|
||||
ann_valid = decoder_stack->list_annotation(&ann, col, row);
|
||||
row++;
|
||||
}while(ann_valid && !ann.is_numberic());
|
||||
}
|
||||
while(ann_valid && !ann.is_numberic());
|
||||
|
||||
QString source = ann.annotations().at(0);
|
||||
if (ann_valid && source.contains(nxt))
|
||||
i++;
|
||||
else
|
||||
if (ann_valid){
|
||||
QString source = ann.annotations().at(0);
|
||||
if (source.contains(nxt))
|
||||
i++;
|
||||
else
|
||||
break;
|
||||
}
|
||||
else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}while(i < _str_list.size() && --rowCount);
|
||||
}
|
||||
while(i < _str_list.size() && --rowCount);
|
||||
|
||||
if(i >= _str_list.size() && matchingIndex.isValid()){
|
||||
_table_view->scrollTo(matchingIndex);
|
||||
@@ -753,22 +769,27 @@ void ProtocolDock::search_nxt()
|
||||
uint64_t row = matchingIndex.row() + 1;
|
||||
uint64_t col = matchingIndex.column();
|
||||
pv::data::decode::Annotation ann;
|
||||
bool ann_valid;
|
||||
bool ann_valid = false;
|
||||
|
||||
while(i < _str_list.size()) {
|
||||
QString nxt = _str_list.at(i);
|
||||
|
||||
do {
|
||||
ann_valid = decoder_stack->list_annotation(ann, col, row);
|
||||
ann_valid = decoder_stack->list_annotation(&ann, col, row);
|
||||
row++;
|
||||
}while(ann_valid && !ann.is_numberic());
|
||||
}
|
||||
while(ann_valid && !ann.is_numberic());
|
||||
|
||||
auto strlist = ann.annotations();
|
||||
QString source = ann.annotations().at(0);
|
||||
if (ann_valid && source.contains(nxt))
|
||||
i++;
|
||||
else
|
||||
if (ann_valid){
|
||||
QString source = ann.annotations().at(0);
|
||||
if (source.contains(nxt))
|
||||
i++;
|
||||
else
|
||||
break;
|
||||
}
|
||||
else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}while(i < _str_list.size() && --rowCount);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user