Read legacy tokens before current tokens.

(So current can overwrite.)

Fixes https://gitlab.com/kicad/code/kicad/-/issues/21525
This commit is contained in:
Jeff Young 2025-08-22 16:26:39 +01:00
parent 01991fed53
commit 03c230dd64
4 changed files with 12 additions and 33 deletions

View File

@ -348,7 +348,15 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std:
if( !aJson.is_object() )
return;
for( const RC_ITEM& item : DRC_ITEM::GetItemsWithSeverities( true ) )
// Load V8 'hole_near_hole' token first (if present). Any current 'hole_to_hole' token
// found will then overwrite it.
// We can't use the migration architecture because we forgot to bump the version number
// when the change was made. But this is a one-off as any future deprecations should
// bump the version number and use registerMigration().
if( aJson.contains( "hole_near_hole" ) )
m_DRCSeverities[DRCE_DRILLED_HOLES_TOO_CLOSE] = SeverityFromString( aJson["hole_near_hole"] );
for( const RC_ITEM& item : DRC_ITEM::GetItemsWithSeverities() )
{
wxString name = item.GetSettingsKey();
std::string key( name.ToUTF8() );

View File

@ -298,13 +298,6 @@ DRC_ITEM DRC_ITEM::nonMirroredTextOnBackLayer( DRCE_NONMIRRORED_TEXT_ON_BACK_LAY
_HKI( "Non-Mirrored text on back layer" ),
wxT( "nonmirrored_text_on_back_layer" ) );
/// Deprecated item names
/// They have the current error code but the old name for compatibility with old settings files
DRC_ITEM DRC_ITEM::holeNearHolev8( DRCE_DRILLED_HOLES_TOO_CLOSE,
_HKI( "Drilled hole too close to other hole - deprecated" ),
wxT( "hole_near_hole" ) );
std::vector<std::reference_wrapper<RC_ITEM>> DRC_ITEM::allItemTypes(
{
DRC_ITEM::heading_electrical,
@ -376,12 +369,6 @@ std::vector<std::reference_wrapper<RC_ITEM>> DRC_ITEM::allItemTypes(
DRC_ITEM::libFootprintMismatch,
DRC_ITEM::footprintTHPadhasNoHole,
// Deprecated items need to come second to last in the list
// They will not be shown in the panel but will be used to
// parse old settings files
DRC_ITEM::heading_deprecated,
DRC_ITEM::holeNearHolev8,
// DRC_ITEM types with no user-editable severities
// NOTE: this MUST be the last grouping in the list!
DRC_ITEM::heading_internal,

View File

@ -130,10 +130,9 @@ public:
*/
static std::shared_ptr<DRC_ITEM> Create( const wxString& aErrorKey );
static std::vector<std::reference_wrapper<RC_ITEM>> GetItemsWithSeverities( bool aIncludeDeprecated = false )
static std::vector<std::reference_wrapper<RC_ITEM>> GetItemsWithSeverities()
{
static std::vector<std::reference_wrapper<RC_ITEM>> itemsWithSeveritiesAll;
static std::vector<std::reference_wrapper<RC_ITEM>> itemsWithSeveritiesDeprecated;
if( itemsWithSeveritiesAll.empty() )
{
@ -146,18 +145,7 @@ public:
}
}
if( itemsWithSeveritiesDeprecated.empty() )
{
for( RC_ITEM& item : allItemTypes )
{
if( &item == &heading_deprecated )
break;
itemsWithSeveritiesDeprecated.push_back( item );
}
}
return aIncludeDeprecated ? itemsWithSeveritiesAll : itemsWithSeveritiesDeprecated;
return itemsWithSeveritiesAll;
}
void SetViolatingRule ( DRC_RULE *aRule ) { m_violatingRule = aRule; }
@ -255,9 +243,6 @@ private:
static DRC_ITEM mirroredTextOnFrontLayer;
static DRC_ITEM nonMirroredTextOnBackLayer;
/// Deprecated items
static DRC_ITEM holeNearHolev8;
private:
DRC_RULE* m_violatingRule = nullptr;
DRC_TEST_PROVIDER* m_violatingTest = nullptr;

View File

@ -178,8 +178,7 @@ bool AskLoadBoardFileName( PCB_EDIT_FRAME* aParent, wxString* aFileName, int aCt
bool kicadFormat = ( aCtl & KICTL_KICAD_ONLY );
wxFileDialog dlg( aParent,
kicadFormat ? _( "Open Board File" ) : _( "Import Non KiCad Board File" ),
wxFileDialog dlg( aParent, kicadFormat ? _( "Open Board File" ) : _( "Import Non KiCad Board File" ),
path, name, fileFiltersStr, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
FILEDLG_IMPORT_NON_KICAD importOptions( aParent->config()->m_System.show_import_issues );