mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-15 10:43:15 +02:00
Add a simple hash for sch_tables to avoid too much reordering in the saved schematic file
Fixes https://gitlab.com/kicad/code/kicad/-/issues/20918
This commit is contained in:
parent
6d1bf799ff
commit
f7e851178e
@ -401,6 +401,15 @@ void SCH_IO_KICAD_SEXPR::Format( SCH_SHEET* aSheet )
|
|||||||
if( a->Type() != b->Type() )
|
if( a->Type() != b->Type() )
|
||||||
return a->Type() < b->Type();
|
return a->Type() < b->Type();
|
||||||
|
|
||||||
|
// sorting fix specific for 9.0 to avoid format change
|
||||||
|
if( a->Type() == SCH_TABLE_T && b->Type() == SCH_TABLE_T )
|
||||||
|
{
|
||||||
|
const SCH_TABLE* aTable = static_cast<const SCH_TABLE*>( a );
|
||||||
|
const SCH_TABLE* bTable = static_cast<const SCH_TABLE*>( b );
|
||||||
|
|
||||||
|
return aTable->GetHash() < bTable->GetHash();
|
||||||
|
}
|
||||||
|
|
||||||
return a->m_Uuid < b->m_Uuid;
|
return a->m_Uuid < b->m_Uuid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -628,6 +628,25 @@ double SCH_TABLE::Similarity( const SCH_ITEM& aOther ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
size_t SCH_TABLE::GetHash() const
|
||||||
|
{
|
||||||
|
size_t hash = 0;
|
||||||
|
|
||||||
|
// The goal here is to generate an hash that would change the least for
|
||||||
|
// mundane things like just moving the table.
|
||||||
|
|
||||||
|
hash_combine( hash, m_colCount );
|
||||||
|
hash_combine( hash, m_rowHeights.size() );
|
||||||
|
|
||||||
|
for( SCH_TABLECELL* cell : m_cells )
|
||||||
|
{
|
||||||
|
hash_combine( hash, cell->GetText() );
|
||||||
|
}
|
||||||
|
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static struct SCH_TABLE_DESC
|
static struct SCH_TABLE_DESC
|
||||||
{
|
{
|
||||||
SCH_TABLE_DESC()
|
SCH_TABLE_DESC()
|
||||||
|
@ -245,6 +245,12 @@ public:
|
|||||||
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function exists to keep tables sorted on save in 9.0 as the uuid
|
||||||
|
* is missing.
|
||||||
|
*/
|
||||||
|
size_t GetHash() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool m_strokeExternal;
|
bool m_strokeExternal;
|
||||||
bool m_StrokeHeaderSeparator;
|
bool m_StrokeHeaderSeparator;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user