InkCanvas.DynamicRenderer set different custom DynamicRenderer multiple times, throw an exception
See original GitHub issueDescription
When using the touch screen, errors will occur, but not when using the mouse
On the touch screen, the two buttons switch and click multiple times to set a custom Dynamic Renderer for InkCanvas.DynamicRenderer. The crash always occurs after DrawPen OnRemoved
Button(DrawPen)、Button(DrawArrow)
`var dr = name switch
{
“GeneralPen” => new DrawPen(this),
“ArrowPen” => new DrawArrow(this),
_ => new DrawPen(this),
};
DynamicRenderer = dr; `
If set different custom DynamicRenderer multiple times, throw an exception
App_DispatcherUnhandledException--Object reference not set to an instance of an object. at System.Windows.Input.StylusPlugIns.DynamicRenderer.TransitionComplete(StrokeInfo si) at System.Windows.Input.StylusPlugIns.DynamicRenderer.<>c__DisplayClass19_0.<NotifyAppOfDRThreadRenderComplete>b__0(Object unused) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
Reproduction Steps
Ditto description
Expected behavior
No exception will be thrown
Actual behavior
Throw thread exception
Regression?
No response
Known Workarounds
No response
Impact
No response
Configuration
.NET Core Version: .NET 7.0.103 SDK Windows version: Version 22H2 (OS Build 19045.2546)
Other information
No response
Issue Analytics
- State:
- Created 7 months ago
- Comments:7 (5 by maintainers)
Top GitHub Comments
Please provide a repro project having the issue.
@lindexi Thank you for your help. I updated the Demo and annotated some code that may prevent exceptions. These codes are valid, but not 100%. Now we should be able to simply reproduce the exception. Just press the Pen Button several times, switch another button, and repeat it several times
感謝林德熙大神