diff --git a/KomplexHubPlugin/common/paginator.h b/KomplexHubPlugin/common/paginator.h index 6fc58de..737c73a 100644 --- a/KomplexHubPlugin/common/paginator.h +++ b/KomplexHubPlugin/common/paginator.h @@ -131,16 +131,9 @@ public: * @param index * @return */ - auto at(qsizetype index) -> T + auto at(qsizetype index) const -> T { - QMutexLocker dataLocker(&m_dataMutex); - - if(index < 0 || index >= m_data.count()) - { - return {}; - } - - return m_data.at(index); + return get(index); } /** @@ -264,6 +257,25 @@ protected: } private: + /** + * @brief get + * Private thread-safe get operation. This is needed to preserve the constness + * of the at function + * @param index + * @return + */ + auto get(qsizetype index) -> T + { + QMutexLocker dataLocker(&m_dataMutex); + + if(index < 0 || index >= m_data.count()) + { + return {}; + } + + return m_data.at(index); + } + /** * @brief m_offset * Current absolute offset. Used in fetch operations