mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-01 02:13:24 +00:00
Fix crash when importing CSV that requires change of separator
The dialog defaults to tab; if a file is indeed comma separated and one switches to that, data() could be called on a higher index before the model is re-populated. I'm a bit surprised why index.isValid() doesn't catch this, but the manual check appears to work. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
9511ee0294
commit
5a4d85bf7c
1 changed files with 6 additions and 1 deletions
|
@ -217,7 +217,12 @@ QVariant ColumnNameResult::data(const QModelIndex &index, int role) const
|
|||
if (index.row() == 0) {
|
||||
return (columnNames[index.column()]);
|
||||
}
|
||||
return QVariant(columnValues[index.row() -1][index.column()]);
|
||||
// make sure the element exists before returning it - this might get called before the
|
||||
// model is correctly set up again (e.g., when changing separators)
|
||||
if (columnValues.count() > index.row() - 1 && columnValues[index.row() - 1].count() > index.column())
|
||||
return QVariant(columnValues[index.row() - 1][index.column()]);
|
||||
else
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
int ColumnNameResult::rowCount(const QModelIndex &parent) const
|
||||
|
|
Loading…
Add table
Reference in a new issue