Prevent ImageList allocation disposing PropertyGrid

Resolves #3485
This commit is contained in:
Igor Velikorossov 2020-07-02 11:06:22 +10:00
Родитель ef0f6dbf38
Коммит eaf15b7402
1 изменённых файлов: 3 добавлений и 2 удалений

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

@ -1018,9 +1018,10 @@ namespace System.Windows.Forms
get
{
Image image = (Image)Properties.GetObject(s_imageProperty);
if (image == null && (Owner != null) && (Owner.ImageList != null) && ImageIndexer.ActualIndex >= 0)
if (image == null && Owner?.ImageList != null && ImageIndexer.ActualIndex >= 0)
{
if (ImageIndexer.ActualIndex < Owner.ImageList.Images.Count)
bool disposing = _state[s_stateDisposing];
if (!disposing && ImageIndexer.ActualIndex < Owner.ImageList.Images.Count)
{
// CACHE (by design). If we fetched out of the image list every time it would dramatically hit perf.
image = Owner.ImageList.Images[ImageIndexer.ActualIndex];