Commit c1978b32 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: fix crash when undoing a move exact pad in board editor.

Fix also very minor warnings detected by cppcheck.
parent 014905e7
...@@ -35,9 +35,9 @@ ...@@ -35,9 +35,9 @@
// Conversion to application internal units defined at build time. // Conversion to application internal units defined at build time.
#if defined( PCBNEW ) #if defined( PCBNEW )
#include <class_board_item.h> #include <class_board_item.h> // for FMT_IU
#elif defined( EESCHEMA ) #elif defined( EESCHEMA )
#include <sch_item_struct.h> #include <sch_item_struct.h> // for FMT_IU
#elif defined( GERBVIEW ) #elif defined( GERBVIEW )
#elif defined( PL_EDITOR ) #elif defined( PL_EDITOR )
#include <base_units.h> #include <base_units.h>
......
...@@ -132,7 +132,7 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent ) ...@@ -132,7 +132,7 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
bool valExist = false; bool valExist = false;
// try to find component in existing list // try to find component in existing list
for( iter = list.begin(); iter != list.end(); iter++ ) for( iter = list.begin(); iter != list.end(); ++iter )
{ {
cmp* current = *iter; cmp* current = *iter;
......
...@@ -242,7 +242,7 @@ int BOARD_DESIGN_SETTINGS::GetBiggestClearanceValue() ...@@ -242,7 +242,7 @@ int BOARD_DESIGN_SETTINGS::GetBiggestClearanceValue()
int clearance = m_NetClasses.GetDefault()->GetClearance(); int clearance = m_NetClasses.GetDefault()->GetClearance();
//Read list of Net Classes //Read list of Net Classes
for( NETCLASSES::const_iterator nc = m_NetClasses.begin(); nc != m_NetClasses.end(); nc++ ) for( NETCLASSES::const_iterator nc = m_NetClasses.begin(); nc != m_NetClasses.end(); ++nc )
{ {
NETCLASSPTR netclass = nc->second; NETCLASSPTR netclass = nc->second;
clearance = std::max( clearance, netclass->GetClearance() ); clearance = std::max( clearance, netclass->GetClearance() );
...@@ -257,7 +257,7 @@ int BOARD_DESIGN_SETTINGS::GetSmallestClearanceValue() ...@@ -257,7 +257,7 @@ int BOARD_DESIGN_SETTINGS::GetSmallestClearanceValue()
int clearance = m_NetClasses.GetDefault()->GetClearance(); int clearance = m_NetClasses.GetDefault()->GetClearance();
//Read list of Net Classes //Read list of Net Classes
for( NETCLASSES::const_iterator nc = m_NetClasses.begin(); nc != m_NetClasses.end(); nc++ ) for( NETCLASSES::const_iterator nc = m_NetClasses.begin(); nc != m_NetClasses.end(); ++nc )
{ {
NETCLASSPTR netclass = nc->second; NETCLASSPTR netclass = nc->second;
clearance = std::min( clearance, netclass->GetClearance() ); clearance = std::min( clearance, netclass->GetClearance() );
......
...@@ -145,9 +145,7 @@ MODULE::MODULE( const MODULE& aModule ) : ...@@ -145,9 +145,7 @@ MODULE::MODULE( const MODULE& aModule ) :
if( item->GetShape3DName().IsEmpty() ) // do not copy empty shapes. if( item->GetShape3DName().IsEmpty() ) // do not copy empty shapes.
continue; continue;
S3D_MASTER* t3d = m_3D_Drawings; S3D_MASTER* t3d = new S3D_MASTER( this );
t3d = new S3D_MASTER( this );
t3d->Copy( item ); t3d->Copy( item );
m_3D_Drawings.PushBack( t3d ); m_3D_Drawings.PushBack( t3d );
} }
......
...@@ -120,10 +120,10 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, ...@@ -120,10 +120,10 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)frame->GetDisplayOptions(); DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)frame->GetDisplayOptions();
PCB_SCREEN* screen = frame->GetScreen(); PCB_SCREEN* screen = frame->GetScreen();
if( displ_opts->m_DisplayPadFill == FILLED ) if( displ_opts && displ_opts->m_DisplayPadFill == SKETCH )
drawInfo.m_ShowPadFilled = true;
else
drawInfo.m_ShowPadFilled = false; drawInfo.m_ShowPadFilled = false;
else
drawInfo.m_ShowPadFilled = true;
EDA_COLOR_T color = BLACK; EDA_COLOR_T color = BLACK;
if( m_layerMask[F_Cu] ) if( m_layerMask[F_Cu] )
......
...@@ -1516,8 +1516,14 @@ void PCB_EDIT_FRAME::moveExact() ...@@ -1516,8 +1516,14 @@ void PCB_EDIT_FRAME::moveExact()
{ {
BOARD_ITEM* item = GetScreen()->GetCurItem(); BOARD_ITEM* item = GetScreen()->GetCurItem();
// When a pad is modified, the full footprint is saved
BOARD_ITEM* itemToSave = item;
if( item->Type() == PCB_PAD_T )
itemToSave = item->GetParent();
// Could be moved or rotated // Could be moved or rotated
SaveCopyInUndoList( item, UR_CHANGED ); SaveCopyInUndoList( itemToSave, UR_CHANGED );
item->Move( translation ); item->Move( translation );
item->Rotate( item->GetPosition(), rotation ); item->Rotate( item->GetPosition(), rotation );
......
...@@ -361,9 +361,9 @@ bool EXCELLON_WRITER::GenDrillReportFile( const wxString& aFullFileName ) ...@@ -361,9 +361,9 @@ bool EXCELLON_WRITER::GenDrillReportFile( const wxString& aFullFileName )
} }
if( gen_NPTH_holes ) if( gen_NPTH_holes )
sprintf( line, "\nTotal unplated holes count %d\n\n\n", totalHoleCount ); sprintf( line, "\nTotal unplated holes count %u\n\n\n", totalHoleCount );
else else
sprintf( line, "\nTotal plated holes count %d\n\n\n", totalHoleCount ); sprintf( line, "\nTotal plated holes count %u\n\n\n", totalHoleCount );
fputs( line, m_file ); fputs( line, m_file );
......
...@@ -91,8 +91,7 @@ void PCB_EDIT_FRAME::CallMacros( wxDC* aDC, const wxPoint& aPosition, int aNumbe ...@@ -91,8 +91,7 @@ void PCB_EDIT_FRAME::CallMacros( wxDC* aDC, const wxPoint& aPosition, int aNumbe
GeneralControl( aDC, tPosition ); GeneralControl( aDC, tPosition );
for( std::list<MACROS_RECORD>::iterator i = m_Macros[aNumber].m_Record.begin(); for( std::list<MACROS_RECORD>::iterator i = m_Macros[aNumber].m_Record.begin();
i != m_Macros[aNumber].m_Record.end(); i != m_Macros[aNumber].m_Record.end(); ++i )
i++ )
{ {
wxPoint tmpPos = GetNearestGridPosition( tPosition + i->m_Position ); wxPoint tmpPos = GetNearestGridPosition( tPosition + i->m_Position );
......
...@@ -447,7 +447,7 @@ void DXF2BRD_CONVERTER::addHeader( const DRW_Header* data ) ...@@ -447,7 +447,7 @@ void DXF2BRD_CONVERTER::addHeader( const DRW_Header* data )
{ {
std::map<std::string, DRW_Variant*>::const_iterator it; std::map<std::string, DRW_Variant*>::const_iterator it;
for( it = data->vars.begin(); it != data->vars.end(); it++ ) for( it = data->vars.begin(); it != data->vars.end(); ++it )
{ {
std::string key = ( (*it).first ).c_str(); std::string key = ( (*it).first ).c_str();
......
...@@ -238,9 +238,9 @@ void PCB_EDIT_FRAME::ReCreateHToolbar() ...@@ -238,9 +238,9 @@ void PCB_EDIT_FRAME::ReCreateHToolbar()
m_mainToolBar->AddSeparator(); m_mainToolBar->AddSeparator();
msg = AddHotkeyName( HELP_UNDO, g_Board_Editor_Hokeys_Descr, HK_UNDO, IS_COMMENT ); msg = AddHotkeyName( HELP_UNDO, g_Board_Editor_Hokeys_Descr, HK_UNDO, IS_COMMENT );
m_mainToolBar->AddTool( wxID_UNDO, wxEmptyString, KiBitmap( undo_xpm ), HELP_UNDO ); m_mainToolBar->AddTool( wxID_UNDO, wxEmptyString, KiBitmap( undo_xpm ), msg );
msg = AddHotkeyName( HELP_REDO, g_Board_Editor_Hokeys_Descr, HK_REDO, IS_COMMENT ); msg = AddHotkeyName( HELP_REDO, g_Board_Editor_Hokeys_Descr, HK_REDO, IS_COMMENT );
m_mainToolBar->AddTool( wxID_REDO, wxEmptyString, KiBitmap( redo_xpm ), HELP_REDO ); m_mainToolBar->AddTool( wxID_REDO, wxEmptyString, KiBitmap( redo_xpm ), msg );
m_mainToolBar->AddSeparator(); m_mainToolBar->AddSeparator();
m_mainToolBar->AddTool( wxID_PRINT, wxEmptyString, KiBitmap( print_button_xpm ), m_mainToolBar->AddTool( wxID_PRINT, wxEmptyString, KiBitmap( print_button_xpm ),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment