Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix circular TermControl reference #14228

Merged
2 commits merged into from
Oct 17, 2022
Merged

Fix circular TermControl reference #14228

2 commits merged into from
Oct 17, 2022

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Oct 15, 2022

This regression was introduced in b3c9f01. Since TermControl is the XAML
object that owns its scrollbar and the scrollbar's VisualStateManager
a strong reference back to the TermControl results in a circular reference.

Validation Steps Performed

  • Set a breakpoint on TermControl::~TermControl()
  • Breakpoint hits on tab close ✅

@lhecker lhecker added Issue-Bug It either shouldn't be doing this or needs an investigation. Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Product-Terminal The new Windows Terminal. Priority-1 A description (P1) labels Oct 15, 2022
@lhecker lhecker added this to the Terminal v1.17 milestone Oct 15, 2022
Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, won't this break hot reloading for that setting?

If our options are (1) break hot reload (2) propagate an UpdateSettings call into the new VSM, or (3) be moderate inefficient, I'd much rather we just go for 3 and look up the parent and query the settings every time

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Oct 17, 2022
@@ -20,12 +20,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation
{
struct ScrollBarVisualStateManager : ScrollBarVisualStateManagerT<ScrollBarVisualStateManager>
{
ScrollBarVisualStateManager();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think now that you removed the ctor, you should be able to remove the factory too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still has a constructor - it's just automatically generated by the compiler now. I tested it and it seems like it still needs the factory to exist.

@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Oct 17, 2022
@lhecker
Copy link
Member Author

lhecker commented Oct 17, 2022

@DHowett Pending on the CI the issue should be fixed now. I fixed it by simply using a get_weak() reference. The behavior is still a bit "bodgy" however. If you change the setting you have to hover over the scrollbar once for it to take effect. But I'm certain that this was already the case before this PR.

@DHowett DHowett added the AutoMerge Marked for automatic merge by the bot when requirements are met label Oct 17, 2022
@ghost
Copy link

ghost commented Oct 17, 2022

Hello @DHowett!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit bfd480b into main Oct 17, 2022
@ghost ghost deleted the dev/lhecker/termcontrol-leak branch October 17, 2022 21:14
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-1 A description (P1) Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants