Fix netlist generation bug cause when component unit is set to zero.

Fix if statement logic to ensure the unit number is never set to zero.

Add logic to the legacy schematic plugin to automatically convert any
schematic files that have components with a unit setting of zero.  Set
the schematic modified flag so that the user will be notified of a
changed schematic.

Add a user warning when the schematic parser fixes the bug and sets
the file modified flag.

Fixes lp:1677282

https://bugs.launchpad.net/kicad/+bug/1677282
This commit is contained in:
Wayne Stambaugh 2017-03-30 15:44:47 -04:00
parent ef9f8d40c6
commit 40f60c9871
3 changed files with 27 additions and 3 deletions

View File

@ -338,7 +338,18 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
SetScreen( m_CurrentSheet->LastScreen() ); 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 ); UpdateFileHistory( fullFileName );

View File

@ -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 if( alias == nullptr ) // Dialog closed by OK button, but no symbol selected
return COMPONENT_SELECTION(); return COMPONENT_SELECTION();
if( alias->GetPart()->IsMulti() && sel.Unit == 0 ) if( sel.Unit == 0 )
sel.Unit = 1; sel.Unit = 1;
sel.Fields = dlg.GetFields(); sel.Fields = dlg.GetFields();

View File

@ -1336,7 +1336,20 @@ SCH_COMPONENT* SCH_LEGACY_PLUGIN::loadComponent( FILE_LINE_READER& aReader )
} }
else if( strCompare( "U", line, &line ) ) 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->SetConvert( parseInt( aReader, line, &line ) );
component->SetTimeStamp( parseHex( aReader, line, &line ) ); component->SetTimeStamp( parseHex( aReader, line, &line ) );
} }