router: make sure we are not committing VIAs with non-unique IDs, fixes random disappearing via issue

Note to self:
LINE_PLACER::FixRoute used to silently reclaim the UID of the transient via (as used by the SHOVE's heads tracking logic).
Depending on the particular sequence of user events (the bug is next to impossible to reproduce on a touchpad), this would
result in freshly placed vias disappearing...

Fixes https://gitlab.com/kicad/code/kicad/issues/20999
This commit is contained in:
Tomasz Wlostowski 2025-05-28 13:41:54 +02:00
parent 3813cbd40b
commit c5a4f9e747
2 changed files with 14 additions and 2 deletions

View File

@ -1595,7 +1595,9 @@ bool LINE_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem, bool aForceFinis
///< false but someone with more knowledge of the code will need to determine that.. ///< false but someone with more knowledge of the code will need to determine that..
if( m_lastNode ) if( m_lastNode )
{ {
m_lastNode->Add( Clone( pl.Via() ) ); auto newVia = Clone( pl.Via() );
newVia->ResetUid();
m_lastNode->Add( std::move( newVia ) );
m_shove->AddLockedSpringbackNode( m_lastNode ); m_shove->AddLockedSpringbackNode( m_lastNode );
} }
@ -1675,7 +1677,12 @@ bool LINE_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem, bool aForceFinis
} }
if( pl.EndsWithVia() ) if( pl.EndsWithVia() )
m_lastNode->Add( Clone( pl.Via() ) ); {
auto newVia = Clone( pl.Via() );
newVia->ResetUid();
m_lastNode->Add( std::move( newVia ) );
}
if( realEnd && lastItem ) if( realEnd && lastItem )
simplifyNewLine( m_lastNode, lastItem ); simplifyNewLine( m_lastNode, lastItem );

View File

@ -43,6 +43,11 @@ public:
m_uid( aOther.m_uid ) m_uid( aOther.m_uid )
{} {}
void ResetUid()
{
m_uid = genNextUid();
}
UNIQ_ID Uid() const { return m_uid; } UNIQ_ID Uid() const { return m_uid; }
virtual void SetWidth( int aWidth ) virtual void SetWidth( int aWidth )