-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Dobule clicking on a ToolStripButton to open a dialog causes stack overflow #12847
Comments
WinFormsApp4.zip |
ToolStripBUtton seem to be interpreting the double click as 2 separate clicks, this is why this does not repro for other controls. When processing the second click, Common Dialog assumes that winProc had been cleaned up, which is not the case, and proceeds with hooking up the second win proc and we end up calling the 2 winprocs one from the other. winforms/src/System.Windows.Forms/src/System/Windows/Forms/Dialogs/CommonDialogs/CommonDialog.cs Line 207 in 311ea4c
|
To repro, add this code to the scratch project
|
This exposes 2 issues, I would fix both - toolstripbutton double click is interpreted as 2 single clicks. Probably this is a regression from the NETFX, need to verify. And we proceed with winproc hook up even though the previous one had not been unhooked properly. Might as well exit. I would keep the Assert to signal that this is unexpected. |
.NET version
.NET 9.0
Also reproduced on .Net Framework 3.0, 3.5, 4.6, 4.7.x, 4.8.x, and .NET 5.0, 6.0, 8.0.
Did it work in .NET Framework?
Yes
Did it work in any of the earlier releases of .NET Core or .NET 5+?
Can reproduce on .NET 5.0, 6.0, 8.0 and 9.0.
Unsure on .NET Core 3.x.
Issue description
If a
Click
event ofToolStripButton
callsOpenFileDialog.ShowDialog(IWin32Window)
and the parameterowner
is the current form (this
), double click on the button will causeSystem.StackOverflowException
. It seems that some codes insideSystem.Windows.Form
is called recursively.The same method for
SaveFileDialog
andFolderBrowserDialog
also have the same issue, butFontDialog
andColorDialog
do work correctly.Steps to reproduce
ToolStrip
control and anOpenFileDialog
contol.ToolStripButton
on theToolStrip
control and add aClick
event to the button.Click
event simply write:System.StackOverflowException
exception will be thrown. Note, single click works fine.Result:
Stack overflow with this repeating frame -
System.Private.Windows.Core.dll!Windows.Win32.PInvokeCore.CallWindowProc<Windows.Win32.Foundation.HWND> Line 11 C#
System.Windows.Forms.dll!System.Windows.Forms.CommonDialog.OwnerWndProc Line 145 C#
System.Windows.Forms.dll!System.Windows.Forms.CommonDialog.OwnerWndProcInternal Line 117 C#
[Native to Managed Transition]
user32.dll!UserCallWinProcCheckWow Line 289 C++
[Inline Frame] user32.dll!CallWindowProcAorW Line 2891 C++
user32.dll!CallWindowProcW Line 2914 C++
The text was updated successfully, but these errors were encountered: