CSV Import: use file before it is removed by destructor

The reading of a QTemporaryFile must be done before the object it's destroyed,
otherwise the file is removed.

This was broken since 09aaaccace

Reported in issue #2749.
This commit is contained in:
mgrojo
2021-06-20 18:39:50 +02:00
parent 6510bb104e
commit 5097760fe6
+5 -1
View File
@@ -1390,6 +1390,7 @@ void MainWindow::importTableFromCSV()
if (QFile::exists(file))
validFiles.push_back(file);
}
importCSVfiles(validFiles);
} else if(sender() == ui->actionFileImportCsvClipboard) {
// Save clipboard content to temporary file
@@ -1400,9 +1401,12 @@ void MainWindow::importTableFromCSV()
temp.write(clipboard->text().toUtf8());
temp.close();
validFiles.push_back(temp.fileName());
// Note that the temporary file will be removed when the object is
// destroyed, so the reading must be done in the same scope.
importCSVfiles(validFiles);
}
importCSVfiles(validFiles);
}
void MainWindow::exportTableToCSV()