diff --git a/common/plotters/GERBER_plotter.cpp b/common/plotters/GERBER_plotter.cpp index 3677d82cd5..9f2c456d0a 100644 --- a/common/plotters/GERBER_plotter.cpp +++ b/common/plotters/GERBER_plotter.cpp @@ -244,7 +244,9 @@ bool GERBER_PLOTTER::EndPlot() { fputs( line, outputFile ); - if( strcmp( strtok( line, "\n\r" ), "G04 APERTURE LIST*" ) == 0 ) + char* substr = strtok( line, "\n\r" ); + + if( substr && strcmp( substr, "G04 APERTURE LIST*" ) == 0 ) { writeApertureList(); fputs( "G04 APERTURE END LIST*\n", outputFile ); diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index ae70663167..ebc84270ec 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -1393,9 +1393,24 @@ bool MODULE::BuildPolyCourtyard() return success; } + void MODULE::SwapData( BOARD_ITEM* aImage ) { assert( aImage->Type() == PCB_MODULE_T ); std::swap( *((MODULE*) this), *((MODULE*) aImage) ); } + + +bool MODULE::HasNonSMDPins() const +{ + // returns true if the given module has at lesat one non smd pin, such as through hole + + for( auto pad : Pads() ) + { + if( pad->GetAttribute() != PAD_ATTRIB_SMD ) + return true; + } + + return false; +} diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index c5d4265803..2b3eee9195 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -182,6 +182,13 @@ public: return m_drawings; } + /** + * @return true if the given module has any non smd pins, such as through hole + * and therefore cannot be placed automatically. + * Used in Pick and Place files writers + */ + bool HasNonSMDPins() const; + std::list& Models() { return m_3D_Drawings; } const std::list& Models() const { return m_3D_Drawings; } diff --git a/pcbnew/exporters/export_footprints_placefile.cpp b/pcbnew/exporters/export_footprints_placefile.cpp index c9a66cf5bc..62ce8782ce 100644 --- a/pcbnew/exporters/export_footprints_placefile.cpp +++ b/pcbnew/exporters/export_footprints_placefile.cpp @@ -62,24 +62,6 @@ static bool sortFPlist( const LIST_MOD& ref, const LIST_MOD& tst ) } -/** - * Helper function HasNonSMDPins - * returns true if the given module has any non smd pins, such as through hole - * and therefore cannot be placed automatically. - */ -static bool HasNonSMDPins( MODULE* aModule ) -{ - for( auto pad : aModule->Pads() ) - { - if( pad->GetAttribute() != PAD_ATTRIB_SMD ) - return true; - } - - return false; -} - - - enum SELECT_SIDE { PCB_NO_SIDE, @@ -150,7 +132,7 @@ std::string PLACE_FILE_EXPORTER::GenPositionData() { if( m_forceSmdItems ) // true to fix a bunch of mis-labeled footprints: { - if( !HasNonSMDPins( footprint ) ) + if( !footprint->HasNonSMDPins() ) { // all footprint's pins are SMD, mark the part for pick and place // Note: they are not necessary to pick and place,