Skip to content

Commit 7ab2837

Browse files
committed
Merge #14162: gui: Also log and print messages or questions like bitcoind
fa7e969 qt: Also log and print messages or questions like bitcoind (MarcoFalke) dd031e3 noui: Move handlers to header file (MarcoFalke) Pull request description: Testing and debugging after shutdown are harder if the node was run through the gui, because errors and warnings would not be logged to the debug.log or written to the stderr (as is the case for bitcoind). Tree-SHA512: 1154e2bf02e3c2616c8d28609569d6c3c7344c5877ad5c1303245044cc7aced9eaec9627f1e1258ed087b49c2a2e6f99bc6c1ad0abe0a855b61e737bdf2059bc
2 parents eb2f1bd + fa7e969 commit 7ab2837

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

src/noui.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include <boost/signals2/connection.hpp>
1616

17-
static bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style)
17+
bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style)
1818
{
1919
bool fSecure = style & CClientUIInterface::SECURE;
2020
style &= ~CClientUIInterface::SECURE;
@@ -41,19 +41,18 @@ static bool noui_ThreadSafeMessageBox(const std::string& message, const std::str
4141
return false;
4242
}
4343

44-
static bool noui_ThreadSafeQuestion(const std::string& /* ignored interactive message */, const std::string& message, const std::string& caption, unsigned int style)
44+
bool noui_ThreadSafeQuestion(const std::string& /* ignored interactive message */, const std::string& message, const std::string& caption, unsigned int style)
4545
{
4646
return noui_ThreadSafeMessageBox(message, caption, style);
4747
}
4848

49-
static void noui_InitMessage(const std::string& message)
49+
void noui_InitMessage(const std::string& message)
5050
{
5151
LogPrintf("init message: %s\n", message);
5252
}
5353

5454
void noui_connect()
5555
{
56-
// Connect bitcoind signal handlers
5756
uiInterface.ThreadSafeMessageBox_connect(noui_ThreadSafeMessageBox);
5857
uiInterface.ThreadSafeQuestion_connect(noui_ThreadSafeQuestion);
5958
uiInterface.InitMessage_connect(noui_InitMessage);

src/noui.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55
#ifndef BITCOIN_NOUI_H
66
#define BITCOIN_NOUI_H
77

8-
extern void noui_connect();
8+
#include <string>
9+
10+
/** Non-GUI handler, which logs and prints messages. */
11+
bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style);
12+
/** Non-GUI handler, which logs and prints questions. */
13+
bool noui_ThreadSafeQuestion(const std::string& /* ignored interactive message */, const std::string& message, const std::string& caption, unsigned int style);
14+
/** Non-GUI handler, which only logs a message. */
15+
void noui_InitMessage(const std::string& message);
16+
17+
/** Connect all bitcoind signal handlers */
18+
void noui_connect();
919

1020
#endif // BITCOIN_NOUI_H

src/qt/bitcoin.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#include <interfaces/handler.h>
3030
#include <interfaces/node.h>
31+
#include <noui.h>
3132
#include <rpc/server.h>
3233
#include <ui_interface.h>
3334
#include <uint256.h>
@@ -71,9 +72,9 @@ Q_DECLARE_METATYPE(bool*)
7172
Q_DECLARE_METATYPE(CAmount)
7273
Q_DECLARE_METATYPE(uint256)
7374

74-
static void InitMessage(const std::string &message)
75+
static void InitMessage(const std::string& message)
7576
{
76-
LogPrintf("init message: %s\n", message);
77+
noui_InitMessage(message);
7778
}
7879

7980
/** Translate string to current locale using Qt. */

src/qt/bitcoingui.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <chainparams.h>
3232
#include <interfaces/handler.h>
3333
#include <interfaces/node.h>
34+
#include <noui.h>
3435
#include <ui_interface.h>
3536
#include <util.h>
3637

@@ -1217,8 +1218,11 @@ void BitcoinGUI::showModalOverlay()
12171218
modalOverlay->toggleVisibility();
12181219
}
12191220

1220-
static bool ThreadSafeMessageBox(BitcoinGUI *gui, const std::string& message, const std::string& caption, unsigned int style)
1221+
static bool ThreadSafeMessageBox(BitcoinGUI* gui, const std::string& message, const std::string& caption, unsigned int style)
12211222
{
1223+
// Redundantly log and print message in non-gui fashion
1224+
noui_ThreadSafeMessageBox(message, caption, style);
1225+
12221226
bool modal = (style & CClientUIInterface::MODAL);
12231227
// The SECURE flag has no effect in the Qt GUI.
12241228
// bool secure = (style & CClientUIInterface::SECURE);

0 commit comments

Comments
 (0)