Fix issue: "Malformed footprint causes crash on load" (in fact, no crash: just an assert dialog is shown)

This commit is contained in:
jean-pierre charras 2016-03-13 16:39:18 +01:00
parent 3ba4226cb2
commit 44fc6cb337
2 changed files with 13 additions and 7 deletions

View File

@ -1,10 +1,10 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -900,6 +900,10 @@ void MODULE::ViewGetLayers( int aLayers[], int& aCount ) const
switch( m_Layer ) switch( m_Layer )
{ {
default:
wxASSERT_MSG( false, "Illegal layer" ); // do you really have modules placed on other layers?
// pass through
case F_Cu: case F_Cu:
aLayers[1] = ITEM_GAL_LAYER( MOD_FR_VISIBLE ); aLayers[1] = ITEM_GAL_LAYER( MOD_FR_VISIBLE );
break; break;
@ -907,10 +911,6 @@ void MODULE::ViewGetLayers( int aLayers[], int& aCount ) const
case B_Cu: case B_Cu:
aLayers[1] = ITEM_GAL_LAYER( MOD_BK_VISIBLE ); aLayers[1] = ITEM_GAL_LAYER( MOD_BK_VISIBLE );
break; break;
default:
assert( false ); // do you really have modules placed on inner layers?
break;
} }
} }

View File

@ -1692,7 +1692,13 @@ MODULE* PCB_PARSER::parseMODULE( wxArrayString* aInitialComments ) throw( IO_ERR
break; break;
case T_layer: case T_layer:
module->SetLayer( parseBoardItemLayer() ); {
// Footprints can be only on the front side or the back side.
// but because we can find some stupid layer in file, ensure a
// acceptable layer is set for the footprint
LAYER_ID layer = parseBoardItemLayer();
module->SetLayer( layer == B_Cu ? B_Cu : F_Cu );
}
NeedRIGHT(); NeedRIGHT();
break; break;