From 91c3ddf6920d3f043eff9e724c6b69f593e3ca7c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 2 Dec 2016 19:30:58 +0100 Subject: [PATCH] - fixed: When a tentative class is being replaced, the old one should be removed entirely so that it cannot cause any problems later. --- src/dobjtype.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index c33caf12f..5e1316d71 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -3330,11 +3330,15 @@ PClass *PClass::CreateDerivedClass(FName name, unsigned int size) } else { + TypeTable.ReplaceType(type, existclass, bucket); StaticPointerSubstitution(existclass, type, true); // replace the old one, also in the actor defaults. - // Delete the old class from the actor classes list, if it is in there. + // Delete the old class from the class lists, both the full one and the actor list. auto index = PClassActor::AllActorClasses.Find(static_cast(existclass)); if (index < PClassActor::AllActorClasses.Size()) PClassActor::AllActorClasses.Delete(index); - TypeTable.ReplaceType(type, existclass, bucket); + index = PClass::AllClasses.Find(existclass); + if (index < PClass::AllClasses.Size()) PClass::AllClasses.Delete(index); + // Now we can destroy the old class as nothing should reference it anymore + existclass->Destroy(); } return type; }