A little bit of nullptr safety.

Fixes https://gitlab.com/kicad/code/kicad/issues/11077
This commit is contained in:
Jeff Young 2022-03-21 19:40:17 +00:00
parent 2fed8aa4b8
commit b3ae0fdca5
1 changed files with 13 additions and 9 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@ -309,9 +309,12 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow()
if( !DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::TransferDataFromWindow() )
return false;
int layer = m_LayerSelectionCtrl->GetLayerSelection();
if( !m_item )
return true;
int layer = m_LayerSelectionCtrl->GetLayerSelection();
BOARD_COMMIT commit( m_parent );
commit.Modify( m_item );
if( m_flipStartEnd && m_item->GetShape() != SHAPE_T::ARC )
@ -327,7 +330,7 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow()
if( m_item->GetShape() == SHAPE_T::CIRCLE )
{
m_item->SetEnd( m_item->GetStart() + wxPoint( m_endX.GetValue(), 0 ) );
m_item->SetEnd( m_item->GetStart() + VECTOR2I( m_endX.GetValue(), 0 ) );
}
else if( m_flipStartEnd && m_item->GetShape() != SHAPE_T::ARC )
{
@ -343,26 +346,27 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow()
// For Bezier curve: Set the two control points
if( m_item->GetShape() == SHAPE_T::BEZIER )
{
m_item->SetBezierC1( wxPoint( m_bezierCtrl1X.GetValue(), m_bezierCtrl1Y.GetValue() ) );
m_item->SetBezierC2( wxPoint( m_bezierCtrl2X.GetValue(), m_bezierCtrl2Y.GetValue() ) );
m_item->SetBezierC1( VECTOR2I( m_bezierCtrl1X.GetValue(), m_bezierCtrl1Y.GetValue() ) );
m_item->SetBezierC2( VECTOR2I( m_bezierCtrl2X.GetValue(), m_bezierCtrl2Y.GetValue() ) );
}
if( m_item->GetShape() == SHAPE_T::ARC )
{
VECTOR2D center = CalcArcCenter( m_item->GetStart(), m_item->GetEnd(), m_angle.GetAngleValue() );
VECTOR2D c = CalcArcCenter( m_item->GetStart(), m_item->GetEnd(), m_angle.GetAngleValue() );
m_item->SetCenter( center );
m_item->SetCenter( c );
}
if( m_fp_item )
{
// We are editing a footprint; init the item coordinates relative to the footprint anchor.
m_fp_item->SetStart0( m_fp_item->GetStart() );
m_fp_item->SetEnd0( m_fp_item->GetEnd() );
if( m_item->GetShape() == SHAPE_T::ARC )
if( m_fp_item->GetShape() == SHAPE_T::ARC )
m_fp_item->SetCenter0( m_fp_item->GetCenter() );
if( m_item->GetShape() == SHAPE_T::BEZIER )
if( m_fp_item->GetShape() == SHAPE_T::BEZIER )
{
m_fp_item->SetBezierC1_0( m_fp_item->GetBezierC1() );
m_fp_item->SetBezierC2_0( m_fp_item->GetBezierC2() );