dotnet / dotnet/winforms

Don't force creation of `Handle` in `OnHandleCreated`

Open
#2,235 3 comments 0 reactions 0 assignees View on GitHub
:beetle: bug help wanted waiting-on-team
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
1d 13m
Merged PRs (30d)
85

Description

See https://github.com/dotnet/winforms/pull/2141

The base class `Control.OnHandleCreated` checks for `IsHandleCreated` and does nothing if the handle isn't created.

In other sub-classes, we do not check `if (IsHandleCreated)` before accessing `this.Handle` which forces creation. This leads to strange recursive behaviour as `OnHandleCreated` is called again.

My opinion is that we should fix this oversight in base classes to ensure that they don't create the `Handle` in `OnHandleCreated` if a `Handle` doesn't exist

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.