2019-12-12 04:20 CET

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000904Spring engineGeneralpublic2008-04-30 13:10
Reporterzenzike 
Assigned Totvo 
PrioritynormalSeveritytrivialReproducibilityalways
StatusresolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0000904: [patch] UnitDef.h non-virtual destructor
DescriptionThe destructor in UnitDef.h is not virtual.

Patch included.
Additional InformationIndex: /home/nick/projects/spring/rts/Sim/Units/UnitDef.h
===================================================================
--- /home/nick/projects/spring/rts/Sim/Units/UnitDef.h (revision 5796)
+++ /home/nick/projects/spring/rts/Sim/Units/UnitDef.h (working copy)
@@ -89,7 +89,7 @@
 {
     CR_DECLARE(UnitDef);
     UnitDef() : valid(false) {}
- ~UnitDef();
+ virtual ~UnitDef();
     S3DOModel* LoadModel(int team) const;
 
     UnitImage* unitImage; // GLuint wrapper pointing to build-pic data of this unit type
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files

-Relationships
related to 0000905resolvedtvo [patch] WeaponDefHandler.h non-virtual destructor 
+Relationships

-Notes

~0002170

tvo (reporter)

UnitDef is basically just data storage (just structure in the C-sense, not class in object oriented sense).

Is virtual dtor really needed? (Could be because of creg, ie. the CR_DECLARE thing.)

Did you get compiler warnings about it?

~0002171

zenzike (reporter)

Are you happy for me to just paste the patch in "Additional Information", or would you rather I actually upload a file?

~0002173

zenzike (reporter)

Yes, with both of these I had a compiler warning. They both include types that have some virtual functions, so the destructor ought to be virtual.

~0002188

tvo (reporter)

I probably solved it by using CR_DECLARE_STRUCT instead of CR_DECLARE in the UnitDef. (CR_* is our "class registration system", ie. reflection for C++, and CR_DECLARE_STRUCT defines the GetClass method as non-virtual while CR_DECLARE defines it as virtual.)

This is better then making dtor virtual because the class really isn't supposed to have any virtual functions. (Since it's just a large collection of unit/weapon properties.)

Please reopen if this didn't solve compiler warning.
+Notes

-Issue History
Date Modified Username Field Change
2008-04-28 12:34 zenzike New Issue
2008-04-28 15:34 tvo Summary UnitDef.h non-virtual destructor => [patch] UnitDef.h non-virtual destructor
2008-04-28 15:35 tvo Note Added: 0002170
2008-04-28 15:36 tvo Relationship added related to 0000905
2008-04-28 15:36 zenzike Note Added: 0002171
2008-04-28 15:37 zenzike Note Added: 0002173
2008-04-30 13:10 tvo Status new => assigned
2008-04-30 13:10 tvo Assigned To => tvo
2008-04-30 13:10 tvo Status assigned => resolved
2008-04-30 13:10 tvo Resolution open => fixed
2008-04-30 13:10 tvo Note Added: 0002188
+Issue History