From f6ec173ba708bb3d3c8befe90e80067c8622e0cb Mon Sep 17 00:00:00 2001 From: Roberto Fernandez Bautista Date: Tue, 29 Dec 2020 23:35:57 +0000 Subject: [PATCH] CADSTAR Schematic Archive Importer: Do not load blocks without a linked sheet Fixes std::out_of_range error --- .../cadstar/cadstar_sch_archive_loader.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp index 63bde11bd2..cb5c227de1 100644 --- a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp +++ b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp @@ -1593,6 +1593,21 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadChildSheets( if( block.LayerID == aCadstarSheetID && block.Type == BLOCK::TYPE::CHILD ) { + if( block.AssocLayerID == wxT( "NO_LINK" ) ) + { + if( block.Figures.size() > 0 ) + { + wxLogError( wxString::Format( + _( "The block ID %s (Block name: '%s') is drawn on sheet '%s' but is " + "not linked to another sheet in the design. KiCad requires all " + "sheet symbols to be associated to a sheet, so the block was not " + "loaded." ), + block.ID, block.Name, Sheets.SheetNames.at( aCadstarSheetID ) ) ); + } + + continue; + } + // In KiCad you can only draw rectangular shapes whereas in Cadstar arbitrary shapes // are allowed. We will calculate the extents of the Cadstar shape and draw a rectangle