Blazor-Diagrams / Blazor.Diagrams

A fully customizable and extensible all-purpose diagrams library for Blazor
https://blazor-diagrams.zhaytam.com
MIT License
917 stars 176 forks source link

NullReferenceException when removing DrawNewLinkBehavior #420

Open GeertvanHorrik opened 4 months ago

GeertvanHorrik commented 4 months ago

I was getting NullReferenceExceptions when updating to the new 3.x version. After some debugging, I noticed the ignoring of potentially nullable value:

https://github.com/Blazor-Diagrams/Blazor.Diagrams/blob/develop/src/Blazor.Diagrams/Components/LinkWidget.razor#L18

Since the behavior can be removed, the null check should still exist?

For now I disabled this call on new diagrams:

diagram.UnregisterBehavior<DragNewLinkBehavior>();
vbalestone commented 2 months ago

I had the same exception by removing DrawNewLinkBehavior and registering a derived class from it. I solved the issue by changing the GetBehavior function to check if has a derived class if the asked is not found.