Fix out-of-order issue of multiple annotation rows

This commit is contained in:
DreamSourceLab 2020-05-10 18:44:15 +08:00
parent 2236cace83
commit dbc943d714
3 changed files with 13 additions and 6 deletions

View File

@ -28,13 +28,15 @@ namespace decode {
Row::Row() :
_decoder(NULL),
_row(NULL)
_row(NULL),
_order(-1)
{
}
Row::Row(const srd_decoder *decoder, const srd_decoder_annotation_row *row) :
Row::Row(const srd_decoder *decoder, const srd_decoder_annotation_row *row, const int order) :
_decoder(decoder),
_row(row)
_row(row),
_order(order)
{
}
@ -69,7 +71,7 @@ const QString Row::title() const
bool Row::operator<(const Row &other) const
{
return (_decoder < other._decoder) ||
(_decoder == other._decoder && _row < other._row);
(_decoder == other._decoder && _order < other._order);
}
} // decode

View File

@ -39,7 +39,8 @@ public:
~Row();
Row(const srd_decoder *decoder,
const srd_decoder_annotation_row *row = NULL);
const srd_decoder_annotation_row *row = NULL,
const int order = -1);
const srd_decoder* decoder() const;
const srd_decoder_annotation_row* row() const;
@ -51,6 +52,7 @@ public:
private:
const srd_decoder *_decoder;
const srd_decoder_annotation_row *_row;
int _order;
};
} // decode

View File

@ -147,13 +147,14 @@ void DecoderStack::build_row()
}
// Add the decoder rows
int order = 0;
for (const GSList *l = decc->annotation_rows; l; l = l->next)
{
const srd_decoder_annotation_row *const ann_row =
(srd_decoder_annotation_row *)l->data;
assert(ann_row);
const Row row(decc, ann_row);
const Row row(decc, ann_row, order);
// Add a new empty row data object
_rows[row] = decode::RowData();
@ -173,6 +174,8 @@ void DecoderStack::build_row()
ll; ll = ll->next)
_class_rows[make_pair(decc,
GPOINTER_TO_INT(ll->data))] = row;
order++;
}
}
}