Skip to content

Commit 352941f

Browse files
committed
GUI: Fix transporting errors.
Need to register integer list as new metatype so that Qt's type system knows how to use it. Adding also additional constructors for the ErrorItem.
1 parent faa483b commit 352941f

4 files changed

Lines changed: 50 additions & 0 deletions

File tree

gui/erroritem.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Cppcheck - A tool for static C/C++ code analysis
3+
* Copyright (C) 2007-2010 Daniel Marjamäki and Cppcheck team.
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
#include "erroritem.h"
20+
21+
ErrorItem::ErrorItem(const ErrorItem &item)
22+
{
23+
file = item.file;
24+
files = item.files;
25+
lines = item.lines;
26+
id = item.id;
27+
severity = item.severity;
28+
msg = item.msg;
29+
}
30+
31+
ErrorItem::ErrorItem(const ErrorLine &line)
32+
{
33+
file = line.file;
34+
files.append(line.file);
35+
lines.append(line.line.toUInt());
36+
id = line.id;
37+
severity = line.severity;
38+
msg = line.msg;
39+
}

gui/erroritem.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include <QString>
2323
#include <QStringList>
2424

25+
class ErrorLine;
26+
2527
/// @addtogroup GUI
2628
/// @{
2729

@@ -31,6 +33,10 @@
3133
class ErrorItem
3234
{
3335
public:
36+
ErrorItem() { }
37+
ErrorItem(const ErrorItem &item);
38+
ErrorItem(const ErrorLine &line);
39+
3440
QString file;
3541
QStringList files;
3642
QList<unsigned int> lines;

gui/gui.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ SOURCES += main.cpp \
7171
aboutdialog.cpp \
7272
fileviewdialog.cpp \
7373
projectfile.cpp \
74+
erroritem.cpp \
7475
report.cpp \
7576
txtreport.cpp \
7677
xmlreport.cpp \

gui/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@
2020
#include <QApplication>
2121
#include <QTextCodec>
2222
#include <QTranslator>
23+
#include <QMetaType>
2324
#include "mainwindow.h"
2425

2526
int main(int argc, char *argv[])
2627
{
2728
QApplication app(argc, argv);
2829
app.setWindowIcon(QIcon(":icon.png"));
2930

31+
// Register this metatype that is used to transfer error info
32+
qRegisterMetaType<QList<unsigned int>>("QList<unsigned int>");
33+
3034
// Set codecs so that UTF-8 strings in sources are handled correctly.
3135
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
3236
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));

0 commit comments

Comments
 (0)