Skip to content

Crash when Label text is null #3861

@EricEzaM

Description

@EricEzaM

Issue:
I accidentally set text to null, got a crash due to exception.
Other places in Label do checks for NullOrEmpty, but it is missing here in Render, causing a null ref exception on Text.Contains

System.NullReferenceException: Object reference not set to an instance of an object.
   at ScottPlot.Label.DrawText(SKCanvas canvas, MeasuredText measured, SKPaint paint, PixelRect textRect, Boolean bottom)
   at ScottPlot.Label.Render(SKCanvas canvas, Pixel px, SKPaint paint, Boolean bottom)

ScottPlot Version: (What NuGet package are you using?)
5.0.34

Code Sample:

formsPlot1.Plot.Add.Text(null, 0, 0);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good First IssueThis issue has limited complexity and may be a good start for new contributorsHelp WantedScott won't do this soon, but PRs from the community are welcome!⚠️ HIGH PRIORITY

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions