forked from qt-creator/qt-creator
QtSupport: Minimize calls to MessageManager from ProFileReader
Rather than calling the MessageManager on every debug message, do that only once per parse thread. Somewhat surprisingly, this appears to improve Qt Creator responsiveness noticeably, even when there are not so many messages. Task-number: QTCREATORBUG-18533 Change-Id: Idb689b876741798752bbfe5d84fe1ad99e752de3 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -45,34 +45,36 @@ ProMessageHandler::ProMessageHandler(bool verbose, bool exact)
|
|||||||
: m_verbose(verbose)
|
: m_verbose(verbose)
|
||||||
, m_exact(exact)
|
, m_exact(exact)
|
||||||
//: Prefix used for output from the cumulative evaluation of project files.
|
//: Prefix used for output from the cumulative evaluation of project files.
|
||||||
, m_prefix(tr("[Inexact] "))
|
, m_prefix(QCoreApplication::translate("ProMessageHandler", "[Inexact] "))
|
||||||
{
|
{
|
||||||
connect(this, &ProMessageHandler::writeMessage,
|
|
||||||
Core::MessageManager::instance(), &Core::MessageManager::write, Qt::QueuedConnection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProMessageHandler::~ProMessageHandler()
|
||||||
|
{
|
||||||
|
if (!m_messages.isEmpty())
|
||||||
|
Core::MessageManager::writeMessages(m_messages);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ProMessageHandler::message(int type, const QString &msg, const QString &fileName, int lineNo)
|
void ProMessageHandler::message(int type, const QString &msg, const QString &fileName, int lineNo)
|
||||||
{
|
{
|
||||||
if ((type & CategoryMask) == ErrorMessage && ((type & SourceMask) == SourceParser || m_verbose)) {
|
if ((type & CategoryMask) == ErrorMessage && ((type & SourceMask) == SourceParser || m_verbose)) {
|
||||||
QString fmsg = format(fileName, lineNo, msg);
|
appendMessage(format(fileName, lineNo, msg));
|
||||||
if (m_exact)
|
|
||||||
emit writeMessage(fmsg, Core::MessageManager::NoModeSwitch);
|
|
||||||
else
|
|
||||||
emit writeMessage(m_prefix + fmsg, Core::MessageManager::NoModeSwitch);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProMessageHandler::fileMessage(int type, const QString &msg)
|
void ProMessageHandler::fileMessage(int type, const QString &msg)
|
||||||
{
|
{
|
||||||
Q_UNUSED(type)
|
Q_UNUSED(type)
|
||||||
if (m_verbose) {
|
if (m_verbose)
|
||||||
if (m_exact)
|
appendMessage(msg);
|
||||||
emit writeMessage(msg, Core::MessageManager::NoModeSwitch);
|
|
||||||
else
|
|
||||||
emit writeMessage(m_prefix + msg, Core::MessageManager::NoModeSwitch);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProMessageHandler::appendMessage(const QString &msg)
|
||||||
|
{
|
||||||
|
m_messages << (m_exact ? msg : m_prefix + msg);
|
||||||
|
}
|
||||||
|
|
||||||
ProFileReader::ProFileReader(QMakeGlobals *option, QMakeVfs *vfs)
|
ProFileReader::ProFileReader(QMakeGlobals *option, QMakeVfs *vfs)
|
||||||
: QMakeParser(ProFileCacheManager::instance()->cache(), vfs, this)
|
: QMakeParser(ProFileCacheManager::instance()->cache(), vfs, this)
|
||||||
|
@@ -38,13 +38,11 @@
|
|||||||
namespace QtSupport {
|
namespace QtSupport {
|
||||||
namespace Internal { class QtSupportPlugin; }
|
namespace Internal { class QtSupportPlugin; }
|
||||||
|
|
||||||
class QTSUPPORT_EXPORT ProMessageHandler : public QObject, public QMakeHandler
|
class QTSUPPORT_EXPORT ProMessageHandler : public QMakeHandler
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ProMessageHandler(bool verbose = true, bool exact = true);
|
ProMessageHandler(bool verbose = true, bool exact = true);
|
||||||
~ProMessageHandler() override = default;
|
virtual ~ProMessageHandler();
|
||||||
|
|
||||||
void aboutToEval(ProFile *, ProFile *, EvalFileType) override {}
|
void aboutToEval(ProFile *, ProFile *, EvalFileType) override {}
|
||||||
void doneWithEval(ProFile *) override {}
|
void doneWithEval(ProFile *) override {}
|
||||||
@@ -54,16 +52,16 @@ public:
|
|||||||
void setVerbose(bool on) { m_verbose = on; }
|
void setVerbose(bool on) { m_verbose = on; }
|
||||||
void setExact(bool on) { m_exact = on; }
|
void setExact(bool on) { m_exact = on; }
|
||||||
|
|
||||||
signals:
|
|
||||||
void writeMessage(const QString &error, Core::MessageManager::PrintToOutputPaneFlags flag);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void appendMessage(const QString &msg);
|
||||||
|
|
||||||
bool m_verbose;
|
bool m_verbose;
|
||||||
bool m_exact;
|
bool m_exact;
|
||||||
QString m_prefix;
|
QString m_prefix;
|
||||||
|
QStringList m_messages;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QTSUPPORT_EXPORT ProFileReader : public ProMessageHandler, public QMakeParser, public ProFileEvaluator
|
class QTSUPPORT_EXPORT ProFileReader : public QObject, public ProMessageHandler, public QMakeParser, public ProFileEvaluator
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user