diff --git a/.github/actions/spelling/expect/expect.txt b/.github/actions/spelling/expect/expect.txt index b2961cb7f3..8c1e4ab6c3 100644 --- a/.github/actions/spelling/expect/expect.txt +++ b/.github/actions/spelling/expect/expect.txt @@ -141,6 +141,7 @@ BValue Cacafire CALLCONV CANDRABINDU +CANTCALLOUT capslock CARETBLINKINGENABLED CARRIAGERETURN @@ -808,6 +809,7 @@ INCONTEXT INDEXID INFOEX inheritcursor +ININPUTSYNCCALL INITCOMMONCONTROLSEX INITDIALOG INITGUID diff --git a/src/cascadia/TerminalApp/AppLogic.cpp b/src/cascadia/TerminalApp/AppLogic.cpp index 9fdec92368..f601ec8cf1 100644 --- a/src/cascadia/TerminalApp/AppLogic.cpp +++ b/src/cascadia/TerminalApp/AppLogic.cpp @@ -149,7 +149,9 @@ namespace winrt::TerminalApp::implementation }); _languageProfileNotifier = winrt::make_self([this]() { - _reloadSettings->Run(); + // TODO: This is really bad, because we reset any current user customizations. + // See GH#11522. + ReloadSettingsThrottled(); }); // Do this here, rather than at the top of main. This will prevent us from @@ -329,7 +331,7 @@ namespace winrt::TerminalApp::implementation if (modifiedBasename == settingsBasename) { - _reloadSettings->Run(); + ReloadSettingsThrottled(); } }); } @@ -435,6 +437,11 @@ namespace winrt::TerminalApp::implementation SettingsChanged.raise(*this, *ev); } + void AppLogic::ReloadSettingsThrottled() + { + _reloadSettings->Run(); + } + // This is a continuation of AppLogic::Create() and includes the more expensive parts. void AppLogic::NotifyRootInitialized() { diff --git a/src/cascadia/TerminalApp/AppLogic.h b/src/cascadia/TerminalApp/AppLogic.h index f992561632..2b5a467f85 100644 --- a/src/cascadia/TerminalApp/AppLogic.h +++ b/src/cascadia/TerminalApp/AppLogic.h @@ -36,6 +36,7 @@ namespace winrt::TerminalApp::implementation bool IsRunningElevated() const noexcept; bool CanDragDrop() const noexcept; void ReloadSettings(); + void ReloadSettingsThrottled(); void NotifyRootInitialized(); bool HasSettingsStartupActions() const noexcept; @@ -80,7 +81,6 @@ namespace winrt::TerminalApp::implementation [[nodiscard]] HRESULT _TryLoadSettings() noexcept; void _ProcessLazySettingsChanges(); void _RegisterSettingsChange(); - safe_void_coroutine _DispatchReloadSettings(); void _setupFolderPathEnvVar(); diff --git a/src/cascadia/TerminalApp/AppLogic.idl b/src/cascadia/TerminalApp/AppLogic.idl index 4f6bc262c3..eee6c311a0 100644 --- a/src/cascadia/TerminalApp/AppLogic.idl +++ b/src/cascadia/TerminalApp/AppLogic.idl @@ -25,6 +25,7 @@ namespace TerminalApp Boolean HasSettingsStartupActions(); void ReloadSettings(); + void ReloadSettingsThrottled(); Microsoft.Terminal.Settings.Model.CascadiaSettings Settings { get; }; TerminalWindow CreateNewWindow(); diff --git a/src/cascadia/WindowsTerminal/WindowEmperor.cpp b/src/cascadia/WindowsTerminal/WindowEmperor.cpp index 64fb25e02f..07e96fcc2e 100644 --- a/src/cascadia/WindowsTerminal/WindowEmperor.cpp +++ b/src/cascadia/WindowsTerminal/WindowEmperor.cpp @@ -994,7 +994,13 @@ LRESULT WindowEmperor::_messageHandler(HWND window, UINT const message, WPARAM c if (isCurrentlyDark != _currentSystemThemeIsDark) { _currentSystemThemeIsDark = isCurrentlyDark; - _app.Logic().ReloadSettings(); + + // GH#19505: WM_SETTINGCHANGE gets sent out with a SendMessage() call, which means + // that COM methods marked as [input_sync] cannot be called. Well, our CascadiaSettings + // loader does call such methods. This results in RPC_E_CANTCALLOUT_ININPUTSYNCCALL, aka: + // "An outgoing call cannot be made since the application is dispatching an input-synchronous call." + // The solution is to simply do it in another tick. + _app.Logic().ReloadSettingsThrottled(); } } return 0;