Skip to content

Commit 0c82456

Browse files
oliverClimbshannesa2
authored andcommitted
Fixed highlight null pointer exception
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.
1 parent bab50a7 commit 0c82456

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

  • MPChartLib/src/main/java/com/github/mikephil/charting/charts

MPChartLib/src/main/java/com/github/mikephil/charting/charts/Chart.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,10 +791,14 @@ protected void drawMarkers(Canvas canvas) {
791791
IDataSet set = mData.getDataSetByIndex(highlight.getDataSetIndex());
792792

793793
Entry e = mData.getEntryForHighlight(mIndicesToHighlight[i]);
794+
795+
// make sure entry not null before using it
796+
if (e == null)
797+
continue;
798+
794799
int entryIndex = set.getEntryIndex(e);
795800

796-
// make sure entry not null
797-
if (e == null || entryIndex > set.getEntryCount() * mAnimator.getPhaseX())
801+
if (entryIndex > set.getEntryCount() * mAnimator.getPhaseX())
798802
continue;
799803

800804
float[] pos = getMarkerPosition(highlight);

0 commit comments

Comments
 (0)