From 8b62318588a3b4a648dd463ae306be70e3ba99ec Mon Sep 17 00:00:00 2001 From: joshua Date: Wed, 27 Jul 2022 14:52:00 +0200 Subject: [PATCH] Return an empty QByteArray if something goes wrong with dxf2elmt --- sources/dxf/dxftoelmt.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/sources/dxf/dxftoelmt.cpp b/sources/dxf/dxftoelmt.cpp index b9e162a4d..a90b6f081 100644 --- a/sources/dxf/dxftoelmt.cpp +++ b/sources/dxf/dxftoelmt.cpp @@ -28,6 +28,7 @@ * Return the dxf at @a file_path converted to elmt. * The returned value is a QByteArray, instead of a * QDomDocument or QString, to let user do what they want with that. + * If something goes wrong the QByteArray returned is empty. * @param file_path * @return */ @@ -42,11 +43,18 @@ QByteArray dxfToElmt(const QString &file_path) const QStringList arguments{file_path, QStringLiteral("-v")}; process_.start(program, arguments); - process_.waitForFinished(); - const auto byte_array{process_.readAll()}; - process_.close(); - return byte_array; + if (process_.waitForFinished()) + { + const auto byte_array{process_.readAll()}; + process_.close(); + return byte_array; + } + else + { + //Something goes wrong we return an empty QByteArray + return QByteArray(); + } } QString dxf2ElmtDirPath()