From 7eabba959b0374abb16ebf2dbeba157901cb3303 Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Sun, 13 Sep 2020 11:08:43 +0200 Subject: [PATCH] Split up a few single-liners to help debug crash issue --- src/common/SignalVectorModel.hpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/common/SignalVectorModel.hpp b/src/common/SignalVectorModel.hpp index 76bc14b22..c00476d88 100644 --- a/src/common/SignalVectorModel.hpp +++ b/src/common/SignalVectorModel.hpp @@ -144,7 +144,11 @@ public: Row &rowItem = this->rows_[row]; - rowItem.items[column]->setData(value, role); + assert(this->columnCount_ == rowItem.items.size()); + + auto &cell = rowItem.items[column]; + + cell->setData(value, role); if (rowItem.isCustomRow) { @@ -211,7 +215,11 @@ public: assert(row >= 0 && row < this->rows_.size() && column >= 0 && column < this->columnCount_); - return this->rows_[row].items[column]->flags(); + const auto &rowItem = this->rows_[row]; + + assert(this->columnCount_ == rowItem.items.size()); + + return rowItem.items[column]->flags(); } QStandardItem *getItem(int row, int column) @@ -219,7 +227,11 @@ public: assert(row >= 0 && row < this->rows_.size() && column >= 0 && column < this->columnCount_); - return rows_[row].items[column]; + const auto &rowItem = this->rows_[row]; + + assert(this->columnCount_ == rowItem.items.size()); + + return rowItem.items[column]; } void deleteRow(int row) @@ -395,7 +407,7 @@ private: SignalVector *vector_; std::vector rows_; - int columnCount_; + const int columnCount_; // returns the related index of the SignalVector int getVectorIndexFromModelIndex(int index)