Skip to content

Commit 20a4f1e

Browse files
committed
GUI: Output debug errors to log view.
Debug errors were not shown anywhere in the GUI, they were just ignored. This commit adds new signal for those debug errors and directs them to checking log. Solves ticket danmar#1898 (GUI: Handle internal errors from lib)
1 parent 35afc4c commit 20a4f1e

File tree

7 files changed

+44
-1
lines changed

7 files changed

+44
-1
lines changed

gui/erroritem.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,12 @@ ErrorItem::ErrorItem(const ErrorLine &line)
3737
severity = line.severity;
3838
msg = line.msg;
3939
}
40+
41+
QString ErrorItem::ToString() const
42+
{
43+
QString str = file + " - " + id + " - " + severity +"\n";
44+
str += " " + msg;
45+
for (int i = 0; i < files.size(); i++)
46+
str += " " + files[i] + ": " + lines[i] + "\n";
47+
return str;
48+
}

gui/erroritem.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ class ErrorItem
3939
ErrorItem(const ErrorLine &line);
4040
~ErrorItem() { }
4141

42+
/**
43+
* @brief Convert error item to string.
44+
* @return Error item as string.
45+
*/
46+
QString ToString() const;
47+
4248
QString file;
4349
QStringList files;
4450
QList<unsigned int> lines;

gui/mainwindow.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,14 @@ void MainWindow::Log(const QString &logline)
819819
}
820820
}
821821

822+
void MainWindow::DebugError(const ErrorItem &item)
823+
{
824+
if (mLogView)
825+
{
826+
mLogView->AppendLine(item.ToString());
827+
}
828+
}
829+
822830
void MainWindow::EnableProjectActions(bool enable)
823831
{
824832
mUI.mActionCloseProjectFile->setEnabled(enable);

gui/mainwindow.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class ThreadHandler;
3636
class LogView;
3737
class HelpWindow;
3838
class Project;
39+
class ErrorItem;
3940

4041
/// @addtogroup GUI
4142
/// @{
@@ -218,6 +219,12 @@ protected slots:
218219
*/
219220
void Log(const QString &logline);
220221

222+
/**
223+
* @brief Handle new debug error.
224+
*
225+
*/
226+
void DebugError(const ErrorItem &item);
227+
221228
protected:
222229

223230
/**

gui/threadhandler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ void ThreadHandler::Initialize(ResultsView *view)
146146

147147
connect(&mResults, SIGNAL(Log(const QString &)),
148148
parent(), SLOT(Log(const QString &)));
149+
150+
connect(&mResults, SIGNAL(Error(const ErrorItem &)),
151+
parent(), SLOT(Error(const ErrorItem &)));
149152
}
150153

151154
void ThreadHandler::LoadSettings(QSettings &settings)

gui/threadresult.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ void ThreadResult::reportErr(const ErrorLogger::ErrorMessage &msg)
7171
item.msg = QString(msg._msg.c_str());
7272
item.severity = QString::fromStdString(Severity::toString(msg._severity));
7373

74-
emit Error(item);
74+
if (msg._severity != Severity::debug)
75+
emit Error(item);
76+
else
77+
emit DebugError(item);
7578
}
7679

7780
QString ThreadResult::GetNextFile()

gui/threadresult.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ public slots:
100100
*/
101101
void Log(const QString &logline);
102102

103+
/**
104+
* @brief Signal of a debug error
105+
*
106+
* @param item Error data
107+
*/
108+
void DebugError(const ErrorItem &item);
109+
103110
protected:
104111

105112
/**

0 commit comments

Comments
 (0)