Unsolved QQmlApplicationEngine engine slow to construct after installing custom message handler
-
Calling
QQmlApplicationEngine engine;
needs around 8 seconds, ifqInstallMessageHandler(myMessageOutput);
is called before.
Without callingqInstallMessageHandler(myMessageOutput);
it needs around 400 milliseconds. Used version is Desktop_Qt_5_6_0_MSVC2015_64bit-Debug.#include <QGuiApplication> #include <QQmlApplicationEngine> #include <QElapsedTimer> void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) { return; } int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); qInstallMessageHandler(myMessageOutput); QElapsedTimer timer; timer.start(); QQmlApplicationEngine engine; // This line takes around 8 seconds. But without calling qInstallMessageHandler, it takes around 400 milliseconds. Why? qint64 elapsed = timer.elapsed(); engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); return app.exec(); }