Fix crosshair crash on out-of-range hover (FromOADate)#1087
Merged
Conversation
CorrelatedCrosshairManager.OnMouseMove fed the raw mouse X-coordinate straight into DateTime.FromOADate, which throws ArgumentException ("Not a legal OleAut date") for any value outside year 0100-9999. Hovering past the plotted data, or over an empty/auto-scaled chart, can produce such a coordinate and surfaces a modal error dialog (the handler has no try/catch, unlike ChartHoverHelper). Guard xValue against NaN and the legal OADate range and bail out of the crosshair update instead of crashing.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CorrelatedCrosshairManager.OnMouseMovefeeds the raw mouse X-coordinate straight intoDateTime.FromOADate(xValue)with no bounds check.FromOADatethrowsArgumentException: "Not a legal OleAut date"for any value outside year 0100–9999 (the double range-657435.0 … 2958466.0).Hovering past the plotted data — or over a chart whose axis is auto-scaled wide/empty — produces a coordinate outside that range and crashes. Because this handler (unlike
ChartHoverHelper) has notry/catch, the exception escapes to the dispatcher handler and surfaces a modal "An error occurred… Not a legal OleAut date" dialog.Fix
Guard
xValueagainstNaNand the legal OADate range immediately after it's computed, and bail out of the crosshair update rather than throwing. One 7-line guard; no behavior change for in-range hovers.The other two
FromOADatecall sites (ChartHoverHelper.cs:143/225) are already safe — they convert a real plotted-data-point X and are wrapped intry/catch.Notes
devto investigate [BUG] UI fails to render after sleeping/waking up laptop #1050 (unrelated sleep/wake bug). This is a pre-existing crosshair crash, not caused by the [BUG] UI fails to render after sleeping/waking up laptop #1050SoftwareOnlychange.🤖 Generated with Claude Code