diff --git a/core/include/Data/ArrayData.h b/core/include/Data/ArrayData.h index 4ccc414..0acf6a0 100644 --- a/core/include/Data/ArrayData.h +++ b/core/include/Data/ArrayData.h @@ -23,18 +23,15 @@ public: template > explicit ArrayData(int nbColumns) : m_Data{1, QVector{}} { - QWriteLocker locker(&m_Lock); + QWriteLocker locker{&m_Lock}; m_Data[0].resize(nbColumns); } - /** - * Ctor for a unidimensional ArrayData - * @param nbColumns the number of values the ArrayData will hold - */ + /// Copy ctor explicit ArrayData(const ArrayData &other) { - QReadLocker otherLocker(&other.m_Lock); - QWriteLocker locker(&m_Lock); + QReadLocker otherLocker{&other.m_Lock}; + QWriteLocker locker{&m_Lock}; m_Data = other.m_Data; } @@ -47,7 +44,7 @@ public: template > void setData(int index, double data) noexcept { - QWriteLocker locker(&m_Lock); + QWriteLocker locker{&m_Lock}; if (index >= 0 && index < m_Data.at(0).size()) { m_Data[0].replace(index, data); } @@ -60,7 +57,7 @@ public: template > QVector data() const noexcept { - QReadLocker locker(&m_Lock); + QReadLocker locker{&m_Lock}; return m_Data[0]; } @@ -71,7 +68,7 @@ public: template > QVector data(double tStart, double tEnd) const noexcept { - QReadLocker locker(&m_Lock); + QReadLocker locker{&m_Lock}; return m_Data.at(tStart); } @@ -79,9 +76,9 @@ public: template > void merge(const ArrayData<1> &arrayData) { - QWriteLocker locker(&m_Lock); + QWriteLocker locker{&m_Lock}; if (!m_Data.empty()) { - QReadLocker otherLocker(&arrayData.m_Lock); + QReadLocker otherLocker{&arrayData.m_Lock}; m_Data[0] += arrayData.data(); } } @@ -89,13 +86,13 @@ public: template > int size() const { - QReadLocker locker(&m_Lock); + QReadLocker locker{&m_Lock}; return m_Data[0].size(); } void clear() { - QWriteLocker locker(&m_Lock); + QWriteLocker locker{&m_Lock}; m_Data.clear(); } diff --git a/core/src/Variable/VariableModel.cpp b/core/src/Variable/VariableModel.cpp index e9a7ea0..b2e6327 100644 --- a/core/src/Variable/VariableModel.cpp +++ b/core/src/Variable/VariableModel.cpp @@ -190,6 +190,8 @@ void VariableModel::onVariableUpdated() noexcept }); if (it != end) { + // Gets the index of the variable in the model: we assume here that views have the same + // order as the model auto updateVariableIndex = std::distance(begin, it); emit dataChanged(createIndex(updateVariableIndex, 0), createIndex(updateVariableIndex, columnCount() - 1));