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 a crash during settings update #17751

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/cascadia/TerminalApp/TerminalWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,13 +767,22 @@ namespace winrt::TerminalApp::implementation
// definitely not on OUR UI thread.
winrt::fire_and_forget TerminalWindow::UpdateSettings(winrt::TerminalApp::SettingsLoadEventArgs args)
{
_settings = args.NewSettings();
// GH#17620: We have a bug somewhere where a window doesn't get unregistered from the window list.
// This causes UpdateSettings calls where the thread dispatcher is already null.
const auto dispatcher = _root->Dispatcher();
if (!dispatcher)
{
co_return;
}

const auto weakThis{ get_weak() };
co_await wil::resume_foreground(_root->Dispatcher());
co_await wil::resume_foreground(dispatcher);

// Back on our UI thread...
if (auto logic{ weakThis.get() })
{
_settings = args.NewSettings();

// Update the settings in TerminalPage
// We're on our UI thread right now, so this is safe
_root->SetSettings(_settings, true);
Expand Down
Loading