From 34e5b76c5f9b52fc82b71b49aeee05fd3616c0d8 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Wed, 5 Feb 2020 22:19:14 +0000 Subject: [PATCH] Add virtual constructors to some classes that should have them This is more for safety from undefined deletion behavior than anything else (it also silences the Clang -Wnon-virtual-dtor warning). --- .../3d_render_raytracing/cmaterial.h | 28 +++++++++++++++ 3d-viewer/3d_rendering/ccamera.h | 4 +++ 3d-viewer/3d_rendering/ctrack_ball.h | 4 +++ eeschema/project_rescue.h | 12 +++++++ include/board_printout.h | 4 +++ include/lib_tree_item.h | 4 +++ include/preview_items/polygon_geom_manager.h | 4 +++ include/printout.h | 4 +++ include/project.h | 2 +- include/reporter.h | 24 +++++++++++++ include/widgets/layer_box_selector.h | 4 +++ include/widgets/progress_reporter.h | 4 +++ pcbnew/pcad2kicadpcb_plugin/pcb_callbacks.h | 6 +++- pcbnew/router/pns_node.cpp | 8 +++++ pcbnew/router/pns_node.h | 4 +++ pcbnew/tools/drawing_tool.cpp | 4 +++ pcbnew/tools/footprint_editor_tools.cpp | 4 +++ pcbnew/tools/microwave_tool.cpp | 4 +++ pcbnew/tools/pcb_tool_base.h | 34 +++++++++++-------- pcbnew/tools/zone_create_helper.h | 2 +- qa/pcbnew_tools/tools/drc_tool/drc_tool.cpp | 12 +++++++ 21 files changed, 158 insertions(+), 18 deletions(-) diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/cmaterial.h b/3d-viewer/3d_rendering/3d_render_raytracing/cmaterial.h index 5a88c98a34..aac1ef971b 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/cmaterial.h +++ b/3d-viewer/3d_rendering/3d_render_raytracing/cmaterial.h @@ -40,6 +40,10 @@ class CPROCEDURALGENERATOR public: CPROCEDURALGENERATOR(); + virtual ~CPROCEDURALGENERATOR() + { + } + /** * @brief Generate - Generates a 3D vector based on the ray and * hit information depending on the implementation @@ -62,6 +66,10 @@ public: CBOARDNORMAL() : CPROCEDURALGENERATOR() { m_scale = 1.0f; } CBOARDNORMAL( float aScale ); + virtual ~CBOARDNORMAL() + { + } + // Imported from CPROCEDURALGENERATOR SFVEC3F Generate( const RAY &aRay, const HITINFO &aHitInfo ) const override; @@ -81,6 +89,10 @@ public: CCOPPERNORMAL( float aScale, const CPROCEDURALGENERATOR *aBoardNormalGenerator ); + virtual ~CCOPPERNORMAL() + { + } + // Imported from CPROCEDURALGENERATOR SFVEC3F Generate( const RAY &aRay, const HITINFO &aHitInfo ) const override; @@ -97,6 +109,10 @@ public: CSOLDERMASKNORMAL() : CPROCEDURALGENERATOR() { m_copper_normal_generator = NULL; } CSOLDERMASKNORMAL( const CPROCEDURALGENERATOR *aCopperNormalGenerator ); + virtual ~CSOLDERMASKNORMAL() + { + } + // Imported from CPROCEDURALGENERATOR SFVEC3F Generate( const RAY &aRay, const HITINFO &aHitInfo ) const override; @@ -116,6 +132,10 @@ public: CPLASTICNORMAL( float aScale ); + virtual ~CPLASTICNORMAL() + { + } + // Imported from CPROCEDURALGENERATOR SFVEC3F Generate( const RAY &aRay, const HITINFO &aHitInfo ) const override; @@ -136,6 +156,10 @@ public: CPLASTICSHINENORMAL( float aScale ); + virtual ~CPLASTICSHINENORMAL() + { + } + // Imported from CPROCEDURALGENERATOR SFVEC3F Generate( const RAY &aRay, const HITINFO &aHitInfo ) const override; @@ -155,6 +179,10 @@ public: CMETALBRUSHEDNORMAL( float aScale ); + virtual ~CMETALBRUSHEDNORMAL() + { + } + // Imported from CPROCEDURALGENERATOR SFVEC3F Generate( const RAY &aRay, const HITINFO &aHitInfo ) const override; diff --git a/3d-viewer/3d_rendering/ccamera.h b/3d-viewer/3d_rendering/ccamera.h index 713222e7b3..3eea7a8fcd 100644 --- a/3d-viewer/3d_rendering/ccamera.h +++ b/3d-viewer/3d_rendering/ccamera.h @@ -89,6 +89,10 @@ class CCAMERA */ explicit CCAMERA( float aRangeScale ); + virtual ~CCAMERA() + { + } + /** * Function GetRotationMatrix diff --git a/3d-viewer/3d_rendering/ctrack_ball.h b/3d-viewer/3d_rendering/ctrack_ball.h index 5b81f5d569..059b7d08aa 100644 --- a/3d-viewer/3d_rendering/ctrack_ball.h +++ b/3d-viewer/3d_rendering/ctrack_ball.h @@ -40,6 +40,10 @@ class CTRACK_BALL : public CCAMERA explicit CTRACK_BALL( float aRangeScale ); + virtual ~CTRACK_BALL() + { + } + void Drag( const wxPoint &aNewMousePosition ) override; void Pan( const wxPoint &aNewMousePosition ) override; diff --git a/eeschema/project_rescue.h b/eeschema/project_rescue.h index fdaa82d434..3633484760 100644 --- a/eeschema/project_rescue.h +++ b/eeschema/project_rescue.h @@ -233,6 +233,10 @@ public: RESCUER( PROJECT& aProject, SCH_SHEET_PATH* aCurrentSheet, EDA_DRAW_PANEL_GAL::GAL_TYPE aGalBackeEndType ); + virtual ~RESCUER() + { + } + /** * Writes out the rescue library. Called after successful PerformAction()s. If this fails, * undo the actions. @@ -316,6 +320,10 @@ public: { } + virtual ~LEGACY_RESCUER() + { + } + virtual void FindCandidates() override; virtual void InvokeDialog( wxWindow* aParent, bool aAskShowAgain ) override; @@ -339,6 +347,10 @@ public: SYMBOL_LIB_TABLE_RESCUER( PROJECT& aProject, SCH_SHEET_PATH* aCurrentSheet, EDA_DRAW_PANEL_GAL::GAL_TYPE aGalBackeEndType ); + virtual ~SYMBOL_LIB_TABLE_RESCUER() + { + } + virtual void FindCandidates() override; virtual void InvokeDialog( wxWindow* aParent, bool aAskShowAgain ) override; diff --git a/include/board_printout.h b/include/board_printout.h index 1ea62a3327..020c58115b 100644 --- a/include/board_printout.h +++ b/include/board_printout.h @@ -49,6 +49,10 @@ struct BOARD_PRINTOUT_SETTINGS : public PRINTOUT_SETTINGS { BOARD_PRINTOUT_SETTINGS( const PAGE_INFO& aPageInfo ); + virtual ~BOARD_PRINTOUT_SETTINGS() + { + } + LSET m_layerSet; ///< Layers to print bool m_mirror; ///< Print mirrored diff --git a/include/lib_tree_item.h b/include/lib_tree_item.h index 097d25765e..3ceebbfcff 100644 --- a/include/lib_tree_item.h +++ b/include/lib_tree_item.h @@ -39,6 +39,10 @@ class APIEXPORT LIB_TREE_ITEM { public: + virtual ~LIB_TREE_ITEM() + { + } + virtual LIB_ID GetLibId() const = 0; virtual wxString GetName() const = 0; diff --git a/include/preview_items/polygon_geom_manager.h b/include/preview_items/polygon_geom_manager.h index e8fa42950b..9a9a21ffa4 100644 --- a/include/preview_items/polygon_geom_manager.h +++ b/include/preview_items/polygon_geom_manager.h @@ -58,6 +58,10 @@ public: ///> Called when the polygon is complete virtual void OnComplete( const POLYGON_GEOM_MANAGER& aMgr ) = 0; + + virtual ~CLIENT() + { + } }; /** diff --git a/include/printout.h b/include/printout.h index 7fae8b2458..06d9d748c8 100644 --- a/include/printout.h +++ b/include/printout.h @@ -38,6 +38,10 @@ struct PRINTOUT_SETTINGS m_pageCount = 0; } + virtual ~PRINTOUT_SETTINGS() + { + } + virtual void Save( wxConfigBase* aConfig ); virtual void Load( wxConfigBase* aConfig ); diff --git a/include/project.h b/include/project.h index 67533c285f..8cdbaca110 100644 --- a/include/project.h +++ b/include/project.h @@ -74,7 +74,7 @@ public: }; PROJECT(); - ~PROJECT(); + VTBL_ENTRY ~PROJECT(); //--------------------------------------------------------- diff --git a/include/reporter.h b/include/reporter.h index 7fcf1b11a5..b5d97545df 100644 --- a/include/reporter.h +++ b/include/reporter.h @@ -134,6 +134,10 @@ public: * Returns true if the reporter client is non-empty. */ virtual bool HasMessage() const = 0; + + virtual ~REPORTER() + { + } }; @@ -152,6 +156,10 @@ public: { } + virtual ~WX_TEXT_CTRL_REPORTER() + { + } + REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override; bool HasMessage() const override; @@ -173,6 +181,10 @@ public: { } + virtual ~WX_STRING_REPORTER() + { + } + REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override; bool HasMessage() const override; @@ -194,6 +206,10 @@ public: { } + virtual ~WX_HTML_PANEL_REPORTER() + { + } + REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override; REPORTER& ReportTail( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override; @@ -216,6 +232,10 @@ public: { } + virtual ~NULL_REPORTER() + { + } + static REPORTER& GetInstance(); REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override; @@ -235,6 +255,10 @@ public: { } + virtual ~STDOUT_REPORTER() + { + } + static REPORTER& GetInstance(); REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override; diff --git a/include/widgets/layer_box_selector.h b/include/widgets/layer_box_selector.h index a1190d88eb..5a12fa7fc1 100644 --- a/include/widgets/layer_box_selector.h +++ b/include/widgets/layer_box_selector.h @@ -43,6 +43,10 @@ protected: public: LAYER_SELECTOR(); + virtual ~LAYER_SELECTOR() + { + } + // Returns a color index from the layer id // Virtual function because GerbView uses its own functions in a derived class virtual COLOR4D GetLayerColor( LAYER_NUM aLayer ) const = 0; diff --git a/include/widgets/progress_reporter.h b/include/widgets/progress_reporter.h index 55f9ef7554..59e333a7a8 100644 --- a/include/widgets/progress_reporter.h +++ b/include/widgets/progress_reporter.h @@ -44,6 +44,10 @@ class PROGRESS_REPORTER PROGRESS_REPORTER( int aNumPhases ); PROGRESS_REPORTER( const PROGRESS_REPORTER& ) = delete; + virtual ~PROGRESS_REPORTER() + { + } + /** * initialize the aPhase virtual zone of the dialog progress bar */ diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_callbacks.h b/pcbnew/pcad2kicadpcb_plugin/pcb_callbacks.h index 91866ccb26..3706f0f58b 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_callbacks.h +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_callbacks.h @@ -53,7 +53,11 @@ namespace PCAD2KICAD class PCB_CALLBACKS { public: - virtual PCB_LAYER_ID GetKiCadLayer( int aPCadLayer ) = 0; + virtual ~PCB_CALLBACKS() + { + } + + virtual PCB_LAYER_ID GetKiCadLayer( int aPCadLayer ) = 0; virtual LAYER_TYPE_T GetLayerType( int aPCadLayer ) = 0; virtual wxString GetLayerNetNameRef( int aPCadLayer ) = 0; virtual int GetNewTimestamp() = 0; diff --git a/pcbnew/router/pns_node.cpp b/pcbnew/router/pns_node.cpp index 4f7ad13135..512e26afbf 100644 --- a/pcbnew/router/pns_node.cpp +++ b/pcbnew/router/pns_node.cpp @@ -210,6 +210,10 @@ struct NODE::DEFAULT_OBSTACLE_VISITOR : public OBSTACLE_VISITOR } } + virtual ~DEFAULT_OBSTACLE_VISITOR() + { + } + void SetCountLimit( int aLimit ) { m_limitCount = aLimit; @@ -483,6 +487,10 @@ struct HIT_VISITOR : public OBSTACLE_VISITOR m_items( aTab ), m_point( aPoint ) {} + virtual ~HIT_VISITOR() + { + } + bool operator()( ITEM* aItem ) override { SHAPE_CIRCLE cp( m_point, 0 ); diff --git a/pcbnew/router/pns_node.h b/pcbnew/router/pns_node.h index 12c1243579..4ee01f94c2 100644 --- a/pcbnew/router/pns_node.h +++ b/pcbnew/router/pns_node.h @@ -104,6 +104,10 @@ public: OBSTACLE_VISITOR( const ITEM* aItem ); + virtual ~OBSTACLE_VISITOR() + { + } + void SetWorld( const NODE* aNode, const NODE* aOverride = NULL ); virtual bool operator()( ITEM* aCandidate ) = 0; diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index cfd3e15409..e7fcfb527c 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -1593,6 +1593,10 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent ) VIA_PLACER( PCB_BASE_EDIT_FRAME* aFrame ) : m_gridHelper( aFrame ) {} + virtual ~VIA_PLACER() + { + } + TRACK* findTrack( VIA* aVia ) { const LSET lset = aVia->GetLayerSet(); diff --git a/pcbnew/tools/footprint_editor_tools.cpp b/pcbnew/tools/footprint_editor_tools.cpp index 5abea8f88f..7e267c064c 100644 --- a/pcbnew/tools/footprint_editor_tools.cpp +++ b/pcbnew/tools/footprint_editor_tools.cpp @@ -290,6 +290,10 @@ int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent ) struct PAD_PLACER : public INTERACTIVE_PLACER_BASE { + virtual ~PAD_PLACER() + { + } + std::unique_ptr CreateItem() override { D_PAD* pad = new D_PAD( m_board->GetFirstModule() ); diff --git a/pcbnew/tools/microwave_tool.cpp b/pcbnew/tools/microwave_tool.cpp index f309885839..7ddcc8aec4 100644 --- a/pcbnew/tools/microwave_tool.cpp +++ b/pcbnew/tools/microwave_tool.cpp @@ -65,6 +65,10 @@ int MICROWAVE_TOOL::addMicrowaveFootprint( const TOOL_EVENT& aEvent ) m_itemType( aType ) { }; + virtual ~MICROWAVE_PLACER() + { + } + std::unique_ptr CreateItem() override { switch( m_itemType ) diff --git a/pcbnew/tools/pcb_tool_base.h b/pcbnew/tools/pcb_tool_base.h index a89a11744e..223ef96d52 100644 --- a/pcbnew/tools/pcb_tool_base.h +++ b/pcbnew/tools/pcb_tool_base.h @@ -51,6 +51,10 @@ class PCBNEW_SELECTION; struct INTERACTIVE_PLACER_BASE { + virtual ~INTERACTIVE_PLACER_BASE() + { + } + virtual std::unique_ptr CreateItem() = 0; virtual void SnapItem( BOARD_ITEM *aItem ); virtual bool PlaceItem( BOARD_ITEM *aItem, BOARD_COMMIT& aCommit ); @@ -70,7 +74,7 @@ public: * Creates a tool with given id & name. The name must be unique. */ PCB_TOOL_BASE( TOOL_ID aId, const std::string& aName ) : TOOL_INTERACTIVE ( aId, aName ), - m_editModules( false ) + m_editModules( false ) {}; /** @@ -79,7 +83,7 @@ public: * Creates a tool with given name. The name must be unique. */ PCB_TOOL_BASE( const std::string& aName ) : TOOL_INTERACTIVE ( aName ), - m_editModules( false ) + m_editModules( false ) {}; virtual ~PCB_TOOL_BASE() {}; @@ -133,28 +137,28 @@ protected: virtual void setTransitions() override; - KIGFX::PCB_VIEW* view() const - { - return static_cast( getView() ); + KIGFX::PCB_VIEW* view() const + { + return static_cast( getView() ); } - - KIGFX::VIEW_CONTROLS* controls() const - { - return getViewControls(); + + KIGFX::VIEW_CONTROLS* controls() const + { + return getViewControls(); } - - PCB_BASE_EDIT_FRAME* frame() const - { + + PCB_BASE_EDIT_FRAME* frame() const + { return getEditFrame(); } - + BOARD* board() const { return getModel(); } - + MODULE* module() const { return board()->GetFirstModule(); } - + const PCB_DISPLAY_OPTIONS& displayOptions() const; PCB_DRAW_PANEL_GAL* canvas() const; const PCBNEW_SELECTION& selection() const; diff --git a/pcbnew/tools/zone_create_helper.h b/pcbnew/tools/zone_create_helper.h index b996c17349..3bebfed65d 100644 --- a/pcbnew/tools/zone_create_helper.h +++ b/pcbnew/tools/zone_create_helper.h @@ -71,7 +71,7 @@ public: */ ZONE_CREATE_HELPER( DRAWING_TOOL& aTool, PARAMS& aParams ); - ~ZONE_CREATE_HELPER(); + virtual ~ZONE_CREATE_HELPER(); /* * Interface for receiving POLYGON_GEOM_MANAGER update diff --git a/qa/pcbnew_tools/tools/drc_tool/drc_tool.cpp b/qa/pcbnew_tools/tools/drc_tool/drc_tool.cpp index fdfb1dfdcc..57576926df 100644 --- a/qa/pcbnew_tools/tools/drc_tool/drc_tool.cpp +++ b/qa/pcbnew_tools/tools/drc_tool/drc_tool.cpp @@ -64,6 +64,10 @@ public: { } + virtual ~DRC_RUNNER() + { + } + void Execute( BOARD& aBoard ) { if( m_exec_context.m_verbose ) @@ -151,6 +155,10 @@ public: { } + virtual ~DRC_COURTYARD_OVERLAP_RUNNER() + { + } + private: std::string getRunnerIntro() const override { @@ -184,6 +192,10 @@ public: { } + virtual ~DRC_COURTYARD_MISSING_RUNNER() + { + } + private: std::string getRunnerIntro() const override {