diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 8cb5a6f9f4..cc5ffdb348 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -338,7 +338,18 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in SetScreen( m_CurrentSheet->LastScreen() ); - GetScreen()->ClrModify(); + // It's possible the schematic parser fixed errors due to bugs so warn the user + // that the schematic has been fixed (modified). + SCH_SHEET_LIST sheetList( g_RootSheet ); + + if( sheetList.IsModified() ) + { + DisplayInfoMessage( this, + _( "An error was found when loading the schematic that has " + "been automatically fixed. Please save the schematic to " + "repair the broken file or it may not be usable with other " + "versions of KiCad." ) ); + } UpdateFileHistory( fullFileName ); diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index ec5dff5307..151e0026c4 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -166,7 +166,7 @@ SCH_BASE_FRAME::COMPONENT_SELECTION SCH_BASE_FRAME::SelectComponentFromLibrary( if( alias == nullptr ) // Dialog closed by OK button, but no symbol selected return COMPONENT_SELECTION(); - if( alias->GetPart()->IsMulti() && sel.Unit == 0 ) + if( sel.Unit == 0 ) sel.Unit = 1; sel.Fields = dlg.GetFields(); diff --git a/eeschema/sch_legacy_plugin.cpp b/eeschema/sch_legacy_plugin.cpp index 12df024556..765a41c063 100644 --- a/eeschema/sch_legacy_plugin.cpp +++ b/eeschema/sch_legacy_plugin.cpp @@ -1336,7 +1336,20 @@ SCH_COMPONENT* SCH_LEGACY_PLUGIN::loadComponent( FILE_LINE_READER& aReader ) } else if( strCompare( "U", line, &line ) ) { - component->SetUnit( parseInt( aReader, line, &line ) ); + // This fixes a potentially buggy files caused by unit being set to zero which + // causes netlist issues. See https://bugs.launchpad.net/kicad/+bug/1677282. + int unit = parseInt( aReader, line, &line ); + + if( unit == 0 ) + { + unit = 1; + + // Set the file as modified so the user can be warned. + if( m_rootSheet && m_rootSheet->GetScreen() ) + m_rootSheet->GetScreen()->SetModify(); + } + + component->SetUnit( unit ); component->SetConvert( parseInt( aReader, line, &line ) ); component->SetTimeStamp( parseHex( aReader, line, &line ) ); }