HAX to make it crash less

This commit is contained in:
Dustin L. Howett 2025-12-03 23:29:07 -06:00
parent 09ad716882
commit 2f25f0dc0f
3 changed files with 22 additions and 8 deletions

View File

@ -160,6 +160,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void ControlCore::_setupDispatcherAndCallbacks()
{
///* TODO(DH) */ return;
// Get our dispatcher. If we're hosted in-proc with XAML, this will get
// us the same dispatcher as TermControl::Dispatcher(). If we're out of
// proc, this'll return null. We'll need to instead make a new
@ -408,12 +409,15 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_terminal->Create(viewportSize, Utils::ClampToShortMax(_settings.HistorySize(), 0), *_renderer);
_terminal->UpdateSettings(_settings);
// Tell the render engine to notify us when the swap chain changes.
// We do this after we initially set the swapchain so as to avoid
// unnecessary callbacks (and locking problems)
_renderEngine->SetCallback([this](HANDLE handle) {
_renderEngineSwapChainChanged(handle);
});
if (_hookup == HookupMode::ForComposition)
{
// Tell the render engine to notify us when the swap chain changes.
// We do this after we initially set the swapchain so as to avoid
// unnecessary callbacks (and locking problems)
_renderEngine->SetCallback([this](HANDLE handle) {
_renderEngineSwapChainChanged(handle);
});
}
_renderEngine->SetRetroTerminalEffect(_settings.RetroTerminalEffect());
_renderEngine->SetPixelShaderPath(_settings.PixelShaderPath());
@ -439,6 +443,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
const float compositionScale,
const uint64_t hwnd)
{
_owningHwnd = hwnd;
_hookup = HookupMode::ForHwnd;
auto i = Initialize(actualWidth, actualHeight, compositionScale);
if (i)
{

View File

@ -78,6 +78,12 @@ namespace winrt::Microsoft::Terminal::Control::implementation
struct ControlCore : ControlCoreT<ControlCore>
{
private:
enum class HookupMode
{
ForHwnd = 0x0,
ForComposition = 0x1,
};
public:
ControlCore(Control::IControlSettings settings,
Control::IControlAppearance unfocusedAppearance,
@ -382,7 +388,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
//
// Though, the unit tests don't actually run in TAEF's main
// thread, so we don't care when we're running in tests.
assert(_inUnitTests || _dispatcher.HasThreadAccess());
assert(_hookup == HookupMode::ForHwnd || _inUnitTests || _dispatcher.HasThreadAccess());
}
#endif
return _closing;
@ -427,6 +433,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
std::atomic<bool> _initializedTerminal{ false };
bool _isReadOnly{ false };
bool _closing{ false };
HookupMode _hookup{ HookupMode::ForComposition };
struct StashedColorScheme
{

View File

@ -137,7 +137,7 @@
This diagnostic is broken in VS 17.7 which our CI currently uses. It's fixed in 17.8.
-->
<DisableSpecificWarnings>4201;4312;4467;5105;26434;26445;26456;26478;26494;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<PreprocessorDefinitions>_WINDOWS;EXTERNAL_BUILD;_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING;_WINDOWS;EXTERNAL_BUILD;_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<PrecompiledHeaderFile>precomp.h</PrecompiledHeaderFile>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>