# HG changeset patch # User Chris Cannam # Date 1432287735 -3600 # Node ID fd934705973f2806ebf2624f0416341f545e8b50 # Parent 1c37aa13bfd843859345467ddcb23b6bdb981492 Fix crash when importing wide CSV file diff -r 1c37aa13bfd8 -r fd934705973f widgets/CSVFormatDialog.cpp --- a/widgets/CSVFormatDialog.cpp Fri May 22 09:17:52 2015 +0100 +++ b/widgets/CSVFormatDialog.cpp Fri May 22 10:42:15 2015 +0100 @@ -252,15 +252,17 @@ void CSVFormatDialog::applyStartTimePurpose() { - // First check if we already have any - for (int i = 0; i < m_format.getColumnCount(); ++i) { + // First check if we already have any. NB there may be fewer than + // m_format.getColumnCount() elements in m_columnPurposeCombos + // (because of the fuzzy column behaviour) + for (int i = 0; i < m_columnPurposeCombos.size(); ++i) { QComboBox *cb = m_columnPurposeCombos[i]; if (cb->currentIndex() == int(CSVFormat::ColumnStartTime)) { return; } } // and if not, select one - for (int i = 0; i < m_format.getColumnCount(); ++i) { + for (int i = 0; i < m_columnPurposeCombos.size(); ++i) { QComboBox *cb = m_columnPurposeCombos[i]; if (cb->currentIndex() == int(CSVFormat::ColumnValue)) { cb->setCurrentIndex(int(CSVFormat::ColumnStartTime)); @@ -272,7 +274,10 @@ void CSVFormatDialog::removeStartTimePurpose() { - for (int i = 0; i < m_format.getColumnCount(); ++i) { + // NB there may be fewer than m_format.getColumnCount() elements + // in m_columnPurposeCombos (because of the fuzzy column + // behaviour) + for (int i = 0; i < m_columnPurposeCombos.size(); ++i) { QComboBox *cb = m_columnPurposeCombos[i]; if (cb->currentIndex() == int(CSVFormat::ColumnStartTime)) { cb->setCurrentIndex(int(CSVFormat::ColumnValue));