Preserve leading zeroes in reference designators

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15760
This commit is contained in:
Jon Evans 2023-10-31 22:51:45 -04:00
parent d6b76ae9df
commit 9271fde71d
2 changed files with 6 additions and 3 deletions

View File

@ -852,6 +852,7 @@ void SCH_REFERENCE::Split()
std::string refText = GetRefStr();
m_numRef = -1;
m_numRefStr.Clear();
int ll = refText.length() - 1;
@ -883,7 +884,8 @@ void SCH_REFERENCE::Split()
m_numRef = atoi( cp );
}
refText.erase( ll+1 ); // delete from ll+1 to end
m_numRefStr = std::string( refText, ll + 1 );
refText.erase( ll + 1 );
break;
}
}
@ -967,4 +969,4 @@ void SCH_REFERENCE_LIST::Show( const char* aPrefix )
schref.m_numRef, TO_UTF8( schref.GetLibPart()->GetName() ) );
}
}
#endif
#endif

View File

@ -187,7 +187,7 @@ public:
if( GetLibPart() && GetLibPart()->IsPower() )
ref = wxT( "0" );
return ref << m_numRef;
return m_numRefStr.IsEmpty() ? ( ref << m_numRef ) : ( ref << m_numRefStr );
}
int CompareValue( const SCH_REFERENCE& item ) const
@ -245,6 +245,7 @@ private:
int m_sheetNum; ///< The sheet number for the reference.
KIID m_symbolUuid; ///< UUID of the symbol.
int m_numRef; ///< The numeric part of the reference designator.
wxString m_numRefStr; ///< The numeric part in original string form (may have leading zeroes)
int m_flag;
};