Fix a few Coverity warnings.

Mainly not initialized members, and replace not tested dynamic_cast by static_cast.
This commit is contained in:
jean-pierre charras 2019-01-03 17:49:25 +01:00
parent 25f8b1ce72
commit db7dba96ad
11 changed files with 47 additions and 18 deletions

View File

@ -27,7 +27,8 @@ DIALOG_EDIT_LIBRARY_TABLES::DIALOG_EDIT_LIBRARY_TABLES( wxWindow* aParent,
DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, wxDefaultSize, DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
m_GlobalTableChanged( false ), m_GlobalTableChanged( false ),
m_ProjectTableChanged( false ) m_ProjectTableChanged( false ),
m_contentPanel( nullptr )
{ {
// Construction delayed until after panel is installed // Construction delayed until after panel is installed
} }

View File

@ -120,6 +120,7 @@ CAIRO_PRINT_GAL::CAIRO_PRINT_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions,
cairo_reference( context ); cairo_reference( context );
cairo_surface_reference( surface ); cairo_surface_reference( surface );
m_clearColor = COLOR4D( 1.0, 1.0, 1.0, 1.0 ); m_clearColor = COLOR4D( 1.0, 1.0, 1.0, 1.0 );
m_hasNativeLandscapeRotation = false;
resetContext(); resetContext();
SetScreenDPI( m_printCtx->GetNativeDPI() ); SetScreenDPI( m_printCtx->GetNativeDPI() );
} }

View File

@ -447,7 +447,7 @@ void SCH_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
} }
} }
auto painter = dynamic_cast<KIGFX::SCH_PAINTER*>( GetCanvas()->GetView()->GetPainter() ); auto painter = static_cast<KIGFX::SCH_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
KIGFX::SCH_RENDER_SETTINGS* settings = painter->GetSettings(); KIGFX::SCH_RENDER_SETTINGS* settings = painter->GetSettings();
settings->m_ShowPinsElectricalType = false; settings->m_ShowPinsElectricalType = false;
settings->m_ShowHiddenText = false; settings->m_ShowHiddenText = false;

View File

@ -607,7 +607,7 @@ void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel,
EDA_DRAW_FRAME* frame = aPanel->GetParent(); EDA_DRAW_FRAME* frame = aPanel->GetParent();
if( frame->IsType( FRAME_SCH ) ) if( frame->IsType( FRAME_SCH ) )
drawHidden = dynamic_cast<SCH_EDIT_FRAME*>( frame )->GetShowAllPins(); drawHidden = static_cast<SCH_EDIT_FRAME*>( frame )->GetShowAllPins();
else if( frame->IsType( FRAME_SCH_LIB_EDITOR ) ) else if( frame->IsType( FRAME_SCH_LIB_EDITOR ) )
drawHidden = true; // must be able to edit drawHidden = true; // must be able to edit
} }

View File

@ -101,7 +101,7 @@ void LIB_EDIT_FRAME::BlockMoveSelectedItems( const wxPoint& aOffset, LIB_PART* a
item.ClearFlags(); item.ClearFlags();
} }
// view update // view update
} }
@ -140,7 +140,7 @@ void LIB_EDIT_FRAME::BlockCopySelectedItems( const wxPoint& aOffset, LIB_PART* a
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ ) for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{ {
oldItem = dynamic_cast<LIB_ITEM*>( aItemsList.GetPickedItem( ii ) ); oldItem = static_cast<LIB_ITEM*>( aItemsList.GetPickedItem( ii ) );
// We *do not* copy fields because they are unique for the whole component // We *do not* copy fields because they are unique for the whole component
// so skip them (do not duplicate) if they are flagged selected. // so skip them (do not duplicate) if they are flagged selected.
@ -388,7 +388,7 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
{ {
if( block->GetCommand() != BLOCK_SELECT_ITEMS_ONLY && GetCurPart() ) if( block->GetCommand() != BLOCK_SELECT_ITEMS_ONLY && GetCurPart() )
BlockClearSelectedItems( GetCurPart(), block ); BlockClearSelectedItems( GetCurPart(), block );
GetScreen()->ClearBlockCommand(); GetScreen()->ClearBlockCommand();
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
m_canvas->EndMouseCapture( GetToolId(), GetGalCanvas()->GetCurrentCursor(), wxEmptyString, m_canvas->EndMouseCapture( GetToolId(), GetGalCanvas()->GetCurrentCursor(), wxEmptyString,
@ -461,7 +461,7 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
block->SetCommand( BLOCK_IDLE ); block->SetCommand( BLOCK_IDLE );
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
m_canvas->EndMouseCapture( GetToolId(), GetGalCanvas()->GetCurrentCursor(), wxEmptyString, false ); m_canvas->EndMouseCapture( GetToolId(), GetGalCanvas()->GetCurrentCursor(), wxEmptyString, false );
GetCanvas()->GetView()->ClearPreview(); GetCanvas()->GetView()->ClearPreview();
GetCanvas()->GetView()->ClearHiddenFlags(); GetCanvas()->GetView()->ClearHiddenFlags();
} }
@ -566,7 +566,7 @@ void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
return; return;
block->SetMoveVector( frame->GetCrossHairPosition( true ) - block->GetLastCursorPosition() ); block->SetMoveVector( frame->GetCrossHairPosition( true ) - block->GetLastCursorPosition() );
preview->Clear(); preview->Clear();
view->SetVisible( preview, true ); view->SetVisible( preview, true );

View File

@ -1195,7 +1195,7 @@ void LIB_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
for( unsigned ii = 0; ii < block.GetCount(); ii++ ) for( unsigned ii = 0; ii < block.GetCount(); ii++ )
{ {
item = dynamic_cast<LIB_ITEM*>( block.GetItem( ii ) ); item = static_cast<LIB_ITEM*>( block.GetItem( ii ) );
item->Rotate( rotationPoint ); item->Rotate( rotationPoint );
} }
@ -1254,7 +1254,7 @@ void LIB_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
for( unsigned ii = 0; ii < block.GetCount(); ii++ ) for( unsigned ii = 0; ii < block.GetCount(); ii++ )
{ {
item = dynamic_cast<LIB_ITEM*>( block.GetItem( ii ) ); item = static_cast<LIB_ITEM*>( block.GetItem( ii ) );
if( aEvent.GetId() == ID_LIBEDIT_MIRROR_Y || aEvent.GetId() == ID_POPUP_MIRROR_Y_BLOCK ) if( aEvent.GetId() == ID_LIBEDIT_MIRROR_Y || aEvent.GetId() == ID_POPUP_MIRROR_Y_BLOCK )
item->MirrorHorizontal( mirrorPoint ); item->MirrorHorizontal( mirrorPoint );

View File

@ -60,10 +60,14 @@ namespace KIGFX
{ {
SCH_RENDER_SETTINGS::SCH_RENDER_SETTINGS() : SCH_RENDER_SETTINGS::SCH_RENDER_SETTINGS() :
m_ShowUnit( 0 ), m_ShowUnit( 0 ), m_ShowConvert( 0 )
m_ShowConvert( 0 )
{ {
ImportLegacyColors( nullptr ); ImportLegacyColors( nullptr );
m_ShowHiddenText = true;
m_ShowHiddenPins = true;
m_ShowPinsElectricalType = true;
m_ShowUmbilicals = true;
} }

View File

@ -1532,6 +1532,9 @@ size_t SCH_SCREENS::GetLibNicknames( wxArrayString& aLibNicknames )
symbol = dynamic_cast< SCH_COMPONENT* >( item ); symbol = dynamic_cast< SCH_COMPONENT* >( item );
wxASSERT( symbol ); wxASSERT( symbol );
if( !symbol )
continue;
nickname = symbol->GetLibId().GetLibNickname(); nickname = symbol->GetLibId().GetLibNickname();
if( !nickname.empty() && ( aLibNicknames.Index( nickname ) == wxNOT_FOUND ) ) if( !nickname.empty() && ( aLibNicknames.Index( nickname ) == wxNOT_FOUND ) )

View File

@ -84,7 +84,26 @@ protected:
public: public:
EDA_DRAW_PANEL(){}; EDA_DRAW_PANEL() :
m_showCrossHair( true ),
m_cursorLevel( 0 ),
m_scrollIncrementX( 1 ),
m_scrollIncrementY( 1 ),
m_abortRequest( false ),
m_enableZoomNoCenter( false ),
m_enableMousewheelPan( false ),
m_enableAutoPan( false ),
m_ignoreMouseEvents( false ),
m_ignoreNextLeftButtonRelease( false ),
m_enableBlockCommands( true ),
m_minDragEventCount( 5 ),
m_PrintIsMirrored( false ),
m_mouseCaptureCallback( nullptr ),
m_endMouseCaptureCallback( nullptr ),
m_canStartBlock( true ),
m_doubleClickInterval( 0 )
{};
virtual ~EDA_DRAW_PANEL(){}; virtual ~EDA_DRAW_PANEL(){};
/** /**

View File

@ -183,11 +183,12 @@ void DIALOG_POSITION_RELATIVE::OnUseUserOriginClick( wxCommandEvent& event )
void DIALOG_POSITION_RELATIVE::UpdateAnchor( EDA_ITEM* aItem ) void DIALOG_POSITION_RELATIVE::UpdateAnchor( EDA_ITEM* aItem )
{ {
wxString reference = _( "<none selected>" ); wxString reference = _( "<none selected>" );
BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( aItem );
if( aItem ) if( item )
{ {
m_anchor_position = dynamic_cast<BOARD_ITEM*>( aItem )->GetPosition(); m_anchor_position = item->GetPosition();
reference = aItem->GetSelectMenuText( GetUserUnits() ); reference = item->GetSelectMenuText( GetUserUnits() );
} }
m_referenceInfo->SetLabel( wxString::Format( "Reference item: %s", reference ) ); m_referenceInfo->SetLabel( wxString::Format( "Reference item: %s", reference ) );

View File

@ -598,9 +598,9 @@ wxString PANEL_SETUP_LAYERS::getLayerName( LAYER_NUM aLayer )
wxControl* control = getName( aLayer ); wxControl* control = getName( aLayer );
if( dynamic_cast<wxTextCtrl*>( control ) ) if( dynamic_cast<wxTextCtrl*>( control ) )
return dynamic_cast<wxTextCtrl*>( control )->GetValue().Trim(); return static_cast<wxTextCtrl*>( control )->GetValue().Trim();
else else
return dynamic_cast<wxStaticText*>( control )->GetLabel(); return static_cast<wxStaticText*>( control )->GetLabel();
} }