Skip to content

Commit e3f6636

Browse files
Prevent crash when updating datasets and calling animation functions
Sometimes, when changing datasets and then animating, an erroneous highlight is generated for the removed dataset. Null check prevents crash (interestingly the iOS lib had the same issue)
1 parent b3d33e3 commit e3f6636

File tree

1 file changed

+3
-1
lines changed
  • MPChartLib/src/main/java/com/github/mikephil/charting/charts

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,8 +761,10 @@ protected void drawMarkers(Canvas canvas) {
761761

762762
for (Highlight highlight : mIndicesToHighlight) {
763763

764+
// When changing data sets and calling animation functions, sometimes an erroneous highlight is generated
765+
// on the dataset that is removed. Null check to prevent crash
764766
IDataSet set = mData.getDataSetByIndex(highlight.getDataSetIndex());
765-
if (!set.isVisible()) {
767+
if (set == null || !set.isVisible()) {
766768
continue;
767769
}
768770

0 commit comments

Comments
 (0)