diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index 062862f9db..5609875816 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -145,6 +145,7 @@ SCH_BASE_FRAME::COMPONENT_SELECTION SCH_BASE_FRAME::SelectComponentFromLibTree( { LIB_ALIAS* alias = GetLibAlias( i.LibId ); + // This can be null, for example when a symbol has been deleted from a library if( alias ) history_list.push_back( alias ); } diff --git a/pcbnew/load_select_footprint.cpp b/pcbnew/load_select_footprint.cpp index a33fb1f229..8a025c8312 100644 --- a/pcbnew/load_select_footprint.cpp +++ b/pcbnew/load_select_footprint.cpp @@ -227,17 +227,20 @@ MODULE* PCB_BASE_FRAME::SelectFootprintFromLibTree( LIB_ID aPreselect, bool aAll std::vector historyInfos; for( auto const& item : s_ModuleHistoryList ) - historyInfos.push_back( GFootprintList.GetModuleInfo( item ) ); + { + LIB_TREE_ITEM* fp_info = GFootprintList.GetModuleInfo( item ); + + // this can be null, for example, if the footprint has been deleted from a library. + if( fp_info != nullptr ) + historyInfos.push_back( fp_info ); + } adapter->DoAddLibrary( "-- " + _( "Recently Used" ) + " --", wxEmptyString, historyInfos, true ); if( aPreselect.IsValid() ) adapter->SetPreselectNode( aPreselect, 0 ); else if( historyInfos.size() ) - { - if( historyInfos[0] ) // Can be null if the footprint was deleted since the last call - adapter->SetPreselectNode( historyInfos[0]->GetLibId(), 0 ); - } + adapter->SetPreselectNode( historyInfos[0]->GetLibId(), 0 ); adapter->AddLibraries();