Skip to content

Conversation

@JeremyKuhne
Copy link
Member

@JeremyKuhne JeremyKuhne commented Oct 21, 2025

Disposing in InvalidateLayout would break in some workflows when accessing the Links VisualRegion as it is shared. This got mistakenly moved in #10448.

Fixes #13973

Microsoft Reviewers: Open in CodeFlow

Disposing in InvalidateLayout would break when accessing the links VisualRegion as it is shared.

Fixes dotnet#13973
@JeremyKuhne JeremyKuhne requested a review from a team as a code owner October 21, 2025 20:35
@JeremyKuhne JeremyKuhne added this to the .NET 10.0 milestone Oct 21, 2025
@github-actions github-actions bot added the area-DarkMode Issues relating to Dark Mode feature label Oct 21, 2025
@JeremyKuhne JeremyKuhne added servicing-consider .NET Shiproom label indicating a PR seeks to enter into a branch under Tell-Mode criteria and removed area-DarkMode Issues relating to Dark Mode feature labels Oct 21, 2025
@JeremyKuhne
Copy link
Member Author

Writing a regression test for this isn't simple as it requires a specific sequence of Windows messages to get in the offending state. I added an assert to the Control code that was attempting to use the disposed region to hopefully flag this sort of thing earlier.

@codecov
Copy link

codecov bot commented Oct 21, 2025

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.14570%. Comparing base (4edb501) to head (81fcf82).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #13978         +/-   ##
===================================================
- Coverage   77.15202%   77.14570%   -0.00632%     
===================================================
  Files           3276        3276                 
  Lines         645116      645117          +1     
  Branches       47705       47705                 
===================================================
- Hits          497720      497680         -40     
- Misses        143708      143750         +42     
+ Partials        3688        3687          -1     
Flag Coverage Δ
Debug 77.14570% <33.33333%> (-0.00632%) ⬇️
integration 18.98098% <33.33333%> (-0.01399%) ⬇️
production 52.00196% <33.33333%> (-0.01408%) ⬇️
test 97.40947% <ø> (ø)
unit 49.45379% <33.33333%> (-0.00781%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@Shyam-Gupta Shyam-Gupta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@JeremyKuhne JeremyKuhne merged commit 1b9ba2a into dotnet:main Oct 21, 2025
9 checks passed
@JeremyKuhne JeremyKuhne deleted the fixlinklabel branch October 21, 2025 22:04
@JeremyKuhne
Copy link
Member Author

/backport to release/10.0

@github-actions
Copy link
Contributor

Started backporting to release/10.0: https://github.com/dotnet/winforms/actions/runs/18699261623

JeremyKuhne added a commit that referenced this pull request Oct 22, 2025
…13979)

Backport of #13978 to release/10.0

/cc @JeremyKuhne

## Customer Impact

Changing `LinkLabel` state during events can cause the app to crash as
we'll try to give GDI+ a null pointer. There is no known workaround to
this as internal state can't be changed as events are being processed.

A System.Drawing `Region` disposal was moved to a location that would
let it get used after disposal by another holder of the Region. The fix
is to move the disposal back to its original location.

## Testing

Manual testing of the end users' repro. Existing automated coverage.

This is not plausible to unit test as it requires a long sequence of
messages to reproduce. (MouseEnter, MouseHover, MouseUp, and more.)

## Risk

Low. Moving the disposal back to where it was originally, which is
before the new `Region` is created and applied.

###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/winforms/pull/13979)
@github-actions github-actions bot locked and limited conversation to collaborators Nov 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

servicing-consider .NET Shiproom label indicating a PR seeks to enter into a branch under Tell-Mode criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LinkLabel System.ArgumentException and application crash

2 participants