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:
Jarek Kobus
2023-08-08 17:03:08 +02:00
parent 3970a834bc
commit 0a320185dc
6 changed files with 20 additions and 23 deletions

View File

@@ -1058,12 +1058,12 @@ void MemcheckToolPrivate::loadXmlLogFile(const QString &filePath)
auto parser = new ThreadedParser;
connect(parser, &ThreadedParser::error,
this, &MemcheckToolPrivate::parserError);
connect(parser, &ThreadedParser::internalError,
this, &MemcheckToolPrivate::internalParserError);
connect(parser, &ThreadedParser::finished,
this, &MemcheckToolPrivate::loadingExternalXmlLogFileFinished);
connect(parser, &ThreadedParser::finished,
parser, &ThreadedParser::deleteLater);
connect(parser, &ThreadedParser::done, this, [this, parser](bool success, const QString &err) {
if (!success)
internalParserError(err);
loadingExternalXmlLogFileFinished();
parser->deleteLater();
});
parser->parse(logFile); // ThreadedParser owns the file
}

View File

@@ -162,7 +162,10 @@ ValgrindRunner::ValgrindRunner(QObject *parent)
{
connect(&d->m_parser, &ThreadedParser::status, this, &ValgrindRunner::status);
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()

View File

@@ -318,12 +318,6 @@ static Status::State parseState(const QString &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)
{
Stack s;
@@ -618,7 +612,9 @@ void Parser::Private::parse(QIODevice *device)
{
QTC_ASSERT(device, return);
reader.setDevice(device);
errorString.clear();
bool success = true;
try {
while (notAtEnd()) {
blockingReadNext();
@@ -639,11 +635,13 @@ void Parser::Private::parse(QIODevice *device)
checkTool(blockingReadElementText());
}
} catch (const ParserException &e) {
reportInternalError(e.message());
errorString = e.message();
success = false;
} 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)

View File

@@ -33,11 +33,10 @@ public:
signals:
void status(const Valgrind::XmlProtocol::Status &status);
void error(const Valgrind::XmlProtocol::Error &error);
void internalError(const QString &errorString);
void errorCount(qint64 unique, qint64 count);
void suppressionCount(const QString &name, qint64 count);
void announceThread(const Valgrind::XmlProtocol::AnnounceThread &announceThread);
void finished();
void done(bool success, const QString &errorString);
private:
class Private;

View File

@@ -50,9 +50,7 @@ void ThreadedParser::parse(QIODevice *device)
qRegisterMetaType<Error>();
connect(parser, &Parser::status, this, &ThreadedParser::status, Qt::QueuedConnection);
connect(parser, &Parser::error, this, &ThreadedParser::error, Qt::QueuedConnection);
connect(parser, &Parser::internalError, this, &ThreadedParser::internalError,
Qt::QueuedConnection);
connect(parser, &Parser::finished, this, &ThreadedParser::finished, Qt::QueuedConnection);
connect(parser, &Parser::done, this, &ThreadedParser::done, Qt::QueuedConnection);
m_parserThread = new Thread;
connect(m_parserThread.get(), &QThread::finished, m_parserThread.get(), &QObject::deleteLater);

View File

@@ -37,8 +37,7 @@ public:
signals:
void status(const Status &status);
void error(const Error &error);
void internalError(const QString &errorString);
void finished();
void done(bool success, const QString &errorString);
private:
QPointer<Thread> m_parserThread;