Announcement

Collapse
No announcement yet.

Is this a memory leak in slate API?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Is this a memory leak in slate API?

    I am writing plugins for Unreal Engine 4 and I have noticed something strange about using widget Slots. for example when you write
    Code:
    + SHorizontalBox::Slot()
    this is being called


    Code:
    static FSlot& Slot()
    {
        return *(new FSlot());
    }

    can you find where this pointer is deleted? I could find nothing. the `+` operator for adding slots is given to you by this macro

    Code:
    SLATE_BEGIN_ARGS(SHorizontalBox)
    ...
    SLATE_SUPPORTS_SLOT(SHorizontalBox::FSlot)
    ...
    SLATE_END_ARGS(SHorizontalBox)
    which becomes

    Code:
    TArray< SHorizontalBox::FSlot* > Slots;
    WidgetArgsType& operator + (SHorizontalBox::FSlot& SlotToAdd)
    {
        Slots.Add( &SlotToAdd );
        return *this;
    }
    and that's all there is.

    Now I'm wondering when this slot object allocated on heap is destroyed? does TArray automatically delete pointers? how?
    Last edited by KazemAkhgary; 11-25-2020, 07:53 AM.
Working...
X