Skip to content

Commit

Permalink
Merge pull request #2377 from srcejon/sid_fix_read_csv
Browse files Browse the repository at this point in the history
SID: Fix crash when loading data from .csv.
  • Loading branch information
f4exb authored Jan 19, 2025
2 parents aa65bd5 + c62a25f commit 83b36c6
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions plugins/feature/sid/sidgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2396,8 +2396,11 @@ void SIDGUI::readCSV(const QString& filename, bool autoload)
if (CSV::readRow(in, &colNames))
{
QList<ChannelMeasurement *> measurements;
for (int i = 0; i < colNames.size() - 1; i++) {
QList<int> measurementIdx;
for (int i = 0; i < colNames.size() - 1; i++)
{
measurements.append(nullptr);
measurementIdx.append(-1);
}
for (int i = 1; i < colNames.size(); i++)
{
Expand Down Expand Up @@ -2439,7 +2442,8 @@ void SIDGUI::readCSV(const QString& filename, bool autoload)
} else {
id = name;
}
measurements[i-1] = &addMeasurements(id);
addMeasurements(id);
measurementIdx[i-1] = m_channelMeasurements.size() - 1;

// Create settings, if we don't have them
SIDSettings::ChannelSettings *channelSettings = m_settings.getChannelSettings(id);
Expand Down Expand Up @@ -2482,7 +2486,11 @@ void SIDGUI::readCSV(const QString& filename, bool autoload)
if (!valueStr.isEmpty())
{
double value = valueStr.toDouble();
measurements[i]->append(dateTime, value, false);
if (measurements[i]) {
measurements[i]->append(dateTime, value, false);
} else {
m_channelMeasurements[measurementIdx[i]].append(dateTime, value, false);
}
}
}
}
Expand Down

0 comments on commit 83b36c6

Please sign in to comment.