forked from qt-creator/qt-creator
Valgrind: Merge parsers' finished() and internalError() signals
Replace them with done() signal. Change-Id: I5f03df927ddefd803d9cb0b06d3f4c1601a15381 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -1058,12 +1058,12 @@ void MemcheckToolPrivate::loadXmlLogFile(const QString &filePath)
|
|||||||
auto parser = new ThreadedParser;
|
auto parser = new ThreadedParser;
|
||||||
connect(parser, &ThreadedParser::error,
|
connect(parser, &ThreadedParser::error,
|
||||||
this, &MemcheckToolPrivate::parserError);
|
this, &MemcheckToolPrivate::parserError);
|
||||||
connect(parser, &ThreadedParser::internalError,
|
connect(parser, &ThreadedParser::done, this, [this, parser](bool success, const QString &err) {
|
||||||
this, &MemcheckToolPrivate::internalParserError);
|
if (!success)
|
||||||
connect(parser, &ThreadedParser::finished,
|
internalParserError(err);
|
||||||
this, &MemcheckToolPrivate::loadingExternalXmlLogFileFinished);
|
loadingExternalXmlLogFileFinished();
|
||||||
connect(parser, &ThreadedParser::finished,
|
parser->deleteLater();
|
||||||
parser, &ThreadedParser::deleteLater);
|
});
|
||||||
|
|
||||||
parser->parse(logFile); // ThreadedParser owns the file
|
parser->parse(logFile); // ThreadedParser owns the file
|
||||||
}
|
}
|
||||||
|
@@ -162,7 +162,10 @@ ValgrindRunner::ValgrindRunner(QObject *parent)
|
|||||||
{
|
{
|
||||||
connect(&d->m_parser, &ThreadedParser::status, this, &ValgrindRunner::status);
|
connect(&d->m_parser, &ThreadedParser::status, this, &ValgrindRunner::status);
|
||||||
connect(&d->m_parser, &ThreadedParser::error, this, &ValgrindRunner::error);
|
connect(&d->m_parser, &ThreadedParser::error, this, &ValgrindRunner::error);
|
||||||
connect(&d->m_parser, &ThreadedParser::internalError, this, &ValgrindRunner::internalError);
|
connect(&d->m_parser, &ThreadedParser::done, this, [this](bool success, const QString &err) {
|
||||||
|
if (!success)
|
||||||
|
emit internalError(err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ValgrindRunner::~ValgrindRunner()
|
ValgrindRunner::~ValgrindRunner()
|
||||||
|
@@ -318,12 +318,6 @@ static Status::State parseState(const QString &state)
|
|||||||
throw ParserException(Tr::tr("Unknown state \"%1\"").arg(state));
|
throw ParserException(Tr::tr("Unknown state \"%1\"").arg(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::Private::reportInternalError(const QString &e)
|
|
||||||
{
|
|
||||||
errorString = e;
|
|
||||||
emit q->internalError(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Stack makeStack(const XauxWhat &xauxwhat, const QList<Frame> &frames)
|
static Stack makeStack(const XauxWhat &xauxwhat, const QList<Frame> &frames)
|
||||||
{
|
{
|
||||||
Stack s;
|
Stack s;
|
||||||
@@ -618,7 +612,9 @@ void Parser::Private::parse(QIODevice *device)
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(device, return);
|
QTC_ASSERT(device, return);
|
||||||
reader.setDevice(device);
|
reader.setDevice(device);
|
||||||
|
errorString.clear();
|
||||||
|
|
||||||
|
bool success = true;
|
||||||
try {
|
try {
|
||||||
while (notAtEnd()) {
|
while (notAtEnd()) {
|
||||||
blockingReadNext();
|
blockingReadNext();
|
||||||
@@ -639,11 +635,13 @@ void Parser::Private::parse(QIODevice *device)
|
|||||||
checkTool(blockingReadElementText());
|
checkTool(blockingReadElementText());
|
||||||
}
|
}
|
||||||
} catch (const ParserException &e) {
|
} catch (const ParserException &e) {
|
||||||
reportInternalError(e.message());
|
errorString = e.message();
|
||||||
|
success = false;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
reportInternalError(Tr::tr("Unexpected exception caught during parsing."));
|
errorString = Tr::tr("Unexpected exception caught during parsing.");
|
||||||
|
success = false;
|
||||||
}
|
}
|
||||||
emit q->finished();
|
emit q->done(success, errorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
Parser::Parser(QObject *parent)
|
Parser::Parser(QObject *parent)
|
||||||
|
@@ -33,11 +33,10 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void status(const Valgrind::XmlProtocol::Status &status);
|
void status(const Valgrind::XmlProtocol::Status &status);
|
||||||
void error(const Valgrind::XmlProtocol::Error &error);
|
void error(const Valgrind::XmlProtocol::Error &error);
|
||||||
void internalError(const QString &errorString);
|
|
||||||
void errorCount(qint64 unique, qint64 count);
|
void errorCount(qint64 unique, qint64 count);
|
||||||
void suppressionCount(const QString &name, qint64 count);
|
void suppressionCount(const QString &name, qint64 count);
|
||||||
void announceThread(const Valgrind::XmlProtocol::AnnounceThread &announceThread);
|
void announceThread(const Valgrind::XmlProtocol::AnnounceThread &announceThread);
|
||||||
void finished();
|
void done(bool success, const QString &errorString);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Private;
|
class Private;
|
||||||
|
@@ -50,9 +50,7 @@ void ThreadedParser::parse(QIODevice *device)
|
|||||||
qRegisterMetaType<Error>();
|
qRegisterMetaType<Error>();
|
||||||
connect(parser, &Parser::status, this, &ThreadedParser::status, Qt::QueuedConnection);
|
connect(parser, &Parser::status, this, &ThreadedParser::status, Qt::QueuedConnection);
|
||||||
connect(parser, &Parser::error, this, &ThreadedParser::error, Qt::QueuedConnection);
|
connect(parser, &Parser::error, this, &ThreadedParser::error, Qt::QueuedConnection);
|
||||||
connect(parser, &Parser::internalError, this, &ThreadedParser::internalError,
|
connect(parser, &Parser::done, this, &ThreadedParser::done, Qt::QueuedConnection);
|
||||||
Qt::QueuedConnection);
|
|
||||||
connect(parser, &Parser::finished, this, &ThreadedParser::finished, Qt::QueuedConnection);
|
|
||||||
|
|
||||||
m_parserThread = new Thread;
|
m_parserThread = new Thread;
|
||||||
connect(m_parserThread.get(), &QThread::finished, m_parserThread.get(), &QObject::deleteLater);
|
connect(m_parserThread.get(), &QThread::finished, m_parserThread.get(), &QObject::deleteLater);
|
||||||
|
@@ -37,8 +37,7 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void status(const Status &status);
|
void status(const Status &status);
|
||||||
void error(const Error &error);
|
void error(const Error &error);
|
||||||
void internalError(const QString &errorString);
|
void done(bool success, const QString &errorString);
|
||||||
void finished();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<Thread> m_parserThread;
|
QPointer<Thread> m_parserThread;
|
||||||
|
Reference in New Issue
Block a user