-
Notifications
You must be signed in to change notification settings - Fork 996
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
An exception pops up when pressing the space key on the checkbox cell #12752
Comments
@Zheng-Li01 - thank you for creating a scratch project repro! |
This issue is similar to issue #12692. Before calling NotifyMSAAClient, the DataGridView should be checked to see if it is not null. |
@LeafShi1 - thank you! Please prepare the fix and search the source code for similar cases. |
I proceeded to test WinForms's repo main branch latest commit (10.0.100-alpha.1.25064.3) and the issue doesn't reproduce. I believe this was fixed by #12701, because removing the null check introduced in that PR would cause the issue to happen again. |
@ricardobossan Could please try using the space keyboard on the checkbox cell to reproduce this issue. |
Thank you for pointing that out, @Zheng-Li01 . I missed the detail about reproducing the issue by pressing the space key. I retested following the issue description more carefully, and I can confirm the issue does reproduce as described. |
… `NotifyMSAAClient` method. Fixes dotnet#12752 ## Root Cause - The issue occurs because the `NotifyMSAAClient` method is called without checking if the `DataGridView` instance is `null`. This leads to a potential `NullReferenceException`. ## Proposed changes - Add a `null` check for the `DataGridView` instance before calling the `NotifyMSAAClient` method. ## Customer Impact - Prevents runtime crashes when the `DataGridView` is `null`. ## Regression? - No ## Risk - Minimal ## Screenshots ### Before ### After ## Test methodology - Manual testing ## Test environment(s) - `10.0.100-alpha.1.25064.3`
If the following code is executed in
Therefore, before executing PaintGrid, we need to check whether CurrentCell is null. It is difficult to find other similar cases just by looking at the code, so I dragged a DataGridView control and added some events to it, and added the above code to the events, so that the problem will be exposed when the corresponding events are executed. |
@LeafShi1 @ricardobossan - I would add a null-check before on in PaintGrid. Performance cost is low, and someone might clear the cells in the paint method. |
… null. Fixes dotnet#12752 ## Root Cause - The issue occurs because the `NotifyMSAAClient` method is called without checking if the `DataGridView` instance is `null`. This leads to a potential `NullReferenceException`. ## Proposed changes - Add a `null` check for the `DataGridView` instance before calling the `NotifyMSAAClient` method. - Adds another `null` check for the `CurrentCell` property before calling the `PaintGrid` method. ## Customer Impact - Prevents runtime crashes when the `DataGridView` or `CurrentCell` are null. ## Regression? - No ## Risk - Minimal ## Screenshots ### Before ### After ## Test methodology - Manual testing ## Test environment(s) - `10.0.100-alpha.1.25064.3`
I have updated the PR to reflect this suggestion. |
… null. Fixes dotnet#12752 ## Root Cause - The issue occurs because the `NotifyMSAAClient` method is called without checking if the `DataGridView` instance is `null`. This leads to a potential `NullReferenceException`. ## Proposed changes - Add a `null` check for the `DataGridView` instance before calling the `NotifyMSAAClient` method. - Adds another `null` check for the `CurrentCell` property before calling the `PaintGrid` method. ## Customer Impact - Prevents runtime crashes when the `DataGridView` or `CurrentCell` are null. ## Regression? - No ## Risk - Minimal ## Screenshots ### Before ### After ## Test methodology - Manual testing ## Test environment(s) - `10.0.100-alpha.1.25064.3`
.NET version
.NET SDK 10.0.100-alpha.1.25058.38
Did it work in .NET Framework?
No
Did it work in any of the earlier releases of .NET Core or .NET 5+?
This is not a regression issue, can reproduce all earlier releases of .NET versions (.NET 6.0/7.0/8.0/9.0) & .NET Framework
Issue description
An exception pops up when pressing the space keyboard on the checkbox cell
Steps to reproduce
Debug info:
Call Stack:
The text was updated successfully, but these errors were encountered: