Skip to content

Commit

Permalink
- fixed potential garbage collection of still referenced objects
Browse files Browse the repository at this point in the history
Objects from dynamic array stored in items of array of structures were incorrectly treated as unreachable

https://forum.zdoom.org/viewtopic.php?t=61354
  • Loading branch information
alexey-lysiuk authored and coelckers committed Jul 28, 2018
1 parent 7e69cd8 commit e9041c0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/scripting/types.cpp
Expand Up @@ -1748,6 +1748,23 @@ void PArray::SetPointer(void *base, unsigned offset, TArray<size_t> *special)
}
}

//==========================================================================
//
// PArray :: SetPointerArray
//
//==========================================================================

void PArray::SetPointerArray(void *base, unsigned offset, TArray<size_t> *special)
{
if (ElementType->isStruct())
{
for (unsigned int i = 0; i < ElementCount; ++i)
{
ElementType->SetPointerArray(base, offset + ElementSize * i, special);
}
}
}

//==========================================================================
//
// NewArray
Expand Down
1 change: 1 addition & 0 deletions src/scripting/types.h
Expand Up @@ -485,6 +485,7 @@ class PArray : public PCompoundType

void SetDefaultValue(void *base, unsigned offset, TArray<FTypeAndOffset> *special) override;
void SetPointer(void *base, unsigned offset, TArray<size_t> *special) override;
void SetPointerArray(void *base, unsigned offset, TArray<size_t> *ptrofs = NULL) override;
};

class PStaticArray : public PArray
Expand Down

0 comments on commit e9041c0

Please sign in to comment.