Fix WindowRoot memory leak in SUI#19826
Merged
carlos-zamora merged 3 commits intomainfrom Feb 3, 2026
Merged
Conversation
DHowett
reviewed
Feb 3, 2026
| _WeakWindowRoot(windowRoot) {} | ||
|
|
||
| Editor::IHostedInWindow WindowRoot() const noexcept { return _WindowRoot; } | ||
| Editor::IHostedInWindow WindowRoot() const noexcept { return _WeakWindowRoot ? _WeakWindowRoot.get() : nullptr; } |
Member
There was a problem hiding this comment.
in some places you do weak ? weak.get : nullptr, and in others you just do weak.get; why the difference?
(fwiw i think weak.get returns nullptr properly on its own when you'd expect it to)
Member
Author
There was a problem hiding this comment.
I think I tried to make all of them consistent. But if weak.get() already returns nullptr properly, I'll just use that tbh.
| const auto list = NewTabMenuListView(); | ||
| MoveToFolderButton().IsEnabled(list.SelectedItems().Size() > 0); | ||
| DeleteMultipleButton().IsEnabled(list.SelectedItems().Size() > 0); | ||
| NewTabMenuListView().SelectionChanged([weakThis = get_weak()](auto&&, auto&&) { |
Member
There was a problem hiding this comment.
will the selection conceivably change after this has been destructed?
Member
There was a problem hiding this comment.
if not, this doesn't need to be a weak reference.
lhecker
approved these changes
Feb 3, 2026
DHowett
approved these changes
Feb 3, 2026
Comment on lines
-28
to
-30
| const auto list = NewTabMenuListView(); | ||
| MoveToFolderButton().IsEnabled(list.SelectedItems().Size() > 0); | ||
| DeleteMultipleButton().IsEnabled(list.SelectedItems().Size() > 0); |
Member
There was a problem hiding this comment.
the code was fine as it was, but I'm not blocking over this change
DHowett
pushed a commit
that referenced
this pull request
Feb 10, 2026
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.
Summary of the Pull Request
Fixes a memory leak for
IHostedInWindowin the TerminalSettingsEditor.The memory leak occurs from
MainPagecreating an object that stores reference to back toMainPageasIHostedInWindow. WithIconPickerspecifically, the cycle would look likeMainPage-->NewTabMenu-->IconPicker-->MainPage.I've audited uses of
IHostedInWindowin the TerminalSettingsEditor and replaced them as weak references. I also checked areas thatWindowRoot()was called and added a null-check for safety.Validation Steps Performed
Verified
MainPageandNewTabMenudtors are called when the settings UI closes from...✅ Launch page (base case - it doesn't have an
IHostedInWindow)✅ New Tab Menu page