You know, there's 0% chance that this is the right pattern for this, but it _works_
This commit is contained in:
parent
d84a31801a
commit
88d974280d
|
@ -21,6 +21,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
return true;
|
||||
}
|
||||
|
||||
ContentProcess::~ContentProcess()
|
||||
{
|
||||
_DestructedHandlers();
|
||||
}
|
||||
|
||||
Control::ControlInteractivity ContentProcess::GetInteractivity()
|
||||
{
|
||||
return _interactivity;
|
||||
|
|
|
@ -12,12 +12,15 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
|
||||
{
|
||||
ContentProcess();
|
||||
~ContentProcess();
|
||||
bool Initialize(Control::IControlSettings settings,
|
||||
TerminalConnection::ConnectionInformation connectionInfo);
|
||||
Control::ControlInteractivity GetInteractivity();
|
||||
|
||||
uint64_t RequestSwapChainHandle(const uint64_t pid);
|
||||
|
||||
WINRT_CALLBACK(Destructed, Control::DestructedArgs);
|
||||
|
||||
private:
|
||||
Control::ControlInteractivity _interactivity{ nullptr };
|
||||
};
|
||||
|
|
|
@ -5,6 +5,8 @@ import "ControlInteractivity.idl";
|
|||
|
||||
namespace Microsoft.Terminal.Control
|
||||
{
|
||||
delegate void DestructedArgs();
|
||||
|
||||
runtimeclass ContentProcess {
|
||||
|
||||
ContentProcess();
|
||||
|
@ -15,5 +17,7 @@ namespace Microsoft.Terminal.Control
|
|||
ControlInteractivity GetInteractivity();
|
||||
|
||||
UInt64 RequestSwapChainHandle(UInt64 pid);
|
||||
|
||||
event DestructedArgs Destructed;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -247,17 +247,17 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
inline bool _IsClosing() const noexcept
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
// TODO! This may not be strictly true if the core is running out of
|
||||
// proc with XAML. I keep hitting this assertion every time it
|
||||
// exits, so we might need a better solution.
|
||||
if (_dispatcher)
|
||||
{
|
||||
// _closing isn't atomic and may only be accessed from the main thread.
|
||||
//
|
||||
// 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());
|
||||
}
|
||||
// // TODO! This may not be strictly true if the core is running out of
|
||||
// // proc with XAML. I keep hitting this assertion every time it
|
||||
// // exits, so we might need a better solution.
|
||||
// if (_dispatcher)
|
||||
// {
|
||||
// // _closing isn't atomic and may only be accessed from the main thread.
|
||||
// //
|
||||
// // 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());
|
||||
// }
|
||||
#endif
|
||||
return _closing;
|
||||
}
|
||||
|
|
|
@ -143,6 +143,11 @@ struct HostClassFactory : implements<HostClassFactory, IClassFactory>
|
|||
if (!g_weak)
|
||||
{
|
||||
winrt::Microsoft::Terminal::Control::ContentProcess strong{}; // = winrt::make<winrt::Microsoft::Terminal::Control::ContentProcess>();
|
||||
strong.Destructed([]() {
|
||||
std::unique_lock<std::mutex> lk(m);
|
||||
dtored = true;
|
||||
cv.notify_one();
|
||||
});
|
||||
winrt::weak_ref<winrt::Microsoft::Terminal::Control::ContentProcess> weak{ strong };
|
||||
g_weak = weak;
|
||||
return strong.as(iid, result);
|
||||
|
|
Loading…
Reference in a new issue