From cffccc3970d49ee9d6596f4e70ac78616e58f5a1 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 29 Sep 2020 17:02:29 +0200 Subject: [PATCH] Code cleanup: remove useless wx/wx.h include inside a few files. in most of files, including wx.h is not necessary, when only 2 or 3 wx files must be included. Moreover, on windows, including wx.h sometimes create compil warnings about shadowed vars defined in some specific windows headers. --- .../3d_render_raytracing/shapes3D/cbbox.cpp | 1 + .../3d_render_raytracing/shapes3D/cbbox.h | 1 - common/common.cpp | 3 -- .../plugins/cadstar/cadstar_archive_parser.h | 46 +++++++++---------- common/richio.cpp | 2 + common/search_stack.cpp | 1 + common/searchhelpfilefullpath.cpp | 1 + common/widgets/mathplot.cpp | 2 +- eeschema/dialogs/dialog_plot_schematic.h | 1 - eeschema/sch_plugin.cpp | 1 + include/common.h | 5 +- include/eda_base_frame.h | 3 +- include/fctsys.h | 8 ---- include/macros.h | 3 +- include/property.h | 2 +- include/richio.h | 3 +- include/status_popup.h | 5 +- include/tool/tools_holder.h | 2 - .../panel_board_stackup.h | 1 - .../stackup_predefined_prms.h | 2 + pcbnew/dialogs/dialog_board_reannotate.h | 3 +- pcbnew/dialogs/dialog_drc.h | 1 - .../drc/drc_test_provider_matched_length.cpp | 7 +-- pcbnew/netlist_reader/netlist_reader.h | 1 - pcbnew/pcbnew.h | 1 - pcbnew/plugin.cpp | 7 +-- pcbnew/specctra_import_export/specctra.h | 7 ++- pcbnew/zones_functions_for_undo_redo.cpp | 6 ++- qa/pcbnew/test_libeval_compiler.cpp | 8 ++-- 29 files changed, 66 insertions(+), 68 deletions(-) diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cbbox.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cbbox.cpp index a00b1918a0..72b15229ca 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cbbox.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cbbox.cpp @@ -30,6 +30,7 @@ #include "cbbox.h" #include +#include #include // For the wxASSERT diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cbbox.h b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cbbox.h index 1f5fedab80..8cce10f1b6 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cbbox.h +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cbbox.h @@ -31,7 +31,6 @@ #define _CBBOX_H_ #include "../ray.h" -#include // For the DBG( /** * CBBOX diff --git a/common/common.cpp b/common/common.cpp index 8a5023a4b2..a806b042dd 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -23,7 +23,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include #include #include #include @@ -39,8 +38,6 @@ #include #include -using KIGFX::COLOR4D; - // Create only once, as seeding is *very* expensive static boost::uuids::random_generator randomGenerator; diff --git a/common/plugins/cadstar/cadstar_archive_parser.h b/common/plugins/cadstar/cadstar_archive_parser.h index 76db8f563e..5ccb1c2e6e 100644 --- a/common/plugins/cadstar/cadstar_archive_parser.h +++ b/common/plugins/cadstar/cadstar_archive_parser.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include @@ -443,7 +443,7 @@ public: * boundary and defines how the text is displayed. * * For example, with an alignment of bottom-right the origin will be positioned at the bottom - * right of the text boundary. This makes it easier to right-align several text items + * right of the text boundary. This makes it easier to right-align several text items * regardless of the length of text displayed. * * Text Alignment applies to all CADSTAR text. [...] @@ -451,7 +451,7 @@ public: * Note: Unaligned text operates in the way CADSTAR text always has. In most cases this behaves * as Bottom Left alignment, but there are a few exceptions, e.g. pin names. Also unaligned * multiline text has an origin Bottom Left of the first line." - * + * * See also JUSTIFICATION */ enum class ALIGNMENT @@ -472,8 +472,8 @@ public: static ALIGNMENT ParseAlignment( XNODE* aNode ); /** - * @brief From CADSTAR Help: "Multi Line Text can also be justified as Left, Centre or Right. - * This does not affect the text alignment. Note: Justification of single line text has no + * @brief From CADSTAR Help: "Multi Line Text can also be justified as Left, Centre or Right. + * This does not affect the text alignment. Note: Justification of single line text has no * effect." * * This only affects multiline text @@ -684,7 +684,7 @@ public: * a component outline/area (or an area of component copper, or * a string of component text) dependent on the current mirror * status of the component. - * + * * For example, you may require a string of component text to * be displayed only when the component is mirrored." */ @@ -1113,27 +1113,27 @@ public: /** * @brief Reads a CADSTAR Archive file (S-parameter format) - * @param aFileName + * @param aFileName * @param aFileTypeIdentifier Identifier of the first node in the file to check against. E.g. "CADSTARPCB" - * @return XNODE pointing to the top of the tree for further parsing. Each node has the first - * element as the node's name and subsequent elements as node attributes ("attr0", + * @return XNODE pointing to the top of the tree for further parsing. Each node has the first + * element as the node's name and subsequent elements as node attributes ("attr0", * "attr1", "attr2", etc.). Caller is responsible for deleting to avoid memory leaks. * @throws IO_ERROR */ static XNODE* LoadArchiveFile( const wxString& aFileName, const wxString& aFileTypeIdentifier ); /** - * @brief - * @param aAttribute - * @return + * @brief + * @param aAttribute + * @return */ static bool IsValidAttribute( wxXmlAttribute* aAttribute ); /** - * @brief - * @param aNode - * @param aID + * @brief + * @param aNode + * @param aID * @param aIsRequired Prevents exception throwing if false. * @return returns the value (wxString) of attribute "attrX" in aNode where 'X' is aID * @throws IO_ERROR if attribute does not exist @@ -1142,9 +1142,9 @@ public: XNODE* aNode, unsigned int aID, bool aIsRequired = true ); /** - * @brief - * @param aNode - * @param aID + * @brief + * @param aNode + * @param aID * @param aIsRequired Prevents exception throwing if false. * @return returns the value (long) of attribute "attrX" in aNode where 'X' is aID * @throws IO_ERROR if attribute does not exist @@ -1152,15 +1152,15 @@ public: static long GetXmlAttributeIDLong( XNODE* aNode, unsigned int aID, bool aIsRequired = true ); /** - * @brief - * @param aNode + * @brief + * @param aNode * @throw IO_ERROR if a child node was found */ static void CheckNoChildNodes( XNODE* aNode ); /** - * @brief - * @param aNode + * @brief + * @param aNode * @throw IO_ERROR if a node adjacent to aNode was found */ static void CheckNoNextNodes( XNODE* aNode ); @@ -1168,7 +1168,7 @@ public: /** * @brief * @param aNode with a child node containing an EVALUE - * @param aValueToParse + * @param aValueToParse * @throw IO_ERROR if unable to parse or node is not an EVALUE */ static void ParseChildEValue( XNODE* aNode, EVALUE& aValueToParse ); diff --git a/common/richio.cpp b/common/richio.cpp index 9cbaaf1b36..b51414d3e8 100644 --- a/common/richio.cpp +++ b/common/richio.cpp @@ -28,6 +28,8 @@ #include +#include +#include // Fall back to getc() when getc_unlocked() is not available on the target platform. #if !defined( HAVE_FGETC_NOLOCK ) diff --git a/common/search_stack.cpp b/common/search_stack.cpp index 3cfa3c4eda..45e66fb1fe 100644 --- a/common/search_stack.cpp +++ b/common/search_stack.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #if defined(__MINGW32__) #define PATH_SEPS wxT( ";\r\n" ) diff --git a/common/searchhelpfilefullpath.cpp b/common/searchhelpfilefullpath.cpp index 64636dbeff..e59b382962 100644 --- a/common/searchhelpfilefullpath.cpp +++ b/common/searchhelpfilefullpath.cpp @@ -27,6 +27,7 @@ #include #include // to define DEFAULT_INSTALL_PATH #include +#include #include diff --git a/common/widgets/mathplot.cpp b/common/widgets/mathplot.cpp index 82003223a6..0ecfdf1564 100644 --- a/common/widgets/mathplot.cpp +++ b/common/widgets/mathplot.cpp @@ -631,7 +631,7 @@ void mpFXY::Plot( wxDC& dc, mpWindow& w ) if( !m_continuous ) { bool first = true; - wxCoord ix; + wxCoord ix = 0; std::set ys; while( GetNextXY( x, y ) ) diff --git a/eeschema/dialogs/dialog_plot_schematic.h b/eeschema/dialogs/dialog_plot_schematic.h index dea1fb1f05..857f569ecf 100644 --- a/eeschema/dialogs/dialog_plot_schematic.h +++ b/eeschema/dialogs/dialog_plot_schematic.h @@ -27,7 +27,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include #include #include #include diff --git a/eeschema/sch_plugin.cpp b/eeschema/sch_plugin.cpp index 29d763be2e..83a90f26fa 100644 --- a/eeschema/sch_plugin.cpp +++ b/eeschema/sch_plugin.cpp @@ -23,6 +23,7 @@ #include #include +#include #define FMT_UNIMPLEMENTED _( "Plugin \"%s\" does not implement the \"%s\" function." ) diff --git a/include/common.h b/include/common.h index 7e951c7119..d7aec28e06 100644 --- a/include/common.h +++ b/include/common.h @@ -35,13 +35,14 @@ #include #include -#include #include #include #include +#include +#include +#include #include -#include #include #include diff --git a/include/eda_base_frame.h b/include/eda_base_frame.h index e4ddb219a3..47bcbab6bf 100644 --- a/include/eda_base_frame.h +++ b/include/eda_base_frame.h @@ -41,8 +41,7 @@ #include #include #include -#include -#include + #include #include #include diff --git a/include/fctsys.h b/include/fctsys.h index 5e209f2a59..e83da61664 100644 --- a/include/fctsys.h +++ b/include/fctsys.h @@ -26,14 +26,6 @@ #define FCTSYS_H_ #include - -#ifdef DEBUG -#define DBG(x) x -#else -#define DBG(x) // nothing -#endif - - #include #endif // FCTSYS_H__ diff --git a/include/macros.h b/include/macros.h index ddb5611b2b..4f8e20bb7e 100644 --- a/include/macros.h +++ b/include/macros.h @@ -31,13 +31,14 @@ #ifndef MACROS_H #define MACROS_H -#include #include #include #include #include #include // std::shared_ptr +#include + #if defined( __has_attribute ) #define KI_HAS_ATTRIBUTE( x ) __has_attribute( x ) #else diff --git a/include/property.h b/include/property.h index c51f1bb1da..df24e5e01f 100644 --- a/include/property.h +++ b/include/property.h @@ -22,9 +22,9 @@ #ifndef PROPERTY_H #define PROPERTY_H -#include #include #include +#include #include #include diff --git a/include/richio.h b/include/richio.h index b48d8d0f4d..96196e4c7c 100644 --- a/include/richio.h +++ b/include/richio.h @@ -35,7 +35,8 @@ // I really did not want to be dependent on wxWidgets in richio // but the errorText needs to be wide char so wxString rules. #include -#include +#include +#include #include diff --git a/include/status_popup.h b/include/status_popup.h index 6a4e9cb2fa..835683a14b 100644 --- a/include/status_popup.h +++ b/include/status_popup.h @@ -26,9 +26,12 @@ #define __STATUS_POPUP_H_ -#include #include #include +#include +#include +#include +#include class EDA_DRAW_FRAME; diff --git a/include/tool/tools_holder.h b/include/tool/tools_holder.h index 3431f54a83..9b739c82ea 100644 --- a/include/tool/tools_holder.h +++ b/include/tool/tools_holder.h @@ -25,8 +25,6 @@ #define TOOL_HOLDER_H #include -#include -#include #include #include #include diff --git a/pcbnew/board_stackup_manager/panel_board_stackup.h b/pcbnew/board_stackup_manager/panel_board_stackup.h index 0f6684b507..1a5b5fb3f2 100644 --- a/pcbnew/board_stackup_manager/panel_board_stackup.h +++ b/pcbnew/board_stackup_manager/panel_board_stackup.h @@ -26,7 +26,6 @@ #define PANEL_SETUP_BOARD_STACKUP_H -#include #include #include #include diff --git a/pcbnew/board_stackup_manager/stackup_predefined_prms.h b/pcbnew/board_stackup_manager/stackup_predefined_prms.h index 3a98690860..b4dc702d79 100644 --- a/pcbnew/board_stackup_manager/stackup_predefined_prms.h +++ b/pcbnew/board_stackup_manager/stackup_predefined_prms.h @@ -31,6 +31,8 @@ #include +#include +#include #include #include // For _HKI definition diff --git a/pcbnew/dialogs/dialog_board_reannotate.h b/pcbnew/dialogs/dialog_board_reannotate.h index 7b4dbcec21..a919e17650 100644 --- a/pcbnew/dialogs/dialog_board_reannotate.h +++ b/pcbnew/dialogs/dialog_board_reannotate.h @@ -36,10 +36,9 @@ #include #include #include -#include +//#include #include -#include #include #include #include diff --git a/pcbnew/dialogs/dialog_drc.h b/pcbnew/dialogs/dialog_drc.h index f6df90373c..3ec838155d 100644 --- a/pcbnew/dialogs/dialog_drc.h +++ b/pcbnew/dialogs/dialog_drc.h @@ -28,7 +28,6 @@ #define _DIALOG_DRC_H_ #include -#include #include #include #include diff --git a/pcbnew/drc/drc_test_provider_matched_length.cpp b/pcbnew/drc/drc_test_provider_matched_length.cpp index fb5fcb8245..76619ea044 100644 --- a/pcbnew/drc/drc_test_provider_matched_length.cpp +++ b/pcbnew/drc/drc_test_provider_matched_length.cpp @@ -52,13 +52,13 @@ public: { } - virtual ~DRC_TEST_PROVIDER_MATCHED_LENGTH() + virtual ~DRC_TEST_PROVIDER_MATCHED_LENGTH() { } virtual bool Run() override; - virtual const wxString GetName() const override + virtual const wxString GetName() const override { return "length"; }; @@ -109,7 +109,8 @@ void test::DRC_TEST_PROVIDER_MATCHED_LENGTH::checkLengthViolations( { bool minViolation = false; bool maxViolation = false; - int minLen, maxLen; + int minLen = 0; + int maxLen = 0; if( aConstraint.GetValue().HasMin() && ent.total < aConstraint.GetValue().Min() ) { diff --git a/pcbnew/netlist_reader/netlist_reader.h b/pcbnew/netlist_reader/netlist_reader.h index b2d5a051a5..8669875895 100644 --- a/pcbnew/netlist_reader/netlist_reader.h +++ b/pcbnew/netlist_reader/netlist_reader.h @@ -32,7 +32,6 @@ #include -#include #include #include diff --git a/pcbnew/pcbnew.h b/pcbnew/pcbnew.h index d336257460..c0eefa7adf 100644 --- a/pcbnew/pcbnew.h +++ b/pcbnew/pcbnew.h @@ -25,7 +25,6 @@ #ifndef PCBNEW_H #define PCBNEW_H -#include // wxWidgets include. #include // to define Mils2iu() conversion function // These are only here for algorithmic safety, not to tell the user what to do diff --git a/pcbnew/plugin.cpp b/pcbnew/plugin.cpp index 6b85411c09..67be973e6f 100644 --- a/pcbnew/plugin.cpp +++ b/pcbnew/plugin.cpp @@ -24,9 +24,10 @@ #include #include +#include -#define FMT_UNIMPLEMENTED _( "Plugin \"%s\" does not implement the \"%s\" function." ) +#define FMT_UNIMPLEMENTED "Plugin \"%s\" does not implement the \"%s\" function." /** * Function not_implemented @@ -38,8 +39,8 @@ static void not_implemented( PLUGIN* aPlugin, const char* aCaller ) { THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, - aPlugin->PluginName().GetData(), - wxString::FromUTF8( aCaller ).GetData() ) ); + aPlugin->PluginName(), + wxString::FromUTF8( aCaller ) ) ); } diff --git a/pcbnew/specctra_import_export/specctra.h b/pcbnew/specctra_import_export/specctra.h index 28f11ecc42..d3bbefc447 100644 --- a/pcbnew/specctra_import_export/specctra.h +++ b/pcbnew/specctra_import_export/specctra.h @@ -32,7 +32,6 @@ // see http://www.boost.org/libs/ptr_container/doc/ptr_set.html #include -#include #include #include @@ -3935,7 +3934,7 @@ public: /** * Function FromBOARD - * adds the entire BOARD to the PCB but does not write it out. Note that the BOARD given + * adds the entire BOARD to the PCB but does not write it out. Note that the BOARD given * to this function must have all the MODULEs on the component side of the BOARD. * * See PCB_EDIT_FRAME::ExportToSpecctra() for an example before calling this function. @@ -3946,8 +3945,8 @@ public: /** * Function FromSESSION - * adds the entire SESSION info to a BOARD but does not write it out. The BOARD given to - * this function will have all its tracks and via's replaced, and all its components are + * adds the entire SESSION info to a BOARD but does not write it out. The BOARD given to + * this function will have all its tracks and via's replaced, and all its components are * subject to being moved. * * @param aBoard The BOARD to merge the SESSION information into. diff --git a/pcbnew/zones_functions_for_undo_redo.cpp b/pcbnew/zones_functions_for_undo_redo.cpp index 7adcdda77f..da1289d226 100644 --- a/pcbnew/zones_functions_for_undo_redo.cpp +++ b/pcbnew/zones_functions_for_undo_redo.cpp @@ -268,9 +268,11 @@ void UpdateCopyOfZonesList( PICKED_ITEMS_LIST& aPickList, if( notfound ) // happens when the new zone overlaps an existing zone // and these zones are combined { - DBG( printf( + #if defined(DEBUG) + printf( "UpdateCopyOfZonesList(): item not found in aAuxiliaryList," - "combined with another zone\n" ) ); + "combined with another zone\n" ); + #endif } break; } diff --git a/qa/pcbnew/test_libeval_compiler.cpp b/qa/pcbnew/test_libeval_compiler.cpp index 86fe1ce094..9f62d912ee 100644 --- a/qa/pcbnew/test_libeval_compiler.cpp +++ b/qa/pcbnew/test_libeval_compiler.cpp @@ -21,6 +21,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include + #include #include @@ -40,11 +42,11 @@ struct EXPR_TO_TEST using VAL = LIBEVAL::VALUE; -const static std::vector simpleExpressions = { +const static std::vector simpleExpressions = { { "10mm + 20 mm", false, VAL( 30e6 ) }, - { "3*(7+8)", false, VAL( 3 * ( 7 + 8 ) ) }, + { "3*(7+8)", false, VAL( 3 * ( 7 + 8 ) ) }, { "3*7+8", false, VAL( 3 * 7 + 8 ) }, - { "(3*7)+8", false, VAL( 3 * 7 + 8 ) }, + { "(3*7)+8", false, VAL( 3 * 7 + 8 ) }, { "10mm + 20)", true, VAL( 0 ) }, { "1", false, VAL(1) },