Enforce strictly weak ordering in sheets

This ensures that irreflexivity is given in sort ordering.  This may
have been triggering issues in MacOS when adding sheets

Fixes https://gitlab.com/kicad/code/kicad/issues/10557
This commit is contained in:
Seth Hillbrand 2022-01-24 10:37:54 -08:00
parent 871556ebda
commit a1615cce7e
2 changed files with 11 additions and 8 deletions

View File

@ -22,6 +22,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <cstdlib>
#include <climits>
#include <bitmaps.h>
#include <core/mirror.h>
#include <sch_draw_panel.h>
@ -1224,10 +1227,9 @@ int SCH_SHEET::ComparePageNum( const wxString& aPageNumberA, const wxString& aPa
// If not numeric, then sort as strings using natural sort
int result = StrNumCmp( aPageNumberA, aPageNumberB );
if( result > 0 )
return 1; // A > B
result = result / std::abs( result );
return -1; //A < B
return result;
}

View File

@ -175,13 +175,14 @@ int SCH_SHEET_PATH::ComparePageNum( const SCH_SHEET_PATH& aSheetPathToTest ) con
int virtualPageA = GetVirtualPageNumber();
int virtualPageB = aSheetPathToTest.GetVirtualPageNumber();
return virtualPageA > virtualPageB ? 1 : -1;
if( virtualPageA > virtualPageB )
pageNumComp = 1;
else if( virtualPageA < virtualPageB )
pageNumComp = -1;
}
else
{
return pageNumComp;
}
}
bool SCH_SHEET_PATH::IsContainedWithin( const SCH_SHEET_PATH& aSheetPathToTest ) const