diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 04444d607c..7a10729d93 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -188,17 +188,6 @@ static bool InitSettings() return true; } -/* qDebug() message handler --> debug.log */ -void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString &msg) -{ - Q_UNUSED(context); - if (type == QtDebugMsg) { - LogPrint(BCLog::QT, "GUI: %s\n", msg.toStdString()); - } else { - LogPrintf("GUI: %s\n", msg.toStdString()); - } -} - static int qt_argc = 1; static const char* qt_argv = "bitcoin-qt"; @@ -591,8 +580,7 @@ int GuiMain(int argc, char* argv[]) // Install global event filter for processing Windows session related Windows messages (WM_QUERYENDSESSION and WM_ENDSESSION) qApp->installNativeEventFilter(new WinShutdownMonitor()); #endif - // Install qDebug() message handler to route to debug.log - qInstallMessageHandler(DebugMessageHandler); + // Allow parameter interaction before we create the options model app.parameterSetup(); GUIUtil::LogQtInfo(); diff --git a/src/qt/main.cpp b/src/qt/main.cpp index cad1162243..9ef1bbfe0c 100644 --- a/src/qt/main.cpp +++ b/src/qt/main.cpp @@ -12,18 +12,24 @@ #include #endif // USE_QML +#include #include #include #include #include #include -#include - #include #include #include +#include +#include + +QT_BEGIN_NAMESPACE +class QMessageLogContext; +QT_END_NAMESPACE + #if defined(QT_STATICPLUGIN) #include #if defined(QT_QPA_PLATFORM_XCB) @@ -41,6 +47,19 @@ extern const std::function G_TRANSLATION_FUN = [](cons }; UrlDecodeFn* const URL_DECODE = urlDecode; +namespace { +/* qDebug() message handler --> debug.log */ +void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg) +{ + Q_UNUSED(context); + if (type == QtDebugMsg) { + LogPrint(BCLog::QT, "GUI: %s\n", msg.toStdString()); + } else { + LogPrintf("GUI: %s\n", msg.toStdString()); + } +} +} // namespace + int main(int argc, char* argv[]) { #ifdef WIN32 @@ -54,6 +73,9 @@ int main(int argc, char* argv[]) // Subscribe to global signals from core. noui_connect(); + // Install qDebug() message handler to route to debug.log + qInstallMessageHandler(DebugMessageHandler); + #if USE_QML return QmlGuiMain(argc, argv); #else