From 8d6e75fce6600dc534f3e726591d59ecb16f9cca Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 4 Mar 2015 20:45:18 +0100 Subject: [PATCH] Fix 2 coverity warnings, and cleanup a old code in dialog_color_config. --- common/class_plotter.cpp | 6 +++- common/grid_tricks.cpp | 5 +++ eeschema/dialogs/dialog_color_config.cpp | 42 +++++------------------- eeschema/dialogs/dialog_color_config.h | 16 ++------- eeschema/operations_on_items_lists.cpp | 3 +- 5 files changed, 22 insertions(+), 50 deletions(-) diff --git a/common/class_plotter.cpp b/common/class_plotter.cpp index 12bbac2ed4..0503cfec93 100644 --- a/common/class_plotter.cpp +++ b/common/class_plotter.cpp @@ -54,12 +54,16 @@ PLOTTER::PLOTTER( ) defaultPenWidth = 0; currentPenWidth = -1; // To-be-set marker penState = 'Z'; // End-of-path idle - m_plotMirror = false; // Mirror flag + m_plotMirror = false; // Plot mirror option flag m_mirrorIsHorizontal = true; m_yaxisReversed = false; outputFile = 0; colorMode = false; // Starts as a BW plot negativeMode = false; + // Temporary init to avoid not initialized vars, will be set later + m_IUsPerDecimil = 1; // will be set later to the actual value + iuPerDeviceUnit = 1; // will be set later to the actual value + } PLOTTER::~PLOTTER() diff --git a/common/grid_tricks.cpp b/common/grid_tricks.cpp index 40801671e0..c854411ae6 100644 --- a/common/grid_tricks.cpp +++ b/common/grid_tricks.cpp @@ -50,6 +50,11 @@ enum GRID_TRICKS::GRID_TRICKS( wxGrid* aGrid ): m_grid( aGrid ) { + m_sel_row_start = 0; + m_sel_col_start = 0; + m_sel_row_count = 0; + m_sel_col_count = 0; + aGrid->Connect( wxEVT_GRID_CELL_RIGHT_CLICK, wxGridEventHandler( GRID_TRICKS::onGridCellRightClick ), NULL, this ); aGrid->Connect( MYID_FIRST, MYID_LAST, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GRID_TRICKS::onPopupSelection ), NULL, this ); aGrid->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( GRID_TRICKS::onKeyDown ), NULL, this ); diff --git a/eeschema/dialogs/dialog_color_config.cpp b/eeschema/dialogs/dialog_color_config.cpp index 210c4a9ed9..94bf021a51 100644 --- a/eeschema/dialogs/dialog_color_config.cpp +++ b/eeschema/dialogs/dialog_color_config.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2007 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or @@ -110,20 +110,17 @@ static BUTTONINDEX buttonGroups[] = { static EDA_COLOR_T currentColors[ LAYERSCH_ID_COUNT ]; -IMPLEMENT_DYNAMIC_CLASS( DIALOG_COLOR_CONFIG, wxDialog ) - - -DIALOG_COLOR_CONFIG::DIALOG_COLOR_CONFIG() -{ - Init(); -} - - -DIALOG_COLOR_CONFIG::DIALOG_COLOR_CONFIG( EDA_DRAW_FRAME* aParent ) +DIALOG_COLOR_CONFIG::DIALOG_COLOR_CONFIG( EDA_DRAW_FRAME* aParent ) : + DIALOG_SHIM( aParent, wxID_ANY, _( "EESchema Colors" ), + wxDefaultPosition, wxDefaultSize, + wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ) { m_parent = aParent; + SetExtraStyle( wxWS_EX_BLOCK_EVENTS ); Init(); - Create( aParent ); + CreateControls(); + + GetSizer()->SetSizeHints( this ); } @@ -132,27 +129,6 @@ DIALOG_COLOR_CONFIG::~DIALOG_COLOR_CONFIG() } -bool DIALOG_COLOR_CONFIG::Create( wxWindow* aParent, - wxWindowID aId, - const wxString& aCaption, - const wxPoint& aPosition, - const wxSize& aSize, - long aStyle ) -{ - SetExtraStyle( wxWS_EX_BLOCK_EVENTS ); - wxDialog::Create( aParent, aId, aCaption, aPosition, aSize, aStyle ); - - CreateControls(); - - if( GetSizer() ) - { - GetSizer()->SetSizeHints( this ); - } - - return true; -} - - void DIALOG_COLOR_CONFIG::Init() { m_outerBoxSizer = NULL; diff --git a/eeschema/dialogs/dialog_color_config.h b/eeschema/dialogs/dialog_color_config.h index 39c1a63709..0299c073fc 100644 --- a/eeschema/dialogs/dialog_color_config.h +++ b/eeschema/dialogs/dialog_color_config.h @@ -26,6 +26,7 @@ #define DIALOG_COLOR_CONFIG_H_ #include +#include class wxBoxSizer; @@ -33,18 +34,13 @@ class wxStaticLine; class wxStdDialogButtonSizer; -extern void SeedLayers(); - - /***********************************************/ /* Derived class for the frame color settings. */ /***********************************************/ -class DIALOG_COLOR_CONFIG : public wxDialog +class DIALOG_COLOR_CONFIG : public DIALOG_SHIM { private: - DECLARE_DYNAMIC_CLASS( DIALOG_COLOR_CONFIG ) - EDA_DRAW_FRAME* m_parent; wxBoxSizer* m_outerBoxSizer; wxBoxSizer* m_mainBoxSizer; @@ -55,14 +51,6 @@ private: wxStaticLine* m_line; wxStdDialogButtonSizer* m_stdDialogButtonSizer; - // Creation - bool Create( wxWindow* aParent, - wxWindowID aId = wxID_ANY, - const wxString& aCaption = _( "EESchema Colors" ), - const wxPoint& aPosition = wxDefaultPosition, - const wxSize& aSize = wxDefaultSize, - long aStyle = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ); - // Initializes member variables void Init(); diff --git a/eeschema/operations_on_items_lists.cpp b/eeschema/operations_on_items_lists.cpp index ed280717cc..89346b1958 100644 --- a/eeschema/operations_on_items_lists.cpp +++ b/eeschema/operations_on_items_lists.cpp @@ -159,8 +159,7 @@ void SCH_EDIT_FRAME::DeleteItem( SCH_ITEM* aItem ) { wxCHECK_RET( aItem != NULL, wxT( "Cannot delete invalid item." ) ); - if( aItem == NULL ) - return; + // Here, aItem is not null. SCH_SCREEN* screen = GetScreen();