forked from qt-creator/qt-creator
Delete parsers after parsing is done.
This way we have a chance to flush out any state the parsers might have.
This commit is contained in:
@@ -204,6 +204,12 @@ void AbstractProcessStep::processStarted()
|
|||||||
|
|
||||||
void AbstractProcessStep::processFinished(int exitCode, QProcess::ExitStatus status)
|
void AbstractProcessStep::processFinished(int exitCode, QProcess::ExitStatus status)
|
||||||
{
|
{
|
||||||
|
// Clean up output parsers
|
||||||
|
if (m_outputParserChain) {
|
||||||
|
delete m_outputParserChain;
|
||||||
|
m_outputParserChain = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (status == QProcess::NormalExit && exitCode == 0) {
|
if (status == QProcess::NormalExit && exitCode == 0) {
|
||||||
emit addOutput(tr("The process \"%1\" exited normally.")
|
emit addOutput(tr("The process \"%1\" exited normally.")
|
||||||
.arg(QDir::toNativeSeparators(m_command)),
|
.arg(QDir::toNativeSeparators(m_command)),
|
||||||
|
|||||||
@@ -60,9 +60,9 @@ IOutputParser *IOutputParser::takeOutputParserChain()
|
|||||||
{
|
{
|
||||||
IOutputParser *parser = m_parser;
|
IOutputParser *parser = m_parser;
|
||||||
disconnect(parser, SIGNAL(addOutput(QString,ProjectExplorer::BuildStep::OutputFormat)),
|
disconnect(parser, SIGNAL(addOutput(QString,ProjectExplorer::BuildStep::OutputFormat)),
|
||||||
this, SLOT(outputAdded(QString,ProjectExplorer::BuildStep::OutputFormat)));
|
this, SLOT(outputAdded(QString,ProjectExplorer::BuildStep::OutputFormat)));
|
||||||
disconnect(parser, SIGNAL(addTask(ProjectExplorer::Task)),
|
disconnect(parser, SIGNAL(addTask(ProjectExplorer::Task)),
|
||||||
this, SLOT(taskAdded(ProjectExplorer::Task)));
|
this, SLOT(taskAdded(ProjectExplorer::Task)));
|
||||||
m_parser = 0;
|
m_parser = 0;
|
||||||
return parser;
|
return parser;
|
||||||
}
|
}
|
||||||
@@ -72,6 +72,13 @@ IOutputParser *IOutputParser::childParser() const
|
|||||||
return m_parser;
|
return m_parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IOutputParser::setChildParser(IOutputParser *parser)
|
||||||
|
{
|
||||||
|
if (m_parser != parser)
|
||||||
|
delete m_parser;
|
||||||
|
m_parser = parser;
|
||||||
|
}
|
||||||
|
|
||||||
void IOutputParser::stdOutput(const QString &line)
|
void IOutputParser::stdOutput(const QString &line)
|
||||||
{
|
{
|
||||||
if (m_parser)
|
if (m_parser)
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ public:
|
|||||||
/// Return the head of this parsers output parser children
|
/// Return the head of this parsers output parser children
|
||||||
/// IOutputParser keeps ownership!
|
/// IOutputParser keeps ownership!
|
||||||
IOutputParser *childParser() const;
|
IOutputParser *childParser() const;
|
||||||
|
void setChildParser(IOutputParser *parser);
|
||||||
|
|
||||||
/// Called once for each line if standard output to parse.
|
/// Called once for each line if standard output to parse.
|
||||||
virtual void stdOutput(const QString &line);
|
virtual void stdOutput(const QString &line);
|
||||||
|
|||||||
@@ -64,6 +64,19 @@ void OutputParserTester::testParsing(const QString &lines,
|
|||||||
else
|
else
|
||||||
childParser()->stdError(input);
|
childParser()->stdError(input);
|
||||||
}
|
}
|
||||||
|
// first disconnect ourselves from the end of the parser chain again
|
||||||
|
IOutputParser * parser = this;
|
||||||
|
while (parser = parser->childParser()) {
|
||||||
|
if (parser->childParser() == this) {
|
||||||
|
childParser()->takeOutputParserChain();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
parser = 0;
|
||||||
|
emit aboutToDeleteParser();
|
||||||
|
|
||||||
|
// then delete the parser(s) to test
|
||||||
|
setChildParser(0);
|
||||||
|
|
||||||
QCOMPARE(m_receivedOutput, outputLines);
|
QCOMPARE(m_receivedOutput, outputLines);
|
||||||
QCOMPARE(m_receivedStdErrChildLine, childStdErrLines);
|
QCOMPARE(m_receivedStdErrChildLine, childStdErrLines);
|
||||||
|
|||||||
@@ -70,6 +70,9 @@ public:
|
|||||||
|
|
||||||
void appendOutputParser(IOutputParser *parser);
|
void appendOutputParser(IOutputParser *parser);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void aboutToDeleteParser();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void outputAdded(const QString &line, const QTextCharFormat &textCharFormat);
|
void outputAdded(const QString &line, const QTextCharFormat &textCharFormat);
|
||||||
void taskAdded(const ProjectExplorer::Task &task);
|
void taskAdded(const ProjectExplorer::Task &task);
|
||||||
|
|||||||
Reference in New Issue
Block a user