Coverity fixes

CIDs:
102571
168696
168701
168704
168706
168708
168710
168713
168716
168717
This commit is contained in:
Maciej Suminski 2017-11-01 10:20:13 +01:00
parent 83cf726cd6
commit 5eb56dd8b0
10 changed files with 53 additions and 27 deletions

View File

@ -934,10 +934,6 @@ ECONNECT::ECONNECT( wxXmlNode* aConnect )
gate = parseRequiredAttribute<string>( aConnect, "gate" );
pin = parseRequiredAttribute<string>( aConnect, "pin" );
pad = parseRequiredAttribute<string>( aConnect, "pad" );
//TODO:
//int contactroute;
};

View File

@ -69,7 +69,8 @@ OPENGL_GAL::OPENGL_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions, wxWindow* aParent,
GAL( aDisplayOptions ),
wxGLCanvas( aParent, wxID_ANY, (int*) glAttributes, wxDefaultPosition, wxDefaultSize,
wxEXPAND, aName ),
mouseListener( aMouseListener ), paintListener( aPaintListener )
mouseListener( aMouseListener ), paintListener( aPaintListener ), currentManager( nullptr ),
cachedManager( nullptr ), nonCachedManager( nullptr ), overlayManager( nullptr )
{
if( glMainContext == NULL )
{
@ -1537,6 +1538,7 @@ int OPENGL_GAL::drawBitmapChar( unsigned long aChar )
const float TEX_Y = font_image.height;
const FONT_GLYPH_TYPE* glyph = LookupGlyph(aChar);
wxASSERT( glyph );
if( !glyph ) return 0;
@ -1592,6 +1594,11 @@ void OPENGL_GAL::drawBitmapOverbar( double aLength, double aHeight )
{
// To draw an overbar, simply draw an overbar
const FONT_GLYPH_TYPE* glyph = LookupGlyph( '_' );
wxASSERT( glyph );
if( !glyph )
return;
const float H = glyph->maxy - glyph->miny;
Save();
@ -1642,6 +1649,7 @@ std::pair<VECTOR2D, float> OPENGL_GAL::computeBitmapTextSize( const wxString& aT
unsigned int c = aText[i];
const FONT_GLYPH_TYPE* glyph = LookupGlyph( c );
wxASSERT( glyph );
// a few chars
if( !glyph || // Not coded in font

View File

@ -30,16 +30,17 @@
WIDGET_NET_SELECTOR::WIDGET_NET_SELECTOR (wxWindow *parent, wxWindowID id, const wxString &value, const wxPoint &pos, const wxSize &size,
int n, const wxString choices[], long style, const wxValidator &validator, const wxString &name ) :
wxComboBox ( parent, id, value, pos, size, n, choices, style, validator, name )
wxComboBox( parent, id, value, pos, size, n, choices, style, validator, name ),
m_multiple( false )
{
}
WIDGET_NET_SELECTOR::~WIDGET_NET_SELECTOR()
{
}
void WIDGET_NET_SELECTOR::SetMultiple( bool aMultiple )
{
if ( aMultiple )
@ -51,6 +52,7 @@ void WIDGET_NET_SELECTOR::SetMultiple( bool aMultiple )
}
}
void WIDGET_NET_SELECTOR::SetSelectedNet ( int aNetcode )
{
for( const auto& n : m_nets )
@ -63,9 +65,11 @@ void WIDGET_NET_SELECTOR::SetSelectedNet ( int aNetcode )
}
}
int WIDGET_NET_SELECTOR::GetSelectedNet()
{
int pos = GetSelection();
for( const auto& n : m_nets )
{
if( n.pos == pos )
@ -75,6 +79,7 @@ int WIDGET_NET_SELECTOR::GetSelectedNet()
return 0;
}
bool WIDGET_NET_SELECTOR::IsUniqueNetSelected() const
{
if( m_multiple && ( GetSelection() == ( (int)GetCount() - 1 ) ) )
@ -83,16 +88,17 @@ bool WIDGET_NET_SELECTOR::IsUniqueNetSelected() const
return true;
}
void WIDGET_NET_SELECTOR::SetBoard( BOARD* aBoard )
{
auto& netinfo = aBoard->GetNetInfo();
Append( wxT( "<no net>" ));
Append( wxT( "<no net>" ) );
for(unsigned i = 1; i < netinfo.GetNetCount(); i++)
for( unsigned i = 1; i < netinfo.GetNetCount(); i++ )
{
NETINFO_ITEM *ni = netinfo.GetNetItem(i);
NET n;
NETINFO_ITEM* ni = netinfo.GetNetItem( i );
NET n;
n.name = ni->GetNetname();
n.code = i;
m_nets.push_back( n );
@ -100,7 +106,7 @@ void WIDGET_NET_SELECTOR::SetBoard( BOARD* aBoard )
std::sort( m_nets.begin(), m_nets.end() );
for ( auto& n : m_nets )
for( auto& n : m_nets )
{
n.pos = Append( n.name );
}

View File

@ -81,8 +81,14 @@ bool WX_UNIT_BINDER::Valid() const
void WX_UNIT_BINDER::Enable( bool aEnable )
{
wxWindow* wxWin = dynamic_cast<wxWindow*> ( m_textEntry );
wxWin->Enable( aEnable );
wxWindow* wxWin = dynamic_cast<wxWindow*>( m_textEntry );
wxASSERT( wxWin );
// Most text input entry widgets inherit from wxTextEntry and wxWindow, so it should be fine.
// Still, it is better to be safe than sorry.
if( wxWin )
wxWin->Enable( aEnable );
m_unitLabel->Enable( aEnable );
}

View File

@ -278,7 +278,10 @@ static void eagleToKicadAlignment( EDA_TEXT* aText, int aEagleAlignment,
SCH_EAGLE_PLUGIN::SCH_EAGLE_PLUGIN()
{
m_kiway = nullptr;
m_rootSheet = nullptr;
m_currentSheet = nullptr;
m_partlib = nullptr;
}
@ -480,7 +483,6 @@ void SCH_EAGLE_PLUGIN::loadSchematic( wxXmlNode* aSchematicNode )
int sheet_count = countChildren( schematicChildren["sheets"], "sheet" );
// If eagle schematic has multiple sheets.
if( sheet_count > 1 )
{
int x, y, i;
@ -497,20 +499,19 @@ void SCH_EAGLE_PLUGIN::loadSchematic( wxXmlNode* aSchematicNode )
sheet->SetTimeStamp( GetNewTimeStamp() - i ); // minus the sheet index to make it unique.
sheet->SetParent( m_rootSheet->GetScreen() );
sheet->SetScreen( screen );
sheet->GetScreen()->SetFileName( sheet->GetFileName() );
m_currentSheet = sheet.get();
sheet->GetScreen()->SetFileName( sheet->GetFileName() );
m_rootSheet->GetScreen()->Append( sheet.release() );
loadSheet( sheetNode, i );
m_rootSheet->GetScreen()->Append( sheet.release() );
sheetNode = sheetNode->GetNext();
x += 2;
if( x > 10 )
if( x > 10 ) // start next row
{
x = 1;
y += 2;
x = 1;
y += 2;
}
i++;

View File

@ -128,7 +128,7 @@ double AM_PARAM::GetValue( const D_CODE* aDcode ) const
default:
wxLogDebug( "AM_PARAM::GetValue(): dcode %d prm %d/%d: unexpected type %d",
aDcode->m_Num_Dcode, ii, m_paramStack.size(), item.GetType() );
aDcode ? aDcode->m_Num_Dcode : -1, ii, m_paramStack.size(), item.GetType() );
break;
}
}

View File

@ -981,7 +981,7 @@ struct ECONNECT
string gate;
string pin;
string pad;
int contactroute;
//int contactroute; // TODO
ECONNECT( wxXmlNode* aConnect );
};

View File

@ -69,6 +69,11 @@ void TEXTE_PCB::SetTextAngle( double aAngle )
void TEXTE_PCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
GR_DRAWMODE DrawMode, const wxPoint& offset )
{
wxASSERT( panel );
if( !panel )
return;
BOARD* brd = GetBoard();
if( brd->IsLayerVisible( m_Layer ) == false )
@ -78,8 +83,7 @@ void TEXTE_PCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
auto color = frame->Settings().Colors().GetLayerColor( m_Layer );
EDA_DRAW_MODE_T fillmode = FILLED;
DISPLAY_OPTIONS* displ_opts =
panel ? (DISPLAY_OPTIONS*)panel->GetDisplayOptions() : NULL;
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions();
if( displ_opts && displ_opts->m_DisplayDrawItemsFill == SKETCH )
fillmode = SKETCH;

View File

@ -41,7 +41,10 @@ CLIPBOARD_IO::CLIPBOARD_IO():
}
CLIPBOARD_IO::~CLIPBOARD_IO(){}
CLIPBOARD_IO::~CLIPBOARD_IO()
{
delete m_parser;
}
STRING_FORMATTER* CLIPBOARD_IO::GetFormatter()
@ -303,6 +306,7 @@ BOARD* CLIPBOARD_IO::Load( const wxString& aFileName,
{
board = dynamic_cast<BOARD*>( item );
}
// Give the filename to the board if it's new
if( !aAppendToMe )
board->SetFileName( aFileName );

View File

@ -37,6 +37,7 @@ DRAGGER::DRAGGER( ROUTER* aRouter ) :
m_dragStatus = false;
m_currentMode = RM_MarkObstacles;
m_initialVia = NULL;
m_freeAngleMode = false;
}