Commit d76d9c21 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Don't add the same resource twice in the resources proxy model

parent db01c0d4
......@@ -445,10 +445,12 @@ void ResourcesProxyModel::sortedInsertion(const QVector<AbstractResource*> & res
}
for(auto resource: resources) {
int newIdx = 0;
const auto finder = [this, resource](AbstractResource* res){ return lessThan(resource, res); };
const auto it = std::find_if(m_displayedResources.constBegin() + newIdx, m_displayedResources.constEnd(), finder);
newIdx = it == m_displayedResources.constEnd() ? m_displayedResources.count() : (it - m_displayedResources.constBegin());
const auto it = std::find_if(m_displayedResources.constBegin(), m_displayedResources.constEnd(), finder);
const auto newIdx = it == m_displayedResources.constEnd() ? m_displayedResources.count() : (it - m_displayedResources.constBegin());
if (it != m_displayedResources.constEnd() && *it == resource)
continue;
beginInsertRows({}, newIdx, newIdx);
m_displayedResources.insert(newIdx, resource);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment