Return an empty QByteArray if something goes wrong with dxf2elmt

This commit is contained in:
joshua
2022-07-27 14:52:00 +02:00
parent 31466a65ba
commit 8b62318588

View File

@@ -28,6 +28,7 @@
* Return the dxf at @a file_path converted to elmt. * Return the dxf at @a file_path converted to elmt.
* The returned value is a QByteArray, instead of a * The returned value is a QByteArray, instead of a
* QDomDocument or QString, to let user do what they want with that. * QDomDocument or QString, to let user do what they want with that.
* If something goes wrong the QByteArray returned is empty.
* @param file_path * @param file_path
* @return * @return
*/ */
@@ -42,11 +43,18 @@ QByteArray dxfToElmt(const QString &file_path)
const QStringList arguments{file_path, QStringLiteral("-v")}; const QStringList arguments{file_path, QStringLiteral("-v")};
process_.start(program, arguments); process_.start(program, arguments);
process_.waitForFinished();
if (process_.waitForFinished())
{
const auto byte_array{process_.readAll()}; const auto byte_array{process_.readAll()};
process_.close(); process_.close();
return byte_array; return byte_array;
}
else
{
//Something goes wrong we return an empty QByteArray
return QByteArray();
}
} }
QString dxf2ElmtDirPath() QString dxf2ElmtDirPath()