Fixed #7278 (GUI: error rechecking with some files)
This commit is contained in:
parent
979dfc3f4e
commit
4aa2876ca0
|
@ -84,6 +84,7 @@ Q_DECLARE_METATYPE(ErrorItem);
|
||||||
class ErrorLine {
|
class ErrorLine {
|
||||||
public:
|
public:
|
||||||
QString file;
|
QString file;
|
||||||
|
QString file0;
|
||||||
unsigned int line;
|
unsigned int line;
|
||||||
QString errorId;
|
QString errorId;
|
||||||
bool inconclusive;
|
bool inconclusive;
|
||||||
|
|
|
@ -221,8 +221,6 @@ void MainWindow::HandleCLIParams(const QStringList ¶ms)
|
||||||
LoadProjectFile(params[index + 1]);
|
LoadProjectFile(params[index + 1]);
|
||||||
} else if ((index = params.indexOf(QRegExp(".*\\.cppcheck$", Qt::CaseInsensitive), 0)) >= 0 && index < params.length() && QFile(params[index]).exists()) {
|
} else if ((index = params.indexOf(QRegExp(".*\\.cppcheck$", Qt::CaseInsensitive), 0)) >= 0 && index < params.length() && QFile(params[index]).exists()) {
|
||||||
LoadProjectFile(params[index]);
|
LoadProjectFile(params[index]);
|
||||||
} else if ((index = params.indexOf(QRegExp(".*\\.xml$", Qt::CaseInsensitive), 0)) >= 0 && index < params.length() && QFile(params[index]).exists()) {
|
|
||||||
LoadResults(params[index]);
|
|
||||||
} else if (params.contains("-l")) {
|
} else if (params.contains("-l")) {
|
||||||
QString logFile;
|
QString logFile;
|
||||||
index = params.indexOf("-l");
|
index = params.indexOf("-l");
|
||||||
|
@ -239,6 +237,8 @@ void MainWindow::HandleCLIParams(const QStringList ¶ms)
|
||||||
} else {
|
} else {
|
||||||
LoadResults(logFile);
|
LoadResults(logFile);
|
||||||
}
|
}
|
||||||
|
} else if ((index = params.indexOf(QRegExp(".*\\.xml$", Qt::CaseInsensitive), 0)) >= 0 && index < params.length() && QFile(params[index]).exists()) {
|
||||||
|
LoadResults(params[index],QDir::currentPath());
|
||||||
} else
|
} else
|
||||||
DoCheckFiles(params);
|
DoCheckFiles(params);
|
||||||
}
|
}
|
||||||
|
@ -815,6 +815,7 @@ void MainWindow::ReCheckSelected(QStringList files, bool all)
|
||||||
for (int i = 0; i < files.size(); ++i)
|
for (int i = 0; i < files.size(); ++i)
|
||||||
mUI.mResults->ClearRecheckFile(files[i]);
|
mUI.mResults->ClearRecheckFile(files[i]);
|
||||||
|
|
||||||
|
mCurrentDirectory = mUI.mResults->GetCheckDirectory();
|
||||||
FileList pathList;
|
FileList pathList;
|
||||||
pathList.AddPathList(files);
|
pathList.AddPathList(files);
|
||||||
if (mProject)
|
if (mProject)
|
||||||
|
|
|
@ -171,7 +171,7 @@ bool ResultsTree::AddErrorItem(const ErrorItem &item)
|
||||||
data["line"] = item.lines[0];
|
data["line"] = item.lines[0];
|
||||||
data["id"] = item.errorId;
|
data["id"] = item.errorId;
|
||||||
data["inconclusive"] = item.inconclusive;
|
data["inconclusive"] = item.inconclusive;
|
||||||
data["file0"] = item.file0;
|
data["file0"] = StripPath(item.file0, true);
|
||||||
stditem->setData(QVariant(data));
|
stditem->setData(QVariant(data));
|
||||||
|
|
||||||
//Add backtrace files as children
|
//Add backtrace files as children
|
||||||
|
@ -347,8 +347,11 @@ void ResultsTree::ClearRecheckFile(const QString &filename)
|
||||||
if (!item)
|
if (!item)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
QString actualfile((!mCheckPath.isEmpty() && filename.startsWith(mCheckPath)) ? filename.mid(mCheckPath.length() + 1) : filename);
|
||||||
QVariantMap data = item->data().toMap();
|
QVariantMap data = item->data().toMap();
|
||||||
if (filename == data["file"].toString()) {
|
QString storedfile = data["file"].toString();
|
||||||
|
storedfile = ((!mCheckPath.isEmpty() && storedfile.startsWith(mCheckPath)) ? storedfile.mid(mCheckPath.length() + 1) : storedfile);
|
||||||
|
if (actualfile == storedfile) {
|
||||||
mModel.removeRow(i);
|
mModel.removeRow(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -833,12 +836,27 @@ void ResultsTree::RecheckSelectedFiles()
|
||||||
item = item->parent();
|
item = item->parent();
|
||||||
QVariantMap data = item->data().toMap();
|
QVariantMap data = item->data().toMap();
|
||||||
QString currentFile = data["file"].toString();
|
QString currentFile = data["file"].toString();
|
||||||
if (Path::isHeader(currentFile.toStdString())) {
|
if (!currentFile.isEmpty()) {
|
||||||
if (!selectedItems.contains(data["file0"].toString()))
|
QString fileNameWithCheckPath;
|
||||||
selectedItems<<data["file0"].toString();
|
QFileInfo curfileInfo(currentFile);
|
||||||
|
if (!curfileInfo.exists() && !mCheckPath.isEmpty() && currentFile.indexOf(mCheckPath) != 0)
|
||||||
|
fileNameWithCheckPath = mCheckPath + "/" + currentFile;
|
||||||
|
else
|
||||||
|
fileNameWithCheckPath = currentFile;
|
||||||
|
const QFileInfo fileInfo(fileNameWithCheckPath);
|
||||||
|
if (!fileInfo.exists()) {
|
||||||
|
AskFileDir(currentFile);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Path::isHeader(currentFile.toStdString())) {
|
||||||
|
if (!data["file0"].toString().isEmpty() && !selectedItems.contains(data["file0"].toString())) {
|
||||||
|
selectedItems<<((!mCheckPath.isEmpty() && (data["file0"].toString().indexOf(mCheckPath) != 0)) ? (mCheckPath + "/" + data["file0"].toString()) : data["file0"].toString());
|
||||||
|
if (!selectedItems.contains(fileNameWithCheckPath))
|
||||||
|
selectedItems<<fileNameWithCheckPath;
|
||||||
|
}
|
||||||
|
} else if (!selectedItems.contains(fileNameWithCheckPath))
|
||||||
|
selectedItems<<fileNameWithCheckPath;
|
||||||
}
|
}
|
||||||
if (!selectedItems.contains(currentFile))
|
|
||||||
selectedItems<<currentFile;
|
|
||||||
}
|
}
|
||||||
emit CheckSelected(selectedItems);
|
emit CheckSelected(selectedItems);
|
||||||
}
|
}
|
||||||
|
@ -1043,6 +1061,12 @@ void ResultsTree::SetCheckDirectory(const QString &dir)
|
||||||
mCheckPath = dir;
|
mCheckPath = dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString ResultsTree::GetCheckDirectory(void)
|
||||||
|
{
|
||||||
|
return mCheckPath;
|
||||||
|
}
|
||||||
|
|
||||||
QString ResultsTree::StripPath(const QString &path, bool saving) const
|
QString ResultsTree::StripPath(const QString &path, bool saving) const
|
||||||
{
|
{
|
||||||
if ((!saving && mShowFullPath) || (saving && mSaveFullPath)) {
|
if ((!saving && mShowFullPath) || (saving && mSaveFullPath)) {
|
||||||
|
|
|
@ -122,6 +122,14 @@ public:
|
||||||
*/
|
*/
|
||||||
void SetCheckDirectory(const QString &dir);
|
void SetCheckDirectory(const QString &dir);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the directory we are checking
|
||||||
|
*
|
||||||
|
* @return Directory containing source files
|
||||||
|
*/
|
||||||
|
|
||||||
|
QString GetCheckDirectory(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check if there are any visible results in view.
|
* @brief Check if there are any visible results in view.
|
||||||
* @return true if there is at least one visible warning/error.
|
* @return true if there is at least one visible warning/error.
|
||||||
|
|
|
@ -230,6 +230,11 @@ void ResultsView::SetCheckDirectory(const QString &dir)
|
||||||
mUI.mTree->SetCheckDirectory(dir);
|
mUI.mTree->SetCheckDirectory(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ResultsView::GetCheckDirectory(void)
|
||||||
|
{
|
||||||
|
return mUI.mTree->GetCheckDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
void ResultsView::CheckingStarted(int count)
|
void ResultsView::CheckingStarted(int count)
|
||||||
{
|
{
|
||||||
mUI.mProgress->setVisible(true);
|
mUI.mProgress->setVisible(true);
|
||||||
|
|
|
@ -106,6 +106,14 @@ public:
|
||||||
*/
|
*/
|
||||||
void SetCheckDirectory(const QString &dir);
|
void SetCheckDirectory(const QString &dir);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the directory we are checking
|
||||||
|
*
|
||||||
|
* @return Directory containing source files
|
||||||
|
*/
|
||||||
|
|
||||||
|
QString GetCheckDirectory(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Inform the view that checking has started
|
* @brief Inform the view that checking has started
|
||||||
*
|
*
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "xmlreport.h"
|
#include "xmlreport.h"
|
||||||
#include "xmlreportv2.h"
|
#include "xmlreportv2.h"
|
||||||
#include "cppcheck.h"
|
#include "cppcheck.h"
|
||||||
|
#include "path.h"
|
||||||
|
|
||||||
static const char ResultElementName[] = "results";
|
static const char ResultElementName[] = "results";
|
||||||
static const char CppcheckElementName[] = "cppcheck";
|
static const char CppcheckElementName[] = "cppcheck";
|
||||||
|
@ -34,6 +35,7 @@ static const char ErrorElementName[] = "error";
|
||||||
static const char ErrorsElementName[] = "errors";
|
static const char ErrorsElementName[] = "errors";
|
||||||
static const char LocationElementName[] = "location";
|
static const char LocationElementName[] = "location";
|
||||||
static const char FilenameAttribute[] = "file";
|
static const char FilenameAttribute[] = "file";
|
||||||
|
static const char IncludedFromFilenameAttribute[] = "file0";
|
||||||
static const char LineAttribute[] = "line";
|
static const char LineAttribute[] = "line";
|
||||||
static const char IdAttribute[] = "id";
|
static const char IdAttribute[] = "id";
|
||||||
static const char SeverityAttribute[] = "severity";
|
static const char SeverityAttribute[] = "severity";
|
||||||
|
@ -120,6 +122,9 @@ void XmlReportV2::WriteError(const ErrorItem &error)
|
||||||
mXmlWriter->writeStartElement(LocationElementName);
|
mXmlWriter->writeStartElement(LocationElementName);
|
||||||
|
|
||||||
QString file = QDir::toNativeSeparators(error.files[i]);
|
QString file = QDir::toNativeSeparators(error.files[i]);
|
||||||
|
if (Path::isHeader(file.toStdString()) && !error.file0.isEmpty()) {
|
||||||
|
mXmlWriter->writeAttribute(IncludedFromFilenameAttribute, quoteMessage(error.file0));
|
||||||
|
}
|
||||||
file = XmlReport::quoteMessage(file);
|
file = XmlReport::quoteMessage(file);
|
||||||
mXmlWriter->writeAttribute(FilenameAttribute, file);
|
mXmlWriter->writeAttribute(FilenameAttribute, file);
|
||||||
const QString line = QString::number(error.lines[i]);
|
const QString line = QString::number(error.lines[i]);
|
||||||
|
@ -206,9 +211,12 @@ ErrorItem XmlReportV2::ReadError(QXmlStreamReader *reader)
|
||||||
if (mXmlReader->name() == LocationElementName) {
|
if (mXmlReader->name() == LocationElementName) {
|
||||||
QXmlStreamAttributes attribs = mXmlReader->attributes();
|
QXmlStreamAttributes attribs = mXmlReader->attributes();
|
||||||
QString file = attribs.value("", FilenameAttribute).toString();
|
QString file = attribs.value("", FilenameAttribute).toString();
|
||||||
|
QString file0 = attribs.value("", IncludedFromFilenameAttribute).toString();
|
||||||
file = XmlReport::unquoteMessage(file);
|
file = XmlReport::unquoteMessage(file);
|
||||||
if (item.file.isEmpty())
|
if (item.file.isEmpty())
|
||||||
item.file = file;
|
item.file = file;
|
||||||
|
if (!file0.isEmpty())
|
||||||
|
item.file0 = XmlReport::unquoteMessage(file0);
|
||||||
item.files.push_back(file);
|
item.files.push_back(file);
|
||||||
const int line = attribs.value("", LineAttribute).toString().toUInt();
|
const int line = attribs.value("", LineAttribute).toString().toUInt();
|
||||||
item.lines.push_back(line);
|
item.lines.push_back(line);
|
||||||
|
|
|
@ -287,6 +287,8 @@ std::string ErrorLogger::ErrorMessage::toXML(bool verbose, int version) const
|
||||||
|
|
||||||
for (std::list<FileLocation>::const_reverse_iterator it = _callStack.rbegin(); it != _callStack.rend(); ++it) {
|
for (std::list<FileLocation>::const_reverse_iterator it = _callStack.rbegin(); it != _callStack.rend(); ++it) {
|
||||||
printer.OpenElement("location", false);
|
printer.OpenElement("location", false);
|
||||||
|
if (Path::isHeader((*it).getfile()) && !file0.empty())
|
||||||
|
printer.PushAttribute("file0", Path::toNativeSeparators(file0).c_str());
|
||||||
printer.PushAttribute("file", (*it).getfile().c_str());
|
printer.PushAttribute("file", (*it).getfile().c_str());
|
||||||
printer.PushAttribute("line", (*it).line);
|
printer.PushAttribute("line", (*it).line);
|
||||||
printer.CloseElement(false);
|
printer.CloseElement(false);
|
||||||
|
|
Loading…
Reference in New Issue