Update wil. Fixes GDI handle leak (#6229)

## Summary of the Pull Request
When resizing the window title, a GDI object would be leaked. This has to do with our island message handler using `wil` to track these objects and `wil` having a bug.

## References
microsoft/wil#100

## PR Checklist
* [x] Closes #5949 
* [x] I work here.
* [x] Tested manually
* [x] Doc not required.
* [x] Am core contributor.

## Validation Steps Performed
* [x] Added the GDI Objects column to Task Manager, set the Terminal to use the `titleWidth` size tabs, then changed the title a bunch with PowerShell. Confirmed repro before (increasing GDI count). Confirmed it's gone after (no change to object count).
This commit is contained in:
Michael Niksa 2020-06-01 15:29:05 -07:00 committed by GitHub
parent 8987486e85
commit 48b3262eaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 14 additions and 4 deletions

View file

@ -1 +1 @@
Subproject commit e8c599bca6c56c44b6730ad93f6abbc9ecd60fc1
Subproject commit 3c00e7f1d8cf9930bbb8e5be3ef0df65c84e8928

View file

@ -321,7 +321,7 @@ COORD CharRow::GetStorageKey(const size_t column) const noexcept
// - Updates the pointer to the parent row (which might change if we shuffle the rows around)
// Arguments:
// - pParent - Pointer to the parent row
void CharRow::UpdateParent(ROW* const pParent) noexcept
void CharRow::UpdateParent(ROW* const pParent)
{
_pParent = FAIL_FAST_IF_NULL(pParent);
}

View file

@ -88,7 +88,7 @@ public:
const UnicodeStorage& GetUnicodeStorage() const noexcept;
COORD GetStorageKey(const size_t column) const noexcept;
void UpdateParent(ROW* const pParent) noexcept;
void UpdateParent(ROW* const pParent);
friend CharRowCellReference;
friend constexpr bool operator==(const CharRow& a, const CharRow& b) noexcept;

View file

@ -29,6 +29,7 @@ LRESULT CALLBACK HwndTerminal::HwndTerminalWndProc(
UINT uMsg,
WPARAM wParam,
LPARAM lParam) noexcept
try
{
#pragma warning(suppress : 26490) // Win32 APIs can only store void*, have to use reinterpret_cast
HwndTerminal* terminal = reinterpret_cast<HwndTerminal*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
@ -84,6 +85,7 @@ LRESULT CALLBACK HwndTerminal::HwndTerminalWndProc(
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
CATCH_LOG()
static bool RegisterTermClass(HINSTANCE hInstance) noexcept
{
@ -686,6 +688,7 @@ void __stdcall TerminalKillFocus(void* terminal)
// - rows - Rows of text data to copy
// - fAlsoCopyFormatting - true if the color and formatting should also be copied, false otherwise
HRESULT HwndTerminal::_CopyTextToSystemClipboard(const TextBuffer::TextAndColor& rows, bool const fAlsoCopyFormatting)
try
{
std::wstring finalString;
@ -714,7 +717,7 @@ HRESULT HwndTerminal::_CopyTextToSystemClipboard(const TextBuffer::TextAndColor&
RETURN_LAST_ERROR_IF(!OpenClipboard(_hwnd.get()));
{ // Clipboard Scope
auto clipboardCloser = wil::scope_exit([]() noexcept {
auto clipboardCloser = wil::scope_exit([]() {
LOG_LAST_ERROR_IF(!CloseClipboard());
});
@ -742,6 +745,7 @@ HRESULT HwndTerminal::_CopyTextToSystemClipboard(const TextBuffer::TextAndColor&
return S_OK;
}
CATCH_RETURN()
// Routine Description:
// - Copies the given string onto the global system clipboard in the specified format

View file

@ -294,6 +294,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
// Method Description:
// - called when the client application (not necessarily its pty) exits for any reason
void ConptyConnection::_ClientTerminated() noexcept
try
{
if (_isStateAtOrBeyond(ConnectionState::Closing))
{
@ -321,6 +322,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
_piClient.reset();
}
CATCH_LOG()
void ConptyConnection::WriteInput(hstring const& data)
{
@ -349,6 +351,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
}
void ConptyConnection::Close() noexcept
try
{
if (_transitionToState(ConnectionState::Closing))
{
@ -378,6 +381,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
_transitionToState(ConnectionState::Closed);
}
}
CATCH_LOG()
DWORD ConptyConnection::_OutputThread()
{

View file

@ -2236,6 +2236,7 @@ void DxEngine::SetAntialiasingMode(const D2D1_TEXT_ANTIALIAS_MODE antialiasingMo
// Return Value:
// - <none>
void DxEngine::SetDefaultTextBackgroundOpacity(const float opacity) noexcept
try
{
_defaultTextBackgroundOpacity = opacity;
@ -2244,3 +2245,4 @@ void DxEngine::SetDefaultTextBackgroundOpacity(const float opacity) noexcept
// We don't terribly care if this fails.
LOG_IF_FAILED(InvalidateAll());
}
CATCH_LOG()