Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure tooltip window handle is being destroyed when parent window/control is destroyed #2094

Open
wants to merge 5 commits into
base: unity-main
Choose a base branch
from

Conversation

zorana-curkovic
Copy link

@zorana-curkovic zorana-curkovic commented Dec 4, 2024

Inside Systems.Windows.Forms various dialogs and views use and create Tooltip window. The tooltip window is special in a way that is never added to the controls of the window which created the tooltip resulting in never being destroyed with the main window. After the tooltip window is used and domain reload happens, focusing on a newly created main window can result in a crash as the tooltip's registered class object no longer exists in memory.

This PR adds two things:

  1. provides a way to set parent/owner for the tooltip window so it can be added to the controls of its owner to be destroyed when its owner is
  2. Make sure that classes using the tooltip don't create it in their constructor as that is too early for registering with controls

The fix is applied to the following classes instantiating the tooltip:

  • datagridview
  • internalwindowmanager
  • filedialog
  • tabcontrol
  • statusbar
  • listview
  • toolstriptextbox
  • toolstrip
  • toolbar
  • treeview

Fix is not applied to the following classes instantiating tooltip as there is no obvious or guaranteed owner:

  • helpprovider

  • errorprovider

  • Should this pull request have release notes?

    • Yes
    • No
  • Do these changes need to be back ported?

    • Yes
    • No
  • Do these changes need to be upstreamed to mono/mono or dotnet/runtime repositories?

    • Yes
    • No

Reviewers: please consider these questions as well! ❤️

An important note on these changes is that this PR will influence Unity's mono and may be submitted to the upstream. However, the user reporting this crash is using a third-party plugin (just System.Windows.Forms dll) generated from an unknown version of mono (similar to the case UUM-13189 ) which makes it more involved to get this fix over to them than just fixing it in Unity's stream.

Release notes

Fixed UUM-79065 @zorana.curkovic
Mono: Prevent the crash on domain reload when Windows Form is using a tooltip window.

6000.0
2022.3

@unity-cla-assistant
Copy link
Collaborator

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@UnityAlex
Copy link
Collaborator

I see that you've indicated that these changes need to be upstreamed. Have you opened a PR for dotnet/runtime?

@zorana-curkovic
Copy link
Author

I see that you've indicated that these changes need to be upstreamed. Have you opened a PR for dotnet/runtime?

I haven't. I would like to get an opinion from you guys. I'm not sure what kind of changes you usually submit to mono/mono.
My line of thoughts was - I would like this to be reviewed by someone who wrote or maintains this code, but that is all. My understanding is that if I do this it should just go to mono/mono, not dotnet/runtime. Is that right as well?

@joncham
Copy link
Member

joncham commented Dec 10, 2024

I see that you've indicated that these changes need to be upstreamed. Have you opened a PR for dotnet/runtime?

I haven't. I would like to get an opinion from you guys. I'm not sure what kind of changes you usually submit to mono/mono. My line of thoughts was - I would like this to be reviewed by someone who wrote or maintains this code, but that is all. My understanding is that if I do this it should just go to mono/mono, not dotnet/runtime. Is that right as well?

It is unlikely that anyone is maintaining or any original authors would review the Mono Windows Forms source at this point.

@UnityAlex
Copy link
Collaborator

I was more curious if you had noticed if the dotnet/runtime repository also had the same issue. They are actively taking changes and would be interested in this kind of fix. The changes look fine to me as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants