the final_release thing Dustin was talking about. I think I still need to synchronously close the connection though

This commit is contained in:
Mike Griese
2022-07-15 11:11:31 -05:00
parent e9375d67f1
commit 83649075a7
5 changed files with 47 additions and 1 deletions

View File

@@ -4,6 +4,7 @@
#include "pch.h"
#include "ContentProcess.h"
#include "ContentProcess.g.cpp"
#include "ControlCore.h"
namespace winrt::Microsoft::Terminal::Control::implementation
{
@@ -30,6 +31,39 @@ namespace winrt::Microsoft::Terminal::Control::implementation
#pragma warning(disable : 4722)
ContentProcess::~ContentProcess()
{
// if (_interactivity)
// {
// if (_interactivity.Core())
// {
// // IMPORTANT!
// //
// // We're responsible for closing the conntection now. If we
// // don't do this, the OpenConsole will leak.
// _interactivity.Core().Close();
// }
// }
// // DANGER - We're straight up going to EXIT THE ENTIRE PROCESS when we
// // get destructed. This eliminates the need to do any sort of
// // ref-counting weirdness. This entire process exists to host one
// // singular ContentProcess instance. When we're destructed, it's because
// // every other window process was done with us. We can die now, knowing
// // that our job is complete.
// std::exit(0);
}
#pragma warning(pop)
winrt::fire_and_forget ContentProcess::final_release(std::unique_ptr<ContentProcess> ptr) noexcept
{
winrt::com_ptr<ControlCore> coreImpl;
coreImpl.copy_from(winrt::get_self<ControlCore>(ptr->_interactivity.Core()));
if (coreImpl)
{
co_await wil::resume_foreground(coreImpl->Dispatcher(), winrt::Windows::System::DispatcherQueuePriority::Normal);
coreImpl->Close();
}
// DANGER - We're straight up going to EXIT THE ENTIRE PROCESS when we
// get destructed. This eliminates the need to do any sort of
// ref-counting weirdness. This entire process exists to host one
@@ -39,7 +73,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation
std::exit(0);
}
#pragma warning(pop)
Control::ControlInteractivity ContentProcess::GetInteractivity()
{

View File

@@ -12,6 +12,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
{
ContentProcess(winrt::guid g);
~ContentProcess();
static winrt::fire_and_forget final_release(std::unique_ptr<ContentProcess> ptr) noexcept;
bool Initialize(Control::IControlSettings settings,
Control::IControlAppearance unfocusedAppearance,

View File

@@ -218,6 +218,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
UpdateSettings(settings, unfocusedAppearance);
}
winrt::Windows::System::DispatcherQueue ControlCore::Dispatcher()
{
return _dispatcher;
}
ControlCore::~ControlCore()
{
Close();

View File

@@ -193,6 +193,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
uint64_t OwningHwnd();
void OwningHwnd(uint64_t owner);
winrt::Windows::System::DispatcherQueue Dispatcher();
RUNTIME_SETTING(double, Opacity, _settings->Opacity());
RUNTIME_SETTING(bool, UseAcrylic, _settings->UseAcrylic());

View File

@@ -2043,6 +2043,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// Disconnect the TSF input control so it doesn't receive EditContext events.
TSFInputControl().Close();
_autoScrollTimer.Stop();
// THIS IS IMPORTANT!
//
// If we're out of proc, the control can be closed, but we DON'T
// want that to close our content. We'll want the content proc's
// teardown to be responsible for closing the core.
if (!_contentIsOutOfProc())
{
_core.Close();