Fix cyclic TSharedPtr references causing memory leaks in item UI widgets#27
Draft
Copilot wants to merge 7 commits into
Draft
Fix cyclic TSharedPtr references causing memory leaks in item UI widgets#27Copilot wants to merge 7 commits into
Copilot wants to merge 7 commits into
Conversation
…temInventoryWidget, etc.) Co-authored-by: SodiumZH <46860829+SodiumZH@users.noreply.github.com>
Co-authored-by: SodiumZH <46860829+SodiumZH@users.noreply.github.com>
Co-authored-by: SodiumZH <46860829+SodiumZH@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add slate widget for custom inventory canvas
Add SNaInventoryCanvas and UNaInventoryCanvas for canvas-based inventory UI
Feb 27, 2026
- SNaItemSlot: BindSP→BindRaw/CreateRaw in BoxSlot delegate bindings to break parent↔child cycle - SNaInventoryWrappedBox: AddSP→AddRaw in BindEventsToUMG to break self-referential cycle - SNaInventoryCanvas: BindSP/CreateSP→BindRaw/CreateRaw in both BindSlotEvents and BindEventsToUMG - NaItemSlotList UMG: TSharedRef→TSharedPtr for List member (TSharedRef has no default ctor/Reset) - Fix broken SLATE_ATTRIBUTE types in SNaInventoryWrappedBox and SNaItemSlot headers - Add UMGRef assignment in SNaInventoryWrappedBox::Construct (was never set) - Change UMGRef to TWeakObjectPtr in SNaInventoryWrappedBox and SNaInventoryCanvas - Add validity checks in all SlotXxxToUMG() functions Co-authored-by: SodiumZH <46860829+SodiumZH@users.noreply.github.com>
Copilot
AI
changed the title
Add SNaInventoryCanvas and UNaInventoryCanvas for canvas-based inventory UI
Fix cyclic TSharedPtr references causing memory leaks in item UI widgets
Feb 28, 2026
…UI widgets" This reverts commit 5b15a29.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Slate widget trees had multiple cyclic
TSharedPtrreference patterns preventing ref counts from ever reaching zero — widgets were never freed.Cycles fixed
TSharedPtr<SNaBoxSlot>, child delegates heldTSharedPtrback to parent viaBindSPBindEventsToUMG()calledOnSlotXxx.AddSP(this, ...)on own member delegates — permanent self-referenceTSharedPtr, child BoxSlot delegates heldTSharedPtrback to canvas viaCreateSPAll resolved by switching to
BindRaw/CreateRaw— safe because child widgets cannot outlive their parent in the Slate tree:Additional fixes
UNaItemSlotList::List:TSharedRef→TSharedPtr(TSharedRef has no default ctor /Reset())UMGRef: RawUObject*→TWeakObjectPtrin bothSNaInventoryWrappedBoxandSNaInventoryCanvas, with validity checks in allSlotXxxToUMG()forwardersSNaInventoryWrappedBox::Construct:UMGRefwas never assigned fromInArgs._FromUMG—BindEventsToUMG()was always a no-opTSharedRef<FNaItemSlotStyle>→FNaItemSlotStyle*, wrongContainertype, invalidTWeakObjectPtr<UNaItemSlotList*>syntax)SNaItemSlot::StylePtr:TSharedPtr<FNaItemSlotStyle>→ raw pointer (style is stack-owned by UMG widget,TSharedPtrwould double-free)SNaItemSlot::ItemSlotList:TWeakPtr→ raw pointer (child→parent back-ref;TWeakPtrcan't be assigned from raw ptr, broke compilation)🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.