Skip to content

Fix cyclic reference between Unit and UnitCategory

Volker Krause requested to merge work/fix-reference-cycle into master

This made Unit/UnitCategory practically undeletable, as seen for example by the numerous valgrind/LSAN complaints for the unit tests. To solve this the reference to UnitCategory inside Unit is now just a raw pointer.

This is unfortunately not the only problem here, UnitCategory being polymorphic but treated as a value type causes slicing. This works by chance as the sub-classes only contain logic in their ctor, but have no member variables or overloaded methods. This is why this solution works, but the slicing also happened before already.

Merge request reports