From 937da6bd4673fbaf6df3520f3aba3f2fe06af788 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Wed, 17 Oct 2018 06:38:14 +0200 Subject: [PATCH] Put XmlReportV2 object on the stack in ResultsView::readErrorsXml() (#1430) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dynamic memory allocation was used for a XmlReportV2 object in the function “ResultsView::readErrorsXml”. This object was put on the stack instead so that this software became a bit safer and more efficient. Signed-off-by: Markus Elfring --- gui/resultsview.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index 2c47ac177..eae5661da 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -331,20 +331,15 @@ void ResultsView::readErrorsXml(const QString &filename) return; } - XmlReport *report = new XmlReportV2(filename); - + XmlReportV2 report(filename); QList errors; - if (report) { - if (report->open()) - errors = report->read(); - else { - QMessageBox msgBox; - msgBox.setText(tr("Failed to read the report.")); - msgBox.setIcon(QMessageBox::Critical); - msgBox.exec(); - } - delete report; - report = NULL; + if (report.open()) { + errors = report.read(); + } else { + QMessageBox msgBox; + msgBox.setText(tr("Failed to read the report.")); + msgBox.setIcon(QMessageBox::Critical); + msgBox.exec(); } ErrorItem item;