From 10d67ffbd9d38845f221ca806a6609380fc6a893 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 26 Feb 2015 11:33:15 +0100 Subject: [PATCH] Fix some coverity warnings (not initialized members). Add comments. Better (more informative) title in dialog to download .pretty libs. --- 3d-viewer/3d_canvas.cpp | 12 ++++++++++ 3d-viewer/3d_canvas.h | 5 +++-- 3d-viewer/info3d_visu.cpp | 1 + common/class_bitmap_base.cpp | 1 + common/common_plotDXF_functions.cpp | 22 +++++++++++++++++++ common/common_plotHPGL_functions.cpp | 2 ++ eeschema/dialogs/dialog_plot_schematic.h | 2 +- eeschema/plot_schematic_PDF.cpp | 2 +- gerbview/class_GERBER.cpp | 9 ++++++-- .../dialogs/dialog_print_using_printer.cpp | 7 +++--- gerbview/gerbview_frame.h | 1 + include/plot_common.h | 8 +++++-- lib_dxf/drw_base.h | 1 + lib_dxf/libdxfrw.cpp | 2 ++ pagelayout_editor/events_functions.cpp | 1 + pagelayout_editor/pl_editor_frame.cpp | 1 + pcbnew/dialogs/wizard_add_fplib.cpp | 2 +- 17 files changed, 66 insertions(+), 13 deletions(-) diff --git a/3d-viewer/3d_canvas.cpp b/3d-viewer/3d_canvas.cpp index f59e631224..f86924a4ca 100644 --- a/3d-viewer/3d_canvas.cpp +++ b/3d-viewer/3d_canvas.cpp @@ -80,6 +80,18 @@ EDA_3D_CANVAS::EDA_3D_CANVAS( EDA_3D_FRAME* parent, int* attribList ) : { m_init = false; m_shadow_init = false; + // set an invalide value to not yet initialized indexes managing + // textures created to enhance 3D rendering + // (they are dummy values but we do not want uninitialized values) + m_text_pcb = m_text_silk = -1; + m_text_fake_shadow_front = -1; + m_text_fake_shadow_back = -1; + m_text_fake_shadow_board = -1; + + // position of the front and back layers + // (will be initialized to a better value later) + m_ZBottom = 0.0; + m_ZTop = 0.0; // Clear all gl list identifiers: for( int ii = GL_ID_BEGIN; ii < GL_ID_END; ii++ ) diff --git a/3d-viewer/3d_canvas.h b/3d-viewer/3d_canvas.h index bb338409c7..6c6cdc86d7 100644 --- a/3d-viewer/3d_canvas.h +++ b/3d-viewer/3d_canvas.h @@ -83,9 +83,10 @@ private: double m_ZBottom; // position of the back layer double m_ZTop; // position of the front layer - GLuint m_text_pcb; - GLuint m_text_silk; + GLuint m_text_pcb; // an index to the texture generated for pcb texts + GLuint m_text_silk; // an index to the texture generated for silk layers + // Index to the textures generated for shadows bool m_shadow_init; GLuint m_text_fake_shadow_front; GLuint m_text_fake_shadow_back; diff --git a/3d-viewer/info3d_visu.cpp b/3d-viewer/info3d_visu.cpp index aae38d5d75..b74d6ce025 100644 --- a/3d-viewer/info3d_visu.cpp +++ b/3d-viewer/info3d_visu.cpp @@ -66,6 +66,7 @@ INFO3D_VISU::INFO3D_VISU() m_epoxyThickness = 0; m_nonCopperLayerThickness = 0; m_BiuTo3Dunits = 1.0; + zpos_offset = 0.0; // Set copper color, in realistic mode #define LUMINANCE 0.7/255.0 diff --git a/common/class_bitmap_base.cpp b/common/class_bitmap_base.cpp index 134ebe5299..3598e367bf 100644 --- a/common/class_bitmap_base.cpp +++ b/common/class_bitmap_base.cpp @@ -58,6 +58,7 @@ BITMAP_BASE::BITMAP_BASE( const wxPoint& pos ) BITMAP_BASE::BITMAP_BASE( const BITMAP_BASE& aSchBitmap ) { m_Scale = aSchBitmap.m_Scale; + m_ppi = aSchBitmap.m_ppi; m_pixelScaleFactor = aSchBitmap.m_pixelScaleFactor; m_image = new wxImage( *aSchBitmap.m_image ); m_bitmap = new wxBitmap( *m_image ); diff --git a/common/common_plotDXF_functions.cpp b/common/common_plotDXF_functions.cpp index e6e11cce9d..545b5ca506 100644 --- a/common/common_plotDXF_functions.cpp +++ b/common/common_plotDXF_functions.cpp @@ -2,6 +2,28 @@ * @file common_plotDXF_functions.cpp * @brief KiCad: Common plot DXF Routines. */ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2015 KiCad Developers, see CHANGELOG.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 Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ #include #include diff --git a/common/common_plotHPGL_functions.cpp b/common/common_plotHPGL_functions.cpp index 1d7fd54783..81b462de4f 100644 --- a/common/common_plotHPGL_functions.cpp +++ b/common/common_plotHPGL_functions.cpp @@ -221,6 +221,8 @@ void HPGL_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil, paperSize.y *= 10.0 * aIusPerDecimil; SetDefaultLineWidth( 0 ); // HPGL has pen sizes instead m_plotMirror = aMirror; + penOverlap = 0; + penDiameter = 0; } diff --git a/eeschema/dialogs/dialog_plot_schematic.h b/eeschema/dialogs/dialog_plot_schematic.h index 8f29677232..86298b22d6 100644 --- a/eeschema/dialogs/dialog_plot_schematic.h +++ b/eeschema/dialogs/dialog_plot_schematic.h @@ -102,7 +102,7 @@ private: * @param aOldsheetpath the stored old sheet path for the current sheet before the plot started * @param aMsg the message which is print to the message box */ - void restoreEnvironment( PDF_PLOTTER* aPlotter, SCH_SHEET_PATH aOldsheetpath, + void restoreEnvironment( PDF_PLOTTER* aPlotter, SCH_SHEET_PATH& aOldsheetpath, const wxString& aMsg ); // DXF diff --git a/eeschema/plot_schematic_PDF.cpp b/eeschema/plot_schematic_PDF.cpp index 06d0d58293..1ea9471a71 100644 --- a/eeschema/plot_schematic_PDF.cpp +++ b/eeschema/plot_schematic_PDF.cpp @@ -139,7 +139,7 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotFrameRef ) void DIALOG_PLOT_SCHEMATIC::restoreEnvironment( PDF_PLOTTER* aPlotter, - SCH_SHEET_PATH aOldsheetpath, const wxString& aMsg ) + SCH_SHEET_PATH& aOldsheetpath, const wxString& aMsg ) { aPlotter->EndPlot(); delete aPlotter; diff --git a/gerbview/class_GERBER.cpp b/gerbview/class_GERBER.cpp index e36065ba38..8c04e7e430 100644 --- a/gerbview/class_GERBER.cpp +++ b/gerbview/class_GERBER.cpp @@ -200,11 +200,16 @@ void GERBER_IMAGE::ResetDefaultValues() m_PreviousPos.x = m_PreviousPos.y = 0; // last specified coord m_IJPos.x = m_IJPos.y = 0; // current centre coord for // plot arcs & circles - m_Current_File = NULL; // Gerger file to read + m_Current_File = NULL; // Gerber file to read m_FilesPtr = 0; m_PolygonFillMode = false; m_PolygonFillModeState = 0; m_Selected_Tool = FIRST_DCODE; + m_Last_Pen_Command = 0; + m_Exposure = false; + + for( unsigned ii = 0; ii < DIM( m_FilesList ); ii++ ) + m_FilesList[ii] = NULL; } /* Function HasNegativeItems @@ -455,7 +460,7 @@ const wxString GERBER_IMAGE_LIST::GetDisplayName( int aIdx ) if( aIdx >= 0 && aIdx < (int)m_GERBER_List.size() ) gerber = m_GERBER_List[aIdx]; - if( IsUsed(aIdx ) ) + if( gerber && IsUsed(aIdx ) ) { if( gerber->m_FileFunction ) name.Printf( _( "Layer %d (%s, %s)" ), aIdx + 1, diff --git a/gerbview/dialogs/dialog_print_using_printer.cpp b/gerbview/dialogs/dialog_print_using_printer.cpp index 645bb51332..2f4ff2ec8d 100644 --- a/gerbview/dialogs/dialog_print_using_printer.cpp +++ b/gerbview/dialogs/dialog_print_using_printer.cpp @@ -225,10 +225,9 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( ) m_FineAdjustYscaleOpt->SetValue( msg ); bool enable = (s_Parameters.m_PrintScale == 1.0); - if( m_FineAdjustXscaleOpt ) - m_FineAdjustXscaleOpt->Enable(enable); - if( m_FineAdjustYscaleOpt ) - m_FineAdjustYscaleOpt->Enable(enable); + + m_FineAdjustXscaleOpt->Enable(enable); + m_FineAdjustYscaleOpt->Enable(enable); } int DIALOG_PRINT_USING_PRINTER::SetLayerSetFromListSelection() diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h index 4c4bc5506b..b3a58e69f6 100644 --- a/gerbview/gerbview_frame.h +++ b/gerbview/gerbview_frame.h @@ -71,6 +71,7 @@ public: m_DisplayPolarCood = false; m_DisplayDCodes = true; m_IsPrinting = false; + m_DisplayNegativeObjects = false; } }; diff --git a/include/plot_common.h b/include/plot_common.h index 6ebf5f340c..37ef0e51f7 100644 --- a/include/plot_common.h +++ b/include/plot_common.h @@ -1,8 +1,8 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2015 KiCad Developers, see CHANGELOG.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 @@ -671,6 +671,8 @@ class PDF_PLOTTER : public PSLIKE_PLOTTER public: PDF_PLOTTER() : pageStreamHandle( 0 ), workFile( NULL ) { + // Avoid non initialized variables: + pageStreamHandle = streamLengthHandle = fontResDictHandle = 0; } virtual PlotFormat GetPlotterType() const @@ -986,6 +988,8 @@ class DXF_PLOTTER : public PLOTTER public: DXF_PLOTTER() : textAsLines( false ) { + textAsLines = true; + m_currentColor = BLACK; } virtual PlotFormat GetPlotterType() const diff --git a/lib_dxf/drw_base.h b/lib_dxf/drw_base.h index 56c4931301..df8f155cb9 100644 --- a/lib_dxf/drw_base.h +++ b/lib_dxf/drw_base.h @@ -163,6 +163,7 @@ public: DRW_Variant() { type = INVALID; + code = 0; } DRW_Variant( const DRW_Variant& d ) diff --git a/lib_dxf/libdxfrw.cpp b/lib_dxf/libdxfrw.cpp index 1c2a1d64cf..729977b410 100644 --- a/lib_dxf/libdxfrw.cpp +++ b/lib_dxf/libdxfrw.cpp @@ -46,6 +46,8 @@ dxfRW::dxfRW( const char* name ) applyExt = false; elParts = 128; // parts munber when convert ellipse to polyline + version = DRW::UNKNOWNV; + binary = false; iface = NULL; entCount = 0; diff --git a/pagelayout_editor/events_functions.cpp b/pagelayout_editor/events_functions.cpp index 598a141df2..5fb1bb2c73 100644 --- a/pagelayout_editor/events_functions.cpp +++ b/pagelayout_editor/events_functions.cpp @@ -119,6 +119,7 @@ void PL_EDITOR_FRAME::Process_Special_Functions( wxCommandEvent& event ) { case ID_NO_TOOL_SELECTED: SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString ); + break; case ID_SELECT_PAGE_NUMBER: m_canvas->Refresh(); diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index 7ccde4e785..c244b2e859 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -709,6 +709,7 @@ WORKSHEET_DATAITEM* PL_EDITOR_FRAME::Locate( const wxPoint& aPosition ) // because the locate requirements are very basic. std::vector list; drawList.Locate( list, aPosition ); + if( list.size() == 0 ) return NULL; diff --git a/pcbnew/dialogs/wizard_add_fplib.cpp b/pcbnew/dialogs/wizard_add_fplib.cpp index 04d15ff6c7..d20890f7f9 100644 --- a/pcbnew/dialogs/wizard_add_fplib.cpp +++ b/pcbnew/dialogs/wizard_add_fplib.cpp @@ -891,7 +891,7 @@ bool WIZARD_FPLIB_TABLE::downloadGithubLibsFromList( wxArrayString& aUrlList, wxString default_path; wxGetEnv( FP_LIB_TABLE::GlobalPathEnvVariableName(), &default_path ); - masterFolder = wxDirSelector( _("Output Folder" ), + masterFolder = wxDirSelector( _("Choose Folder to Copy Downloaded '.pretty' Libraries" ), default_path, 0, wxDefaultPosition, this ); if( masterFolder.IsEmpty() ) // Aborted by user