2009-03-01 21:44:42 +01:00
|
|
|
/*
|
|
|
|
* Cppcheck - A tool for static C/C++ code analysis
|
2011-01-09 20:33:36 +01:00
|
|
|
* Copyright (C) 2007-2011 Daniel Marjamäki and Cppcheck team.
|
2009-03-01 21:44:42 +01:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2009-09-27 17:08:31 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-03-01 21:44:42 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-10-31 12:16:55 +01:00
|
|
|
#include <QString>
|
|
|
|
#include <QMutexLocker>
|
|
|
|
#include <QList>
|
|
|
|
#include <QStringList>
|
2009-03-02 20:56:51 +01:00
|
|
|
#include <QDebug>
|
2010-07-14 13:24:46 +02:00
|
|
|
#include "erroritem.h"
|
2010-10-31 12:16:55 +01:00
|
|
|
#include "errorlogger.h"
|
2010-07-14 13:24:46 +02:00
|
|
|
#include "threadresult.h"
|
2009-03-01 21:44:42 +01:00
|
|
|
|
|
|
|
ThreadResult::ThreadResult() : mMaxProgress(0), mProgress(0)
|
|
|
|
{
|
|
|
|
//ctor
|
|
|
|
}
|
|
|
|
|
|
|
|
ThreadResult::~ThreadResult()
|
|
|
|
{
|
|
|
|
//dtor
|
|
|
|
}
|
|
|
|
|
|
|
|
void ThreadResult::reportOut(const std::string &outmsg)
|
|
|
|
{
|
2010-07-16 16:48:13 +02:00
|
|
|
emit Log(QString::fromStdString(outmsg));
|
2009-03-01 21:44:42 +01:00
|
|
|
}
|
|
|
|
|
2009-03-02 20:56:51 +01:00
|
|
|
void ThreadResult::FileChecked(const QString &file)
|
|
|
|
{
|
2009-06-09 08:30:28 +02:00
|
|
|
QMutexLocker locker(&mutex);
|
2009-03-02 20:56:51 +01:00
|
|
|
Q_UNUSED(file); //For later use maybe?
|
|
|
|
mProgress++;
|
2010-07-04 17:54:41 +02:00
|
|
|
emit Progress(mProgress);
|
2009-03-02 20:56:51 +01:00
|
|
|
}
|
|
|
|
|
2009-03-01 21:44:42 +01:00
|
|
|
void ThreadResult::reportErr(const ErrorLogger::ErrorMessage &msg)
|
|
|
|
{
|
|
|
|
QMutexLocker locker(&mutex);
|
|
|
|
|
2010-07-10 19:54:33 +02:00
|
|
|
QList<unsigned int> lines;
|
2009-03-01 21:44:42 +01:00
|
|
|
QStringList files;
|
|
|
|
|
2010-04-02 07:30:58 +02:00
|
|
|
for (std::list<ErrorLogger::ErrorMessage::FileLocation>::const_iterator tok = msg._callStack.begin();
|
|
|
|
tok != msg._callStack.end();
|
|
|
|
++tok)
|
2009-03-01 21:44:42 +01:00
|
|
|
{
|
2010-07-18 10:20:10 +02:00
|
|
|
files << QString((*tok).getfile(false).c_str());
|
2009-03-01 21:44:42 +01:00
|
|
|
lines << (*tok).line;
|
|
|
|
}
|
|
|
|
|
2010-07-14 13:24:46 +02:00
|
|
|
ErrorItem item;
|
|
|
|
item.file = QString(callStackToString(msg._callStack).c_str());
|
|
|
|
item.files = files;
|
|
|
|
item.id = QString(msg._id.c_str());
|
|
|
|
item.lines = lines;
|
2010-11-11 21:51:00 +01:00
|
|
|
item.summary = QString::fromStdString(msg.shortMessage());
|
|
|
|
item.message = QString::fromStdString(msg.verboseMessage());
|
2011-03-07 20:10:30 +01:00
|
|
|
item.severity = msg._severity;
|
2011-04-16 13:04:20 +02:00
|
|
|
item.inconclusive = msg._inconclusive;
|
2010-07-14 13:24:46 +02:00
|
|
|
|
2010-08-28 19:37:21 +02:00
|
|
|
if (msg._severity != Severity::debug)
|
|
|
|
emit Error(item);
|
|
|
|
else
|
|
|
|
emit DebugError(item);
|
2009-03-01 21:44:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QString ThreadResult::GetNextFile()
|
|
|
|
{
|
|
|
|
QMutexLocker locker(&mutex);
|
2010-04-02 07:30:58 +02:00
|
|
|
if (mFiles.size() == 0)
|
2009-03-01 21:44:42 +01:00
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
return mFiles.takeFirst();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-19 13:52:32 +02:00
|
|
|
void ThreadResult::reportStatus(unsigned int fileindex, unsigned int filecount, FileLister::filesize_t sizedone, FileLister::filesize_t sizetotal)
|
2009-03-01 21:44:42 +01:00
|
|
|
{
|
2011-04-19 13:52:32 +02:00
|
|
|
Q_UNUSED(fileindex);
|
|
|
|
Q_UNUSED(filecount);
|
|
|
|
Q_UNUSED(sizedone);
|
|
|
|
Q_UNUSED(sizetotal);
|
2009-03-01 21:44:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ThreadResult::SetFiles(const QStringList &files)
|
|
|
|
{
|
2009-03-02 20:56:51 +01:00
|
|
|
QMutexLocker locker(&mutex);
|
2009-03-01 21:44:42 +01:00
|
|
|
mFiles = files;
|
|
|
|
mProgress = 0;
|
|
|
|
mMaxProgress = files.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ThreadResult::ClearFiles()
|
|
|
|
{
|
2009-03-02 20:56:51 +01:00
|
|
|
QMutexLocker locker(&mutex);
|
2009-03-01 21:44:42 +01:00
|
|
|
mFiles.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
int ThreadResult::GetFileCount()
|
|
|
|
{
|
2009-03-02 20:56:51 +01:00
|
|
|
QMutexLocker locker(&mutex);
|
2009-03-01 21:44:42 +01:00
|
|
|
return mFiles.size();
|
|
|
|
}
|