From 13198852850b75ac2d2df796bd55bd5b103421f4 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Thu, 24 Sep 2020 18:08:23 -0400 Subject: [PATCH] Wrap ZONE_FILLER to allow use without commit from Python Fixes https://gitlab.com/kicad/code/kicad/-/issues/5646 --- pcbnew/swig/zone.i | 14 ++++++++++++-- pcbnew/zone_filler.cpp | 4 +++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/pcbnew/swig/zone.i b/pcbnew/swig/zone.i index 6fd00737e3..38b4f315b8 100644 --- a/pcbnew/swig/zone.i +++ b/pcbnew/swig/zone.i @@ -1,11 +1,21 @@ - +// Do not permit default ZONE_FILLER ctor since commits are not supported from Python +%ignore ZONE_FILLER::ZONE_FILLER(BOARD*, COMMIT*); %include class_zone.h %include zones.h -%include zone_filler.h + %{ #include #include #include %} +// Provide a compatiblity ctor for ZONE_FILLER that doesn't need a COMMIT +%include zone_filler.h +%extend ZONE_FILLER +{ + ZONE_FILLER( BOARD* aBoard ) + { + return new ZONE_FILLER( aBoard, nullptr ); + } +} diff --git a/pcbnew/zone_filler.cpp b/pcbnew/zone_filler.cpp index b78fbe37fc..c0226e8c7f 100644 --- a/pcbnew/zone_filler.cpp +++ b/pcbnew/zone_filler.cpp @@ -79,6 +79,7 @@ void ZONE_FILLER::InstallNewProgressReporter( wxWindow* aParent, const wxString& void ZONE_FILLER::SetProgressReporter( PROGRESS_REPORTER* aReporter ) { m_progressReporter = aReporter; + wxASSERT_MSG( m_commit, "ZONE_FILLER must have a valid commit to call SetProgressReporter" ); } @@ -133,7 +134,8 @@ bool ZONE_FILLER::Fill( std::vector& aZones, bool aCheck, wxWin if( zone->GetIsRuleArea() ) continue; - m_commit->Modify( zone ); + if( m_commit ) + m_commit->Modify( zone ); // calculate the hash value for filled areas. it will be used later // to know if the current filled areas are up to date