2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-03 16:05:57 +00:00

Add some asserts in stats.

This commit is contained in:
John Preston
2025-08-14 16:30:11 +04:00
parent 4cefc21819
commit 96360619e1
2 changed files with 4 additions and 0 deletions

View File

@@ -83,6 +83,8 @@ PiePartData PiePartsPercentageByIndices(
for (const auto &line : chartData.lines) { for (const auto &line : chartData.lines) {
auto sum = ChartValue(0); auto sum = ChartValue(0);
for (auto i = xIndices.min; i <= xIndices.max; i++) { for (auto i = xIndices.min; i <= xIndices.max; i++) {
const auto index = int(base::SafeRound(i));
Assert(index >= 0 && index < line.y.size());
sum += line.y[i]; sum += line.y[i];
} }
if (linesFilter) { if (linesFilter) {

View File

@@ -303,6 +303,7 @@ void PointDetailsWidget::setXIndex(int xIndex) {
if (xIndex < 0) { if (xIndex < 0) {
return; return;
} }
Assert(xIndex < _chartData.x.size());
{ {
constexpr auto kOneDay = 3600 * 24 * 1000; constexpr auto kOneDay = 3600 * 24 * 1000;
const auto timestamp = _chartData.x[xIndex]; const auto timestamp = _chartData.x[xIndex];
@@ -328,6 +329,7 @@ void PointDetailsWidget::setXIndex(int xIndex) {
= (_chartData.currency == Data::StatisticalCurrency::Credits); = (_chartData.currency == Data::StatisticalCurrency::Credits);
for (auto i = 0; i < _chartData.lines.size(); i++) { for (auto i = 0; i < _chartData.lines.size(); i++) {
const auto &dataLine = _chartData.lines[i]; const auto &dataLine = _chartData.lines[i];
Assert(xIndex < dataLine.y.size());
auto textLine = Line(); auto textLine = Line();
textLine.id = dataLine.id; textLine.id = dataLine.id;
if (_maxPercentageWidth) { if (_maxPercentageWidth) {