diff --git a/core/src/Variable/VariableModel.cpp b/core/src/Variable/VariableModel.cpp index b3d7481..7553415 100644 --- a/core/src/Variable/VariableModel.cpp +++ b/core/src/Variable/VariableModel.cpp @@ -47,7 +47,7 @@ const auto DATETIME_FORMAT = QStringLiteral("dd/MM/yyyy \nhh:mm:ss:zzz"); struct VariableModel::VariableModelPrivate { /// Variables created in SciQlop std::vector > m_Variables; - std::unordered_map m_VariableToProgress; + std::unordered_map, double> m_VariableToProgress; /// Return the row index of the variable. -1 if it's not found int indexOfVariable(Variable *variable) const noexcept; @@ -99,6 +99,9 @@ void VariableModel::deleteVariable(std::shared_ptr variable) noexcept << tr("Can't delete variable %1 from the model: the variable is not in the model") .arg(variable->name()); } + + // Removes variable from progress map + impl->m_VariableToProgress.erase(variable); } @@ -109,7 +112,7 @@ std::shared_ptr VariableModel::variable(int index) const void VariableModel::setDataProgress(std::shared_ptr variable, double progress) { - impl->m_VariableToProgress[variable.get()] = progress; + impl->m_VariableToProgress[variable] = progress; auto modelIndex = createIndex(impl->indexOfVariable(variable.get()), NAME_COLUMN); emit dataChanged(modelIndex, modelIndex); @@ -169,7 +172,7 @@ QVariant VariableModel::data(const QModelIndex &index, int role) const else if (role == VariableRoles::ProgressRole) { if (auto variable = impl->m_Variables.at(index.row())) { - auto it = impl->m_VariableToProgress.find(variable.get()); + auto it = impl->m_VariableToProgress.find(variable); if (it != impl->m_VariableToProgress.cend()) { return it->second; }