From 5fac74cefc1bf53ed887b15600984201c5320a51 Mon Sep 17 00:00:00 2001 From: Houssem Date: Fri, 10 May 2024 15:35:41 +0200 Subject: [PATCH] fixing auto-insert of garbage values when adding columns --- src/gui/PivotGui.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui/PivotGui.cpp b/src/gui/PivotGui.cpp index bcd056f..30ce92b 100644 --- a/src/gui/PivotGui.cpp +++ b/src/gui/PivotGui.cpp @@ -37,8 +37,12 @@ void PivotGui::Render() { ImGui::BeginChild("MatriceInitiale", ImVec2(topLeftWindowSize.x, io.DisplaySize.y * 0.7f), false); - // Resize matrixValues - matrixValues.resize(matrixSizeY, std::vector(matrixSizeX, 0)); + // Resize matrixValues and initialize new elements to 0 + + matrixValues.resize(matrixSizeY); + for(auto& row : matrixValues) { + row.resize(matrixSizeX, 0); + } for (int y = 0; y < matrixSizeY; y++) { for (int x = 0; x < matrixSizeX; x++) {