Re: [CrystalSpace] #985: FIx compiler warning about non-virtual destructor for class LightComponent (fix included)
"CrystalSpace" <[email protected]> Sat, 06 Jul 2013 00:22:36 -0000
| Newsgroups | gmane.comp.graphics.crystalspace.tracker |
|---|---|
| Message-ID | <[email protected]> |
#985: FIx compiler warning about non-virtual destructor for class LightComponent
(fix included)
--------------------------------+-------------------------------------------
Reporter: ralphcampbell | Owner: admin
Type: defect | Status: new
Priority: minor | Milestone:
Component: other applications | Version: V2.1
Keywords: |
--------------------------------+-------------------------------------------
Description changed by sunshine:
Old description:
> I got this compiler warning with --enable-debug:
>
> {{{
> apps/tools/lighter2/scene.cpp:742:43: warning: deleting object of
> polymorphic class type ‘lighter::RaytracerLighting’ which has non-virtual
> destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
> apps/tools/lighter2/scene.cpp:743:46: warning: deleting object of
> polymorphic class type ‘lighter::PhotonmapperLighting’ which has non-
> virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-
> dtor]
> }}}
>
> The fix is simple:
>
> {{{
> Index: apps/tools/lighter2/lightcomponent.h
> ===================================================================
> --- apps/tools/lighter2/lightcomponent.h (revision 39458)
> +++ apps/tools/lighter2/lightcomponent.h (working copy)
> @@ -36,7 +36,7 @@
> public:
> // Setup
> LightComponent ();
> - ~LightComponent ();
> + virtual ~LightComponent ();
>
> bool SupportsPDLights ();
>
> Index: apps/tools/lighter2/photonmapperlighting.h
> ===================================================================
> --- apps/tools/lighter2/photonmapperlighting.h (revision 39458)
> +++ apps/tools/lighter2/photonmapperlighting.h (working copy)
> @@ -60,7 +60,7 @@
> public:
> // Setup
> PhotonmapperLighting ();
> - ~PhotonmapperLighting ();
> + virtual ~PhotonmapperLighting ();
>
> virtual csColor ComputeElementLightingComponent(Sector* sector,
> ElementProxy element, SamplerSequence<2>& lightSampler,
> Index: apps/tools/lighter2/raytracerlighting.h
> ===================================================================
> --- apps/tools/lighter2/raytracerlighting.h (revision 39458)
> +++ apps/tools/lighter2/raytracerlighting.h (working copy)
> @@ -43,7 +43,7 @@
> public:
> // Setup
> RaytracerLighting (const csVector3& tangentSpaceNorm, size_t
> subLightmapNum);
> - ~RaytracerLighting ();
> + virtual ~RaytracerLighting ();
>
> virtual csColor ComputeElementLightingComponent(Sector* sector,
> ElementProxy element, SamplerSequence<2>& lightSampler,
> }}}
New description:
I got this compiler warning with `--enable-debug`:
{{{
apps/tools/lighter2/scene.cpp:742:43: warning: deleting object of
polymorphic class type ‘lighter::RaytracerLighting’ which has non-virtual
destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
apps/tools/lighter2/scene.cpp:743:46: warning: deleting object of
polymorphic class type ‘lighter::PhotonmapperLighting’ which has non-
virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-
dtor]
}}}
The fix is simple:
{{{
#!diff
Index: apps/tools/lighter2/lightcomponent.h
===================================================================
--- apps/tools/lighter2/lightcomponent.h (revision 39458)
+++ apps/tools/lighter2/lightcomponent.h (working copy)
@@ -36,7 +36,7 @@
public:
// Setup
LightComponent ();
- ~LightComponent ();
+ virtual ~LightComponent ();
bool SupportsPDLights ();
Index: apps/tools/lighter2/photonmapperlighting.h
===================================================================
--- apps/tools/lighter2/photonmapperlighting.h (revision 39458)
+++ apps/tools/lighter2/photonmapperlighting.h (working copy)
@@ -60,7 +60,7 @@
public:
// Setup
PhotonmapperLighting ();
- ~PhotonmapperLighting ();
+ virtual ~PhotonmapperLighting ();
virtual csColor ComputeElementLightingComponent(Sector* sector,
ElementProxy element, SamplerSequence<2>& lightSampler,
Index: apps/tools/lighter2/raytracerlighting.h
===================================================================
--- apps/tools/lighter2/raytracerlighting.h (revision 39458)
+++ apps/tools/lighter2/raytracerlighting.h (working copy)
@@ -43,7 +43,7 @@
public:
// Setup
RaytracerLighting (const csVector3& tangentSpaceNorm, size_t
subLightmapNum);
- ~RaytracerLighting ();
+ virtual ~RaytracerLighting ();
virtual csColor ComputeElementLightingComponent(Sector* sector,
ElementProxy element, SamplerSequence<2>& lightSampler,
}}}
--
--
Ticket URL: <http://www.crystalspace3d.org/trac/CS/ticket/985#comment:1>
CrystalSpace <http://www.crystalspace3d.org/>
Free open-source 3D SDK.
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
crystal-tracker mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crystal-tracker