From 43161ca0d7ae4731d062ca65d551a2f20a1e63ad Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Fri, 4 Mar 2022 06:14:55 -0600 Subject: [PATCH 1/3] Fix showing a dialog multiple times After the dialog is displayed, always clear it out. If we don't, we won't be able to display another! * regressed in #12517. * [x] Fixes #12622. --- src/cascadia/TerminalApp/AppLogic.cpp | 6 +++++- src/cascadia/TerminalSettingsEditor/Profiles_Base.xaml | 9 --------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/cascadia/TerminalApp/AppLogic.cpp b/src/cascadia/TerminalApp/AppLogic.cpp index 71698f7c4c2..c3c64ee4e24 100644 --- a/src/cascadia/TerminalApp/AppLogic.cpp +++ b/src/cascadia/TerminalApp/AppLogic.cpp @@ -380,7 +380,11 @@ namespace winrt::TerminalApp::implementation auto loadedRevoker{ dialog.Loaded(winrt::auto_revoke, themingLambda) }; // if it's not yet in the tree // Display the dialog. - co_return co_await dialog.ShowAsync(Controls::ContentDialogPlacement::Popup); + const auto result = co_await dialog.ShowAsync(Controls::ContentDialogPlacement::Popup); + // GH#12622: After the dialog is displayed, always clear it out. If we + // don't, we won't be able to display another! + _dialog = nullptr; + co_return result; // After the dialog is dismissed, the dialog lock (held by `lock`) will // be released so another can be shown diff --git a/src/cascadia/TerminalSettingsEditor/Profiles_Base.xaml b/src/cascadia/TerminalSettingsEditor/Profiles_Base.xaml index 4f593012110..08ae38cca66 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles_Base.xaml +++ b/src/cascadia/TerminalSettingsEditor/Profiles_Base.xaml @@ -130,15 +130,6 @@ Text="{x:Bind Profile.TabTitle, Mode=TwoWay}" /> - - - - - From f0bf880c3ab722b6187b86196494c0e5879ce8f9 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Fri, 4 Mar 2022 06:19:15 -0600 Subject: [PATCH 2/3] oops this shouldn't be there --- src/cascadia/TerminalSettingsEditor/Profiles_Base.xaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/cascadia/TerminalSettingsEditor/Profiles_Base.xaml b/src/cascadia/TerminalSettingsEditor/Profiles_Base.xaml index 08ae38cca66..4f593012110 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles_Base.xaml +++ b/src/cascadia/TerminalSettingsEditor/Profiles_Base.xaml @@ -130,6 +130,15 @@ Text="{x:Bind Profile.TabTitle, Mode=TwoWay}" /> + + + + + From 2879ec2373da1ce9d5f58d10315a664ffa19c7a5 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Wed, 9 Mar 2022 06:03:48 -0600 Subject: [PATCH 3/3] this is cleaner --- src/cascadia/TerminalApp/AppLogic.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cascadia/TerminalApp/AppLogic.cpp b/src/cascadia/TerminalApp/AppLogic.cpp index c3c64ee4e24..0d8cb34fa2f 100644 --- a/src/cascadia/TerminalApp/AppLogic.cpp +++ b/src/cascadia/TerminalApp/AppLogic.cpp @@ -348,7 +348,11 @@ namespace winrt::TerminalApp::implementation } _dialog = dialog; - + // GH#12622: After the dialog is displayed, always clear it out. If we + // don't, we won't be able to display another! + const auto cleanup = wil::scope_exit([this]() { + _dialog = nullptr; + }); // IMPORTANT: This is necessary as documented in the ContentDialog MSDN docs. // Since we're hosting the dialog in a Xaml island, we need to connect it to the // xaml tree somehow. @@ -380,11 +384,7 @@ namespace winrt::TerminalApp::implementation auto loadedRevoker{ dialog.Loaded(winrt::auto_revoke, themingLambda) }; // if it's not yet in the tree // Display the dialog. - const auto result = co_await dialog.ShowAsync(Controls::ContentDialogPlacement::Popup); - // GH#12622: After the dialog is displayed, always clear it out. If we - // don't, we won't be able to display another! - _dialog = nullptr; - co_return result; + co_return co_await dialog.ShowAsync(Controls::ContentDialogPlacement::Popup); // After the dialog is dismissed, the dialog lock (held by `lock`) will // be released so another can be shown