From 5ef9db6d67a91b73d667b55c7eeb8649a89df204 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Fri, 8 May 2020 16:01:14 -0400 Subject: [PATCH] Eeschema: fix large diffs when saving schematics. Apparently the < operator was never implemented for SCH_JUNCTION objects so they were not get sorted which was causing the large diffs between schematic saves. Fixes https://gitlab.com/kicad/code/kicad/issues/4370 (cherry picked from commit 35f3eb622029e329287e24b437bee349f2c666d4) --- eeschema/sch_junction.cpp | 19 +++++++++++++++++++ eeschema/sch_junction.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index 3312b1b208..d725a375f5 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -223,3 +223,22 @@ BITMAP_DEF SCH_JUNCTION::GetMenuImage() const { return add_junction_xpm; } + + +bool SCH_JUNCTION::operator <( const SCH_ITEM& aItem ) const +{ + if( Type() != aItem.Type() ) + return Type() < aItem.Type(); + + if( GetLayer() != aItem.GetLayer() ) + return GetLayer() < aItem.GetLayer(); + + auto junction = static_cast( &aItem ); + + if( GetPosition().x != junction->GetPosition().x ) + return GetPosition().x < junction->GetPosition().x; + + return GetPosition().y < junction->GetPosition().y; + +} + diff --git a/eeschema/sch_junction.h b/eeschema/sch_junction.h index 8d349e7aee..522be4ca21 100644 --- a/eeschema/sch_junction.h +++ b/eeschema/sch_junction.h @@ -113,6 +113,8 @@ public: EDA_ITEM* Clone() const override; + virtual bool operator <( const SCH_ITEM& aItem ) const override; + #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const override; #endif