- fixed: Dynamic arrays of objects in structs were not registered for garbage collection.

This commit is contained in:
Christoph Oelckers 2017-04-15 13:20:58 +02:00
parent 069e4e9b0b
commit 2d0da4fcfa
2 changed files with 25 additions and 4 deletions

View file

@ -183,7 +183,7 @@ void PType::SetPointer(void *base, unsigned offset, TArray<size_t> *stroffs)
{
}
void PType::SetPointerArray(void *base, unsigned offset, TArray<size_t> *stroffs) const
void PType::SetPointerArray(void *base, unsigned offset, TArray<size_t> *stroffs)
{
}
@ -1951,7 +1951,7 @@ void PDynArray::SetDefaultValue(void *base, unsigned offset, TArray<FTypeAndOffs
//
//==========================================================================
void PDynArray::SetPointerArray(void *base, unsigned offset, TArray<size_t> *special) const
void PDynArray::SetPointerArray(void *base, unsigned offset, TArray<size_t> *special)
{
if (ElementType->isObjectPointer())
{
@ -2185,6 +2185,26 @@ void PStruct::SetPointer(void *base, unsigned offset, TArray<size_t> *special)
}
}
//==========================================================================
//
// PStruct :: SetPointerArray
//
//==========================================================================
void PStruct::SetPointerArray(void *base, unsigned offset, TArray<size_t> *special)
{
auto it = Symbols.GetIterator();
PSymbolTable::MapType::Pair *pair;
while (it.NextPair(pair))
{
auto field = dyn_cast<PField>(pair->Value);
if (field && !(field->Flags & VARF_Transient))
{
field->Type->SetPointerArray(base, unsigned(offset + field->Offset), special);
}
}
}
//==========================================================================
//
// PStruct :: WriteValue

View file

@ -125,7 +125,7 @@ public:
// object is destroyed.
virtual void SetDefaultValue(void *base, unsigned offset, TArray<FTypeAndOffset> *special=NULL);
virtual void SetPointer(void *base, unsigned offset, TArray<size_t> *ptrofs = NULL);
virtual void SetPointerArray(void *base, unsigned offset, TArray<size_t> *ptrofs = NULL) const;
virtual void SetPointerArray(void *base, unsigned offset, TArray<size_t> *ptrofs = NULL);
// Initialize the value, if needed (e.g. strings)
virtual void InitializeValue(void *addr, const void *def) const;
@ -512,7 +512,7 @@ public:
void SetDefaultValue(void *base, unsigned offset, TArray<FTypeAndOffset> *specials) override;
void InitializeValue(void *addr, const void *def) const override;
void DestroyValue(void *addr) const override;
void SetPointerArray(void *base, unsigned offset, TArray<size_t> *ptrofs = NULL) const override;
void SetPointerArray(void *base, unsigned offset, TArray<size_t> *ptrofs = NULL) override;
};
class PMap : public PCompoundType
@ -544,6 +544,7 @@ public:
bool ReadValue(FSerializer &ar, const char *key,void *addr) const override;
void SetDefaultValue(void *base, unsigned offset, TArray<FTypeAndOffset> *specials) override;
void SetPointer(void *base, unsigned offset, TArray<size_t> *specials) override;
void SetPointerArray(void *base, unsigned offset, TArray<size_t> *special) override;
};
class PPrototype : public PCompoundType