Skip to content

Rendering: changing the plottable list mid-render will cause an exception #3753

@ZSYMAX

Description

@ZSYMAX

Issue: (It will cause collection has changed exception on Rendering)

ScottPlot Version: (5.0.31)

foreach (IPlottable plottable in rp.Plot.PlottableList)
{
if (!plottable.IsVisible)
continue;
plottable.Axes.DataRect = rp.DataRect;
rp.CanvasState.Save();
if (plottable is IPlottableGL plottableGL)
{
plottableGL.Render(rp);
}
else
{
rp.CanvasState.Clip(rp.DataRect);
plottable.Render(rp);
}
rp.CanvasState.DisableClipping();
}

/* code to reproduce the bug */
 MeasuredSpan = avaplot.Plot.Add.HorizontalSpan(x1, x1, Colors.Red.WithOpacity(0.4));
 MeasuredSpan.Axes.XAxis = avaplot.Plot.Axes.Top;

when Plot.Add.HorizontalSpan() called,it will add to the PlottableList,if now is rendering,it will caused collection has changed exception.
So rp.Plot.PlottableList need a sample clone, for example rp.Plot.PlottableList.ToList()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions