Skip to content

Commit

Permalink
Fix crash if some columns in .csv file is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
srcejon committed Oct 22, 2023
1 parent 1b392ee commit 3b0512b
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions sdrgui/gui/spectrummarkersdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <QStandardPaths>
#include <QColorDialog>
#include <QFileDialog>
#include <QDebug>

#include "gui/dialpopup.h"
#include "util/db.h"
Expand Down Expand Up @@ -772,15 +773,22 @@ void SpectrumMarkersDialog::on_aMarkersImport_clicked()

while (CSV::readRow(in, &cols))
{
m_annotationMarkers.push_back(SpectrumAnnotationMarker());
m_annotationMarkers.back().m_startFrequency = cols[startCol].toLongLong();
m_annotationMarkers.back().m_bandwidth = cols[widthCol].toUInt();
m_annotationMarkers.back().m_text = cols[textCol];
m_annotationMarkers.back().m_show = (SpectrumAnnotationMarker::ShowState) cols[showCol].toInt();
int r = cols[redCol].toInt();
int g = cols[greenCol].toInt();
int b = cols[blueCol].toInt();
m_annotationMarkers.back().m_markerColor = QColor(r, g, b);
if (cols.size() >= 7)
{
m_annotationMarkers.push_back(SpectrumAnnotationMarker());
m_annotationMarkers.back().m_startFrequency = cols[startCol].toLongLong();
m_annotationMarkers.back().m_bandwidth = cols[widthCol].toUInt();
m_annotationMarkers.back().m_text = cols[textCol];
m_annotationMarkers.back().m_show = (SpectrumAnnotationMarker::ShowState) cols[showCol].toInt();
int r = cols[redCol].toInt();
int g = cols[greenCol].toInt();
int b = cols[blueCol].toInt();
m_annotationMarkers.back().m_markerColor = QColor(r, g, b);
}
else
{
qWarning() << "SpectrumMarkersDialog::on_aMarkersImport_clicked: Missing data in " << cols;
}
}

m_annotationMarkerIndex = 0;
Expand Down

0 comments on commit 3b0512b

Please sign in to comment.