##// END OF EJS Templates
Corrects regression on variable destruction
Alexandre Leroux -
r421:a9d7c7f52b62
parent child
Show More
@@ -47,7 +47,7 const auto DATETIME_FORMAT = QStringLiteral("dd/MM/yyyy \nhh:mm:ss:zzz");
47 47 struct VariableModel::VariableModelPrivate {
48 48 /// Variables created in SciQlop
49 49 std::vector<std::shared_ptr<Variable> > m_Variables;
50 std::unordered_map<Variable *, double> m_VariableToProgress;
50 std::unordered_map<std::shared_ptr<Variable>, double> m_VariableToProgress;
51 51
52 52 /// Return the row index of the variable. -1 if it's not found
53 53 int indexOfVariable(Variable *variable) const noexcept;
@@ -99,6 +99,9 void VariableModel::deleteVariable(std::shared_ptr<Variable> variable) noexcept
99 99 << tr("Can't delete variable %1 from the model: the variable is not in the model")
100 100 .arg(variable->name());
101 101 }
102
103 // Removes variable from progress map
104 impl->m_VariableToProgress.erase(variable);
102 105 }
103 106
104 107
@@ -109,7 +112,7 std::shared_ptr<Variable> VariableModel::variable(int index) const
109 112
110 113 void VariableModel::setDataProgress(std::shared_ptr<Variable> variable, double progress)
111 114 {
112 impl->m_VariableToProgress[variable.get()] = progress;
115 impl->m_VariableToProgress[variable] = progress;
113 116 auto modelIndex = createIndex(impl->indexOfVariable(variable.get()), NAME_COLUMN);
114 117
115 118 emit dataChanged(modelIndex, modelIndex);
@@ -169,7 +172,7 QVariant VariableModel::data(const QModelIndex &index, int role) const
169 172 else if (role == VariableRoles::ProgressRole) {
170 173 if (auto variable = impl->m_Variables.at(index.row())) {
171 174
172 auto it = impl->m_VariableToProgress.find(variable.get());
175 auto it = impl->m_VariableToProgress.find(variable);
173 176 if (it != impl->m_VariableToProgress.cend()) {
174 177 return it->second;
175 178 }
General Comments 0
You need to be logged in to leave comments. Login now