From b1160660d95729eb6961777603a1e200ca17d891 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Mon, 21 Sep 2020 12:32:30 +0100 Subject: [PATCH] Check return value for zone fill in VRML exporter If the zone fill failed, then don't add the zone to the exported VRML because it might not be correct. Also test that the Python command in DIALOG_SCRIPTING worked. This dialog actually isn't used anywhere currently, so it could in theory be removed - but it is simple enough and it provides a decent testing dialog that it is more work to remove it. --- pcbnew/dialogs/dialog_scripting.cpp | 7 ++++--- pcbnew/exporters/export_vrml.cpp | 7 ++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pcbnew/dialogs/dialog_scripting.cpp b/pcbnew/dialogs/dialog_scripting.cpp index 25beb5d36a..426bf5fc8c 100644 --- a/pcbnew/dialogs/dialog_scripting.cpp +++ b/pcbnew/dialogs/dialog_scripting.cpp @@ -48,7 +48,8 @@ DIALOG_SCRIPTING::DIALOG_SCRIPTING( wxWindow* parent ) void DIALOG_SCRIPTING::OnRunButtonClick( wxCommandEvent& event ) { wxCharBuffer buffer = m_txScript->GetValue().ToUTF8(); - PyRun_SimpleString(buffer.data()); + int retv = PyRun_SimpleString( buffer.data()) ; + + if( retv != 0 ) + wxLogError( "Python error %d occurred running command:\n\n`%s`", retv, buffer ); } - - diff --git a/pcbnew/exporters/export_vrml.cpp b/pcbnew/exporters/export_vrml.cpp index c6dab06a4a..1961888717 100644 --- a/pcbnew/exporters/export_vrml.cpp +++ b/pcbnew/exporters/export_vrml.cpp @@ -1017,7 +1017,10 @@ static void export_vrml_zones( MODEL_VRML& aModel, BOARD* aPcb, COMMIT* aCommit { ZONE_FILLER filler( aPcb, aCommit ); zone->SetFillMode( ZONE_FILL_MODE::POLYGONS ); // use filled polygons - filler.Fill( { zone } ); + + // If the zone fill failed, don't try adding it to the export + if( !filler.Fill( { zone } ) ) + continue; } const SHAPE_POLY_SET& poly = zone->GetFilledPolysList( layer ); @@ -1032,7 +1035,9 @@ static void export_vrml_zones( MODEL_VRML& aModel, BOARD* aPcb, COMMIT* aCommit { if( !vl->AddVertex( seg, (double) outline.CPoint( j ).x * BOARD_SCALE, -( (double) outline.CPoint( j ).y * BOARD_SCALE ) ) ) + { throw( std::runtime_error( vl->GetError() ) ); + } } vl->EnsureWinding( seg, false );