QmlDesigner: fix a rarely happen crash

It was difficult to reproduce, but happen regular while importing
something from design tools.

Task-number: QTCREATORBUG-23707
Change-Id: I93e8c8cf9d44ecf20f5754ae48a0599f056a8610
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Tim Jenssen
2020-03-30 15:23:46 +02:00
parent 7834f172ce
commit e571c98661
4 changed files with 13 additions and 5 deletions

View File

@@ -34,6 +34,7 @@
#include <nodemetainfo.h>
#include <utils/algorithm.h>
#include <utils/qtcassert.h>
#include <QVariant>
#include <QMetaProperty>
@@ -290,13 +291,15 @@ void ItemLibraryModel::addRoleNames()
void ItemLibraryModel::sortSections()
{
int nullPointerSectionCount = m_sections.removeAll(QPointer<ItemLibrarySection>());
QTC_ASSERT(nullPointerSectionCount == 0,;);
auto sectionSort = [](ItemLibrarySection *first, ItemLibrarySection *second) {
return QString::localeAwareCompare(first->sortingName(), second->sortingName()) < 1;
};
std::sort(m_sections.begin(), m_sections.end(), sectionSort);
foreach (ItemLibrarySection *itemLibrarySection, m_sections)
for (auto itemLibrarySection : m_sections)
itemLibrarySection->sortItems();
}