From 0476b6c72d11f4c4ea21701096372f161aa9272f Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sun, 5 May 2024 07:32:34 -0700 Subject: [PATCH] Ensure irreflexive property in LIB_TREE_NODE --- common/lib_tree_model.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/common/lib_tree_model.cpp b/common/lib_tree_model.cpp index 3e1ed9d872..e1c4563999 100644 --- a/common/lib_tree_model.cpp +++ b/common/lib_tree_model.cpp @@ -92,10 +92,13 @@ bool LIB_TREE_NODE::Compare( LIB_TREE_NODE const& aNode1, LIB_TREE_NODE const& a if( aNode2.m_Name.StartsWith( wxT( "-- " ) ) ) { // Make sure -- Recently Used is always at the top - if( aNode1.m_Name.StartsWith( wxT( "-- Recently Used" ) ) ) - return true; - else if( aNode2.m_Name.StartsWith( wxT( "-- Recently Used" ) ) ) + // Start by checking the name of aNode2, because we + // want to satisfy the irreflexive property of the + // strict weak ordering. + if( aNode2.m_Name.StartsWith( wxT( "-- Recently Used" ) ) ) return false; + else if( aNode1.m_Name.StartsWith( wxT( "-- Recently Used" ) ) ) + return true; return aNode1.m_IntrinsicRank > aNode2.m_IntrinsicRank; }