diff --git a/common/tool/common_tools.cpp b/common/tool/common_tools.cpp index bed878c317..a3e1c5a445 100644 --- a/common/tool/common_tools.cpp +++ b/common/tool/common_tools.cpp @@ -264,20 +264,18 @@ int COMMON_TOOLS::doZoomFit( ZOOM_FIT_TYPE_T aFitType ) { KIGFX::VIEW* view = getView(); EDA_DRAW_PANEL_GAL* canvas = m_frame->GetCanvas(); - EDA_DRAW_FRAME* frame = getEditFrame(); + EDA_DRAW_FRAME* frame = getEditFrame(); BOX2I bBox = frame->GetDocumentExtents(); BOX2I defaultBox = canvas->GetDefaultViewBBox(); - VECTOR2D scrollbarSize = VECTOR2D( canvas->GetSize() - canvas->GetClientSize() ); view->SetScale( 1.0 ); // The best scale will be determined later, but this initial // value ensures all view parameters are up to date (especially // at init time) VECTOR2D screenSize = view->ToWorld( canvas->GetClientSize(), false ); - // Currently "Zoom to Objects" is only supported on Eeschema. Support for other + // Currently "Zoom to Objects" is only supported on Eeschema. Support for other // programs in the suite can be added as needed. - if( aFitType == ZOOM_FIT_OBJECTS ) { if( frame->IsType( FRAME_SCH ) ) @@ -287,7 +285,6 @@ int COMMON_TOOLS::doZoomFit( ZOOM_FIT_TYPE_T aFitType ) } // If the screen is empty then use the default view bbox - if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 ) bBox = defaultBox; @@ -302,7 +299,6 @@ int COMMON_TOOLS::doZoomFit( ZOOM_FIT_TYPE_T aFitType ) { case ZOOM_FIT_ALL: // Leave a bigger margin for library editors & viewers - if( frame->IsType( FRAME_FOOTPRINT_VIEWER ) || frame->IsType( FRAME_FOOTPRINT_VIEWER_MODAL ) || frame->IsType( FRAME_SCH_VIEWER ) || frame->IsType( FRAME_SCH_VIEWER_MODAL ) ) { diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index 6549967455..a2f6a1266a 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -343,7 +343,7 @@ int ERC_TESTER::TestMultiunitFootprints() const wxString secondFp = secondRef.GetFootprint(); wxString msg; - if( !secondFp.IsEmpty() && unitFP != secondFp ) + if( unit && !secondFp.IsEmpty() && unitFP != secondFp ) { msg.Printf( _( "Different footprints assigned to %s and %s" ), unitName, secondName ); diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 339dab4ce9..3288b62ce9 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -2117,7 +2117,7 @@ wxString BOARD::GroupsSanityCheckInternal( bool repair ) // This check of childIdx should never fail, because if a group // is not found in the groups list, then the board.GetItem() // check above should have failed. - wxCHECK( childIdx >= 0 && childIdx < groups.size(), + wxCHECK( childIdx < groups.size(), wxString::Format( "Group %s not found in groups list", item->m_Uuid.AsString() ) ); wxCHECK( parentGroupIdx[childIdx] == -1, diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 18b4bb7a93..b963deefb4 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -671,7 +671,6 @@ void VIA::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& wxString msg; wxString msg2; wxString source; - BOARD* board = GetBoard(); // Display basic infos switch( GetViaType() ) diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp index 0ebdf655f9..a486d19042 100644 --- a/pcbnew/dialogs/dialog_drc.cpp +++ b/pcbnew/dialogs/dialog_drc.cpp @@ -402,12 +402,15 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent ) { MARKER_PCB* marker = dynamic_cast( node->m_RcItem->GetParent() ); - marker->SetExcluded( false ); - m_brdEditor->GetCanvas()->GetView()->Update( marker ); + if( marker ) + { + marker->SetExcluded( false ); + m_brdEditor->GetCanvas()->GetView()->Update( marker ); - // Update view - static_cast( aEvent.GetModel() )->ValueChanged( node ); - modified = true; + // Update view + static_cast( aEvent.GetModel() )->ValueChanged( node ); + modified = true; + } } break; @@ -415,16 +418,19 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent ) { MARKER_PCB* marker = dynamic_cast( node->m_RcItem->GetParent() ); - marker->SetExcluded( true ); - m_brdEditor->GetCanvas()->GetView()->Update( marker ); + if( marker ) + { + marker->SetExcluded( true ); + m_brdEditor->GetCanvas()->GetView()->Update( marker ); - // Update view - if( m_severities & RPT_SEVERITY_EXCLUSION ) - static_cast( aEvent.GetModel() )->ValueChanged( node ); - else - static_cast( aEvent.GetModel() )->DeleteCurrentItem( false ); + // Update view + if( m_severities & RPT_SEVERITY_EXCLUSION ) + static_cast( aEvent.GetModel() )->ValueChanged( node ); + else + static_cast( aEvent.GetModel() )->DeleteCurrentItem( false ); - modified = true; + modified = true; + } } break; diff --git a/pcbnew/drc/drc_engine.cpp b/pcbnew/drc/drc_engine.cpp index c1960840b6..0f5ddb15fd 100644 --- a/pcbnew/drc/drc_engine.cpp +++ b/pcbnew/drc/drc_engine.cpp @@ -554,7 +554,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRulesForItems( DRC_CONSTRAINT_TYPE_T aConstraintI // Unfortunately implicit rules don't work for local clearances (such as zones) because // they have to be max'ed with netclass values (which are already implicit rules), and our // rule selection paradigm is "winner takes all". - if( aConstraintId == DRC_CONSTRAINT_TYPE_CLEARANCE && implicit ) + if( constraintRef && aConstraintId == DRC_CONSTRAINT_TYPE_CLEARANCE && implicit ) { int global = constraintRef->m_Value.Min(); int localA = connectedA ? connectedA->GetLocalClearance( nullptr ) : 0; diff --git a/pcbnew/tools/convert_tool.cpp b/pcbnew/tools/convert_tool.cpp index 95b061d695..10efa06ffb 100644 --- a/pcbnew/tools/convert_tool.cpp +++ b/pcbnew/tools/convert_tool.cpp @@ -532,7 +532,10 @@ int CONVERT_TOOL::SegmentToArc( const TOOL_EVENT& aEvent ) BOARD_ITEM_CONTAINER* parent = frame->GetModel(); BOARD_ITEM* boardItem = dynamic_cast( source ); - wxASSERT( boardItem ); + + // Don't continue processing if we don't actually have a board item + if( !boardItem ) + return 0; PCB_LAYER_ID layer = boardItem->GetLayer(); diff --git a/pcbnew/tools/drc_tool.cpp b/pcbnew/tools/drc_tool.cpp index 3858e84f18..3a769151df 100644 --- a/pcbnew/tools/drc_tool.cpp +++ b/pcbnew/tools/drc_tool.cpp @@ -208,7 +208,8 @@ void DRC_TOOL::RunTests( PROGRESS_REPORTER* aProgressReporter, bool aTestTracksA m_drcEngine->SetProgressReporter( nullptr ); m_drcEngine->ClearViolationHandler(); - m_drcDialog->SetDrcRun(); + if( m_drcDialog ) + m_drcDialog->SetDrcRun(); if( !netlist.IsEmpty() ) m_drcDialog->SetFootprintTestsRun(); diff --git a/pcbnew/tools/pcb_inspection_tool.cpp b/pcbnew/tools/pcb_inspection_tool.cpp index f6d0892b98..d2e78e690e 100644 --- a/pcbnew/tools/pcb_inspection_tool.cpp +++ b/pcbnew/tools/pcb_inspection_tool.cpp @@ -294,10 +294,9 @@ int PCB_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) r->Report( _( "Items belong to the same net. Clearance is 0." ) ); } } - else + else if( ac ) { // Different nets (or second unconnected).... - reportCopperClearance( layer, ac, b, r ); } } diff --git a/pcbnew/widgets/appearance_controls.cpp b/pcbnew/widgets/appearance_controls.cpp index 27b2c87115..a4b63e65f2 100644 --- a/pcbnew/widgets/appearance_controls.cpp +++ b/pcbnew/widgets/appearance_controls.cpp @@ -2173,7 +2173,7 @@ void APPEARANCE_CONTROLS::onLayerPresetChanged( wxCommandEvent& aEvent ) m_lastSelectedUserPreset = ( !preset || preset->readOnly ) ? nullptr : preset; - if( !preset ) + if( preset ) doApplyLayerPreset( *preset ); if( !m_currentPreset->name.IsEmpty() ) diff --git a/pcbnew/widgets/appearance_controls.h b/pcbnew/widgets/appearance_controls.h index c4a33df0d6..5ac752b361 100644 --- a/pcbnew/widgets/appearance_controls.h +++ b/pcbnew/widgets/appearance_controls.h @@ -161,27 +161,35 @@ public: APPEARANCE_SETTING( const wxString& aLabel, int aId, const wxString& aTooltip = wxEmptyString, - bool aCanControlOpacity = false ) + bool aCanControlOpacity = false ) : + id( aId ), + label( aLabel ), + tooltip( aTooltip ), + visible( true ), + can_control_opacity( aCanControlOpacity ), + spacer( false ), + ctl_panel( nullptr ), + ctl_indicator( nullptr ), + ctl_visibility( nullptr ), + ctl_color( nullptr ), + ctl_text( nullptr ), + ctl_opacity( nullptr ) { - label = aLabel; - id = aId; - tooltip = aTooltip; - spacer = false; - visible = true; - - can_control_opacity = aCanControlOpacity; - - ctl_panel = nullptr; - ctl_indicator = nullptr; - ctl_visibility = nullptr; - ctl_color = nullptr; - ctl_text = nullptr; - ctl_opacity = nullptr; } APPEARANCE_SETTING() : - id( -1 ), label( "" ), tooltip( "" ), visible( false ), - can_control_opacity( false ), spacer( true ) + id( -1 ), + label( "" ), + tooltip( "" ), + visible( false ), + can_control_opacity( false ), + spacer( true ), + ctl_panel( nullptr ), + ctl_indicator( nullptr ), + ctl_visibility( nullptr ), + ctl_color( nullptr ), + ctl_text( nullptr ), + ctl_opacity( nullptr ) { } };