From c396eec30d0db694d665275b625d04627c401317 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 14 Jun 2022 09:13:58 +0300 Subject: Autocommit at 14.06.2022 @ 09:13 --- src/Models/Table.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/Models/Table.cpp') diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp index f55e986..552cd61 100644 --- a/src/Models/Table.cpp +++ b/src/Models/Table.cpp @@ -122,8 +122,8 @@ Table::Table(const char* filePath) { } Table::~Table() { - for (unsigned i = 0; i < cells.get_length(); i++) { - for (unsigned j = 0; j < cells.get_length(); j++) { + for (unsigned i = 0; i < cells.get_count(); i++) { + for (unsigned j = 0; j < cells[i].get_count(); j++) { delete cells[i][j]; } } @@ -163,10 +163,15 @@ void Table::putCell(unsigned row, unsigned col, const char* rawValue) { else throw std::logic_error("Error: Could not determine data type."); - - if (cells[row][col] != nullptr) + if (cells[row].get_count() - 1 < col) { + while (cells[row].get_count() < col) + cells[row].add((Cell*)new CellString()); + cells[row].add(newCell); + } + else { delete cells[row][col]; - cells[row][col] = newCell; + cells[row][col] = newCell; + } } List Table::getAllCells() const { -- cgit v1.3.1-23-gd82d