Put XmlReportV2 object on the stack in ResultsView::readErrorsXml() (#1430)

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 <elfring@users.sourceforge.net>
This commit is contained in:
Markus Elfring 2018-10-17 06:38:14 +02:00 committed by Daniel Marjamäki
parent 0a9be3e734
commit 937da6bd46
1 changed files with 8 additions and 13 deletions

View File

@ -331,21 +331,16 @@ void ResultsView::readErrorsXml(const QString &filename)
return;
}
XmlReport *report = new XmlReportV2(filename);
XmlReportV2 report(filename);
QList<ErrorItem> errors;
if (report) {
if (report->open())
errors = report->read();
else {
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;
}
ErrorItem item;
foreach (item, errors) {