View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0000904 | Spring engine | General | public | 2008-04-28 12:34 | 2008-04-30 13:10 |
| Reporter | zenzike | Assigned To | tvo | ||
| Priority | normal | Severity | trivial | Reproducibility | always |
| Status | resolved | Resolution | fixed | ||
| Summary | 0000904: [patch] UnitDef.h non-virtual destructor | ||||
| Description | The destructor in UnitDef.h is not virtual. Patch included. | ||||
| Additional Information | Index: /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 | ||||
| Tags | No tags attached. | ||||
| Checked infolog.txt for Errors | |||||
|
|
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? |
|
|
Are you happy for me to just paste the patch in "Additional Information", or would you rather I actually upload a file? |
|
|
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. |
|
|
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. |
| 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 |