diff --git a/eeschema/eeschema_jobs_handler.cpp b/eeschema/eeschema_jobs_handler.cpp index 9f257a9cf9..b8cba6e754 100644 --- a/eeschema/eeschema_jobs_handler.cpp +++ b/eeschema/eeschema_jobs_handler.cpp @@ -81,6 +81,13 @@ int EESCHEMA_JOBS_HANDLER::JobExportPdf( JOB* aJob ) JOB_EXPORT_SCH_PDF* aPdfJob = dynamic_cast( aJob ); SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aPdfJob->m_filename, SCH_IO_MGR::SCH_KICAD ); + + if( sch == nullptr ) + { + wxFprintf( stderr, _( "Failed to load schematic file\n" ) ); + return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE; + } + std::unique_ptr renderSettings = std::make_unique(); InitRenderSettings( renderSettings.get(), aPdfJob->m_colorTheme, sch ); @@ -107,6 +114,13 @@ int EESCHEMA_JOBS_HANDLER::JobExportSvg( JOB* aJob ) JOB_EXPORT_SCH_SVG* aSvgJob = dynamic_cast( aJob ); SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aSvgJob->m_filename, SCH_IO_MGR::SCH_KICAD ); + + if( sch == nullptr ) + { + wxFprintf( stderr, _( "Failed to load schematic file\n" ) ); + return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE; + } + std::unique_ptr renderSettings = std::make_unique(); InitRenderSettings( renderSettings.get(), aSvgJob->m_colorTheme, sch ); @@ -134,6 +148,12 @@ int EESCHEMA_JOBS_HANDLER::JobExportNetlist( JOB* aJob ) SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aNetJob->m_filename, SCH_IO_MGR::SCH_KICAD ); + if( sch == nullptr ) + { + wxFprintf( stderr, _( "Failed to load schematic file\n" ) ); + return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE; + } + // Annotation warning check SCH_REFERENCE_LIST referenceList; sch->GetSheets().GetSymbols( referenceList ); @@ -221,6 +241,12 @@ int EESCHEMA_JOBS_HANDLER::JobExportBom( JOB* aJob ) SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aNetJob->m_filename, SCH_IO_MGR::SCH_KICAD ); + if( sch == nullptr ) + { + wxFprintf( stderr, _( "Failed to load schematic file\n" ) ); + return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE; + } + // Annotation warning check SCH_REFERENCE_LIST referenceList; sch->GetSheets().GetSymbols( referenceList );