Skip to content

Conversation

lindexi
Copy link
Member

@lindexi lindexi commented Sep 12, 2025

Fixes #11103

Main PR

Description

See #11103

The stylusDevice.CriticalActiveSource may be null. And the stylusDevice.CriticalActiveSource will update from inputReport.InputSource. So that we directly use inputReport.InputSource will be safe and reasonable.

This PR can not 100% fix the #11103 , but this PR can alleviate the problem.

Customer Impact

Fix the out of roder issues.

Regression

None.

Testing

Test pass in my touch device.

And I build and publish my version to NuGet: https://www.nuget.org/packages/dotnetCampus.WPF.Resource/6.0.4-alpha07-test10

Risk

Normal. As description says, the stylusDevice.CriticalActiveSource will update from inputReport.InputSource in UI thread. We can directly use inputReport.InputSource in Stylus Input thread safely.

Microsoft Reviewers: Open in CodeFlow

@lindexi lindexi requested a review from a team as a code owner September 12, 2025 01:59
@Copilot Copilot AI review requested due to automatic review settings September 12, 2025 01:59
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where StylusPlugIn methods (OnStylusDown/Move/Up) were being called out of order due to potential null reference issues with stylusDevice.CriticalActiveSource. The fix ensures thread safety by using inputReport.InputSource as the primary source, falling back to stylusDevice.CriticalActiveSource only when needed.

  • Replace direct usage of stylusDevice.CriticalActiveSource with null-coalescing pattern using inputReport.InputSource

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

StylusPlugIn OnStylusDown/Move/Up invoked on UI thread and called out of order
1 participant