Prevent RPC_E_CANTCALLOUT_ININPUTSYNCCALL during WM_SETTINGCHANGE (#19755)

Closes #19505
This commit is contained in:
Leonard Hecker 2026-01-19 18:56:53 +01:00 committed by GitHub
parent 0ee3cfb3fd
commit e8971c80ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 20 additions and 4 deletions

View File

@ -141,6 +141,7 @@ BValue
Cacafire
CALLCONV
CANDRABINDU
CANTCALLOUT
capslock
CARETBLINKINGENABLED
CARRIAGERETURN
@ -808,6 +809,7 @@ INCONTEXT
INDEXID
INFOEX
inheritcursor
ININPUTSYNCCALL
INITCOMMONCONTROLSEX
INITDIALOG
INITGUID

View File

@ -149,7 +149,9 @@ namespace winrt::TerminalApp::implementation
});
_languageProfileNotifier = winrt::make_self<LanguageProfileNotifier>([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()
{

View File

@ -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();

View File

@ -25,6 +25,7 @@ namespace TerminalApp
Boolean HasSettingsStartupActions();
void ReloadSettings();
void ReloadSettingsThrottled();
Microsoft.Terminal.Settings.Model.CascadiaSettings Settings { get; };
TerminalWindow CreateNewWindow();

View File

@ -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;