+void DecodeTrace::update_rows()
+{
+ lock_guard<mutex> lock(row_modification_mutex_);
+
+ QFontMetrics m(QApplication::font());
+
+ for (RowData& r : rows_)
+ r.exists = false;
+
+ for (const Row& decode_row : decode_signal_->get_rows()) {
+ // Find row in our list
+ auto r_it = find_if(rows_.begin(), rows_.end(),
+ [&](RowData& r){ return r.decode_row == decode_row; });
+
+ RowData* r = nullptr;
+ if (r_it == rows_.end()) {
+ // Row doesn't exist yet, create and append it
+ RowData nr;
+ nr.decode_row = decode_row;
+ nr.height = default_row_height_;
+ nr.currently_visible = false;
+ nr.expand_marker_highlighted = false;
+ nr.expanded = false;
+
+ rows_.push_back(nr);
+ r = &rows_.back();
+ } else
+ r = &(*r_it);
+
+ r->exists = true;
+
+ const int w = m.boundingRect(r->decode_row.title()).width() + RowTitleMargin;
+ r->title_width = w;
+ }
+
+ // Remove any rows that no longer exist, obeying that iterators are invalidated
+ bool any_exists;
+ do {
+ any_exists = false;
+
+ for (unsigned int i = 0; i < rows_.size(); i++)
+ if (!rows_[i].exists) {
+ rows_.erase(rows_.begin() + i);
+ any_exists = true;
+ break;
+ }
+ } while (any_exists);
+}
+