Skip to content

SP4: ScatterPlotDraggable IsUnderMouse() crashes after calling ScatterPlot.Update() #2870

@onur-akaydin

Description

@onur-akaydin

Bug Report

Issue: ScatterPlotDraggable.IsUnderMouse method crashes after calling ScatterPlotDraggable.Update method

Reproducing:

Calling ScatterPlotDraggable.Update method with a new pair of Xs and Ys arrays, "larger" than the existing ones, then waiting for any event that is triggering ScatterPlotDraggable.IsUnderMouse method (i.e. a mouse down event) will eventually crash. Because in ScatterPlotDraggable, Xs and Ys are defined as NEW double arrays, IsUnderMouse references to them, however ScatterPlot.Update() method updates the other Xs and Ys arrays in the base class.

myScatterPlotDraggable.Update(newXsWithLargerSize, newYsWithLargerSize);
// make a mouse interaction

I found a solution by removing Xs and Ys properties from ScatterPlotDraggable, and changing the relevant set accessors in ScatterPlot class to "protected set"

In ScatterPlotDraggable.cs:

//public new double[] Xs { get; private set; }
//public new double[] Ys { get; private set; }

In ScatterPlot.cs:

public double[] Xs { get; protected set; }
public double[] Ys { get; protected set; }

But I'm not sure if there is a side effect to doing it like this.

System Details

  • ScottPlot Version: 4.1.65.0
  • Operating System: Windows 11
  • Application Type: WPF
  • .NET Version: .NET 7.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    BUGunexpected behaviorHelp WantedScott won't do this soon, but PRs from the community are welcome!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions