diff --git a/src/plugins/coreplugin/welcomepagehelper.cpp b/src/plugins/coreplugin/welcomepagehelper.cpp index 0c46ea98f30..d5f09a8c5c6 100644 --- a/src/plugins/coreplugin/welcomepagehelper.cpp +++ b/src/plugins/coreplugin/welcomepagehelper.cpp @@ -637,8 +637,6 @@ SectionedGridView::SectionedGridView(QWidget *parent) { auto allItemsModel = new ListModel(this); allItemsModel->setPixmapFunction(m_pixmapFunction); - // it just "borrows" the items from the section models: - allItemsModel->setOwnsItems(false); m_filteredAllItemsModel = new Core::ListModelFilter(allItemsModel, this); auto area = new QScrollArea(this); @@ -690,6 +688,10 @@ ListModel *SectionedGridView::addSection(const Section §ion, const QListsetPixmapFunction(m_pixmapFunction); + // the sections only keep a weak reference to the items, + // they are owned by the allProducts model, since multiple sections can contain duplicates + // of the same item + model->setOwnsItems(false); model->appendItems(items); auto gridView = new SectionGridView(this); @@ -716,7 +718,11 @@ ListModel *SectionedGridView::addSection(const Section §ion, const QList(m_filteredAllItemsModel->sourceModel()); - allProducts->appendItems(items); + const QSet allItems = toSet(allProducts->items()); + const QList newItems = filtered(items, [&allItems](ListItem *item) { + return !allItems.contains(item); + }); + allProducts->appendItems(newItems); // only show section label(s) if there is more than one section m_sectionLabels.at(0)->setVisible(m_sectionLabels.size() > 1);