Skip to content

Commit

Permalink
Fixed highlight null pointer exception
Browse files Browse the repository at this point in the history
Moved the null pointer check to before that pointer was actually being used.

Fixes null pointer exception when removing a dataset from the chart after highlighting a data point on that dataset.
  • Loading branch information
oliverClimbs authored and hannesa2 committed Mar 22, 2022
1 parent bab50a7 commit 0c82456
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -791,10 +791,14 @@ protected void drawMarkers(Canvas canvas) {
IDataSet set = mData.getDataSetByIndex(highlight.getDataSetIndex());

Entry e = mData.getEntryForHighlight(mIndicesToHighlight[i]);

// make sure entry not null before using it
if (e == null)
continue;

int entryIndex = set.getEntryIndex(e);

// make sure entry not null
if (e == null || entryIndex > set.getEntryCount() * mAnimator.getPhaseX())
if (entryIndex > set.getEntryCount() * mAnimator.getPhaseX())
continue;

float[] pos = getMarkerPosition(highlight);
Expand Down

0 comments on commit 0c82456

Please sign in to comment.