return ReturnCode::E_INVAL_FORMAT;
}
- if (list.size() > 1)
- file.setFileName(backend->filename(plainName, list.cbegin()->first.c_str()));
- else
- file.setFileName(backend->filename(plainName));
-
- /* Export first signal to file */
- if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
- QMessageBox::critical(nullptr, "Data export error", "Cannot open output file for writing.");
- delete backend;
- return ReturnCode::E_FAILED;
- }
-
- ret = writeToFile(file, backend, list.cbegin()->second);
- if (ret != ReturnCode::SUCCESS) {
- file.close();
- delete backend;
- return ret;
- }
-
WriteList::const_iterator cit = list.cbegin();
- std::advance(cit, 1);
for (; cit != list.cend(); cit++) {
- file.setFileName(backend->filename(plainName, cit->first.c_str()));
+ /* Append a signal name to file name if more that one signal is to be exported */
+ if (list.size() > 1)
+ file.setFileName(backend->filename(plainName, cit->first.c_str()));
+ else
+ file.setFileName(backend->filename(plainName));
+
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QMessageBox::critical(nullptr, "Data export error", "Cannot open output file '" + file.fileName() + "' for writing.");
- return ReturnCode::E_FAILED;
+ ret = ReturnCode::E_FAILED;
+ break;
}
ret = writeToFile(file, backend, cit->second);
file.close();