Skip to content

Commit

Permalink
HeatMap: Catch memory allocation failures when adding data to the cha…
Browse files Browse the repository at this point in the history
…rt and disable it. For #2083
  • Loading branch information
srcejon committed Oct 11, 2024
1 parent f24600b commit 1654642
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions plugins/channelrx/heatmap/heatmapgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1506,21 +1506,29 @@ void HeatMapGUI::addToPowerSeries(QDateTime dateTime, double average, double pul
{
if (m_powerAverageSeries)
{
qint64 msecs = dateTime.toMSecsSinceEpoch();
if (!std::isnan(average)) {
m_powerAverageSeries->append(msecs, average);
}
if (!std::isnan(pulseAverage)) {
m_powerPulseAverageSeries->append(msecs, pulseAverage);
}
if (!std::isnan(max)) {
m_powerMaxPeakSeries->append(msecs, max);
}
if (!std::isnan(min)) {
m_powerMinPeakSeries->append(msecs, min);
try
{
qint64 msecs = dateTime.toMSecsSinceEpoch();
if (!std::isnan(average)) {
m_powerAverageSeries->append(msecs, average);
}
if (!std::isnan(pulseAverage)) {
m_powerPulseAverageSeries->append(msecs, pulseAverage);
}
if (!std::isnan(max)) {
m_powerMaxPeakSeries->append(msecs, max);
}
if (!std::isnan(min)) {
m_powerMinPeakSeries->append(msecs, min);
}
if (!std::isnan(pathLoss)) {
m_powerPathLossSeries->append(msecs, pathLoss);
}
}
if (!std::isnan(pathLoss)) {
m_powerPathLossSeries->append(msecs, pathLoss);
catch (std::bad_alloc&)
{
QMessageBox::critical(this, "Heat Map", QString("Failed to allocate memory for chart series"));
ui->displayChart->setChecked(false);
}
}
}
Expand Down

0 comments on commit 1654642

Please sign in to comment.