-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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 a crash when closing tabs #18620
Fix a crash when closing tabs #18620
Conversation
@@ -851,6 +851,9 @@ namespace winrt::TerminalApp::implementation | |||
{ | |||
ASSERT_UI_THREAD(); | |||
|
|||
// Don't forget to call the overridden function. :) | |||
TabBase::Shutdown(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(FWIW this is a Crucial part of this PR as it sets the content to null. Also, TIL: We have a tab content that is different from the pane content. Was slightly confused by that naming.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zadjii-msft I thought we merged terminaltab back into tabbase 😢
@@ -851,6 +851,9 @@ namespace winrt::TerminalApp::implementation | |||
{ | |||
ASSERT_UI_THREAD(); | |||
|
|||
// Don't forget to call the overridden function. :) | |||
TabBase::Shutdown(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zadjii-msft I thought we merged terminaltab back into tabbase 😢
@@ -903,19 +905,39 @@ namespace winrt::TerminalApp::implementation | |||
if (_tabPointerMiddleButtonPressed && !eventArgs.GetCurrentPoint(nullptr).Properties().IsMiddleButtonPressed()) | |||
{ | |||
_tabPointerMiddleButtonPressed = false; | |||
if (const auto tabViewItem{ sender.try_as<MUX::Controls::TabViewItem>() }) | |||
if (auto tabViewItem = sender.try_as<MUX::Controls::TabViewItem>()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the syntax change? was the previous one wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we're alone in our usage of the auto foo{ ... }
syntax. Not even the C++ Core Guidelines use it: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-auto
As you know, the brace-initializer syntax is historically overladen and rather brittle, so I see people recommend using it only for constructing explicitly named types, and I concur. In fact, since ~C++20 it's actually been going back from there with the consortium's trend towards "we can be like Rust if we have static analyzers", hence members recommending even things like int foo = bar()
, despite the risk for unintentional narrowing.
62e7f4b
into
main
WinUI asynchronously updates its tab view items, so it may happen that we're given a `TabViewItem` that still contains a `TabBase` which has actually already been removed. Regressed in #15924. Closes #18581 ## Validation Steps Performed * Close tabs rapidly with middle click * No crash ✅ (cherry picked from commit 62e7f4b) Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgXpjpM PVTI_lADOAF3p4s4AxadtzgXsRQM Service-Version: 1.23
Is this fix related to that crash #18458 ? |
WinUI asynchronously updates its tab view items, so it may happen that
we're given a
TabViewItem
that still contains aTabBase
which hasactually already been removed. Regressed in #15924.
Closes #18581
Validation Steps Performed