From d2d066064701968a7d75119b891b5da8765e4157 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 22 Mar 2018 11:25:04 +0000 Subject: [PATCH] Open viewer even when FPID is invalid. Just show an empty viewer. --- .../dialog_edit_component_in_schematic.cpp | 16 ++++---------- pcbnew/footprint_viewer_frame.cpp | 22 +++++++++++++------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index 96705fff0f..177146de6e 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -617,20 +617,12 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::showButtonHandler( wxCommandEvent& even KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_MODULE_VIEWER_MODAL, true, this ); - try + if( frame->ShowModal( &fpid, this ) ) { - if( frame->ShowModal( &fpid, this ) ) - { - // DBG( printf( "%s: %s\n", __func__, TO_UTF8( fpid ) ); ) - fieldValueTextCtrl->SetValue( fpid ); + // DBG( printf( "%s: %s\n", __func__, TO_UTF8( fpid ) ); ) + fieldValueTextCtrl->SetValue( fpid ); - setRowItem( fieldNdx, m_FieldsBuf[fieldNdx].GetName( false ), fpid ); - } - } - catch( const IO_ERROR& aError ) - { - // it may happen that the specified footprint is not available in the loaded - // footprint libraries, no big deal + setRowItem( fieldNdx, m_FieldsBuf[fieldNdx].GetName( false ), fpid ); } frame->Destroy(); diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index 475b1a013b..f561540be3 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -626,14 +626,22 @@ bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aResulta { if( aFootprint && !aFootprint->IsEmpty() ) { - LIB_ID fpid( *aFootprint ); - - if( fpid.IsValid() ) + try { - setCurNickname( fpid.GetLibNickname() ); - setCurFootprintName( fpid.GetLibItemName() ); - ReCreateFootprintList(); - SelectAndViewFootprint( NEW_PART ); + LIB_ID fpid( *aFootprint ); + + if( fpid.IsValid() ) + { + setCurNickname( fpid.GetLibNickname() ); + setCurFootprintName( fpid.GetLibItemName() ); + ReCreateFootprintList(); + SelectAndViewFootprint( NEW_PART ); + } + } + catch( ... ) + { + // LIB_ID's constructor throws on some invalid footprint IDs. It'd be nicer + // if it just set it to !IsValid(), but it is what it is. } }