Fix a bug where Terminal may crash or hang at shutdown (#1651)
* Fix a bug where Terminal may crash at shutdown
This commit is contained in:
parent
5dd1f8d38a
commit
45ad2d71bf
|
@ -46,10 +46,8 @@ namespace winrt::TerminalApp::implementation
|
|||
// cause you to chase down the rabbit hole of "why is App not
|
||||
// registered?" when it definitely is.
|
||||
|
||||
// See GH#1339. This is a workaround for MSFT:22116519
|
||||
// We need this to prevent an occasional crash on teardown
|
||||
AddRef();
|
||||
m_inner.as<::IUnknown>()->Release();
|
||||
// Initialize will become protected or be deleted when GH#1339 (workaround for MSFT:22116519) are fixed.
|
||||
Initialize();
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
|
|
@ -9,6 +9,8 @@ namespace TerminalApp
|
|||
{
|
||||
App();
|
||||
|
||||
void Initialize();
|
||||
|
||||
// For your own sanity, it's better to do setup outside the ctor.
|
||||
// If you do any setup in the ctor that ends up throwing an exception,
|
||||
// then it might look like TermApp just failed to activate, which will
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <winrt/Windows.ui.xaml.media.h>
|
||||
#include <winrt/Windows.ui.xaml.input.h>
|
||||
#include <winrt/Windows.UI.Xaml.Hosting.h>
|
||||
#include <winrt/Microsoft.Toolkit.Win32.UI.XamlHost.h>
|
||||
|
||||
#include <windows.ui.xaml.media.dxinterop.h>
|
||||
|
||||
|
|
|
@ -41,7 +41,10 @@ AppHost::AppHost() noexcept :
|
|||
|
||||
AppHost::~AppHost()
|
||||
{
|
||||
// destruction order is important for proper teardown here
|
||||
_window = nullptr;
|
||||
_app.Close();
|
||||
_app = nullptr;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
@ -57,7 +60,6 @@ AppHost::~AppHost()
|
|||
// - <none>
|
||||
void AppHost::Initialize()
|
||||
{
|
||||
_app.Initialize();
|
||||
_window->Initialize();
|
||||
const auto handle = _window->GetHandle();
|
||||
_app.Create(reinterpret_cast<uint64_t>(handle));
|
||||
|
|
|
@ -90,6 +90,16 @@
|
|||
<DeploymentContent>true</DeploymentContent>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</NativeReferenceFile>
|
||||
|
||||
<!--
|
||||
The reason why this is needed for ARM64 is unknown,
|
||||
If not added, the centenial package will fail to include the XamlHost dll.
|
||||
-->
|
||||
<NativeReferenceFile Include="$(OpenConsoleDir)$(Platform)\$(Configuration)\TerminalApp\Microsoft.Toolkit.Win32.UI.XamlHost.dll" Condition="'$(Platform)'=='ARM64'">
|
||||
<DeploymentContent>true</DeploymentContent>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</NativeReferenceFile>
|
||||
|
||||
<!--
|
||||
the packaging project wont recurse through our dependencies, you have to
|
||||
make sure that if you add a cppwinrt dependency to any of these projects,
|
||||
|
|
|
@ -41,7 +41,6 @@ Abstract:
|
|||
#include <winrt/Windows.system.h>
|
||||
#include <winrt/Windows.Foundation.Collections.h>
|
||||
#include <winrt/Windows.UI.Xaml.Hosting.h>
|
||||
#include <winrt/Microsoft.Toolkit.Win32.UI.XamlHost.h>
|
||||
#include <windows.ui.xaml.hosting.desktopwindowxamlsource.h>
|
||||
|
||||
// Additional headers for various xaml features. We need:
|
||||
|
|
Loading…
Reference in a new issue