From 74cefb7f3a3fbf0936aa430423255eae8c46542c Mon Sep 17 00:00:00 2001 From: Reijo Tomperi Date: Fri, 20 Nov 2009 00:19:44 +0200 Subject: [PATCH] Fix #981 (GUI saves report with wrong extension) Apply patch from robertreif http://sourceforge.net/apps/trac/cppcheck/ticket/981 --- gui/mainwindow.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 51dc51698..c968eca83 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -529,7 +529,7 @@ void MainWindow::Save() if (!selectedFile.isEmpty()) { - Report::Type type; + Report::Type type = Report::TXT; if (selectedFilter == tr("XML files (*.xml)")) { type = Report::XML; @@ -542,12 +542,21 @@ void MainWindow::Save() if (!selectedFile.endsWith(".txt", Qt::CaseInsensitive)) selectedFile += ".txt"; } - else + else if (selectedFilter == tr("CSV files (*.csv)")) { type = Report::CSV; if (!selectedFile.endsWith(".csv", Qt::CaseInsensitive)) selectedFile += ".csv"; } + else + { + if (selectedFile.endsWith(".xml", Qt::CaseInsensitive)) + type = Report::XML; + else if (selectedFile.endsWith(".txt", Qt::CaseInsensitive)) + type = Report::TXT; + else if (selectedFile.endsWith(".csv", Qt::CaseInsensitive)) + type = Report::CSV; + } mUI.mResults->Save(selectedFile, type); }