From d05b47ec0d0ef403233b23874ec0c705b3dc4c53 Mon Sep 17 00:00:00 2001 From: Serhiy Mytrovtsiy Date: Thu, 5 Nov 2020 13:30:50 +0100 Subject: [PATCH] - fix out of bounds when changing to the chart widget (happens only when empty history) --- ModuleKit/Widgets/LineChart.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ModuleKit/Widgets/LineChart.swift b/ModuleKit/Widgets/LineChart.swift index dc548fe8..485facd8 100644 --- a/ModuleKit/Widgets/LineChart.swift +++ b/ModuleKit/Widgets/LineChart.swift @@ -251,7 +251,9 @@ public class LineChart: Widget { public override func setValues(_ values: [value_t]) { let historyValues = values.map{ $0.widget_value }.suffix(60) let end = self.chart.points!.count - self.chart.points!.replaceSubrange(end-historyValues.count...end-1, with: historyValues) + if historyValues.count != 0 { + self.chart.points!.replaceSubrange(end-historyValues.count...end-1, with: historyValues) + } self.display() }