fix: ContextMenuStrip leads to crash on W10 1607 (#3279)

This commit is contained in:
Igor Velikorossov 2020-06-24 13:53:59 +10:00 коммит произвёл GitHub
Родитель e2ccd96a21
Коммит fe51dd5bcf
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 5 добавлений и 1 удалений

Просмотреть файл

@ -62,7 +62,11 @@ namespace System.Windows.Forms
!AreDpiAwarenessContextsEqual(originalAwareness, DPI_AWARENESS_CONTEXT.UNAWARE))
{
originalAwareness = SetThreadDpiAwarenessContext(awareness);
dpiAwarenessScopeIsSet = true;
// As reported in https://github.com/dotnet/winforms/issues/2969
// under unknown conditions originalAwareness may remain 0 (which means the call failed)
// causing us to set dpiAwarenessScopeIsSet=true, which would lead to a crash when we attempt to dispose the scope.
dpiAwarenessScopeIsSet = originalAwareness != IntPtr.Zero;
}
}
}