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

View File

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