From fb0db5c745bc6fe4885afd11750e267f89cf99da Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 19 Oct 2020 18:26:20 +0200 Subject: ProjectExplorer: Fix sorting predicate to have a strict weak order Fixes random crashes when opening the 'Manage session' dialog. Amends 8c0906e8fb632b82135a843657a1df9216a93c60 Fixes: QTCREATORBUG-24797 Change-Id: Ic3118163d1a9a10eacc1ea1cc90f54c86ac790d9 Reviewed-by: Eike Ziller --- src/plugins/projectexplorer/sessionmodel.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/plugins/projectexplorer/sessionmodel.cpp') diff --git a/src/plugins/projectexplorer/sessionmodel.cpp b/src/plugins/projectexplorer/sessionmodel.cpp index b0d847e7dfe..4cfa95eea54 100644 --- a/src/plugins/projectexplorer/sessionmodel.cpp +++ b/src/plugins/projectexplorer/sessionmodel.cpp @@ -183,10 +183,18 @@ void SessionModel::sort(int column, Qt::SortOrder order) beginResetModel(); const auto cmp = [column, order](const QString &s1, const QString &s2) { bool isLess; - if (column == 0) + if (column == 0) { + if (s1 == s2) + return false; isLess = s1 < s2; - else - isLess = SessionManager::sessionDateTime(s1) < SessionManager::sessionDateTime(s2); + } + else { + const auto s1time = SessionManager::sessionDateTime(s1); + const auto s2time = SessionManager::sessionDateTime(s2); + if (s1time == s2time) + return false; + isLess = s1time < s2time; + } if (order == Qt::DescendingOrder) isLess = !isLess; return isLess; -- cgit v1.2.3