Skip to content

Commit 4430744

Browse files
committed
Merge bitcoin#19104: gui, refactor: Register Qt meta types in application constructor
4f49d52 gui, refactor: Register Qt meta types in application constructor (João Barbosa) Pull request description: Removes a warning when running `QT_QPA_PLATFORM=cocoa src/qt/test/test_bitcoin-qt`. ACKs for top commit: jonasschnelli: Re utACK 4f49d52 hebasto: ACK 4f49d52, tested on macOS 10.15.5. Tree-SHA512: e931a022ba83cb0ef04d82544ebd9b18242f8fc2b41443afce4d5c4222f222e8b3517bdb484a1a4f61377c5dceca067d8ccf250da3a727299448e54bec33ed6e
2 parents 9bc7751 + 4f49d52 commit 4430744

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/qt/bitcoin.cpp

+18-14
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,23 @@ Q_DECLARE_METATYPE(CAmount)
6565
Q_DECLARE_METATYPE(SynchronizationState)
6666
Q_DECLARE_METATYPE(uint256)
6767

68+
static void RegisterMetaTypes()
69+
{
70+
// Register meta types used for QMetaObject::invokeMethod and Qt::QueuedConnection
71+
qRegisterMetaType<bool*>();
72+
qRegisterMetaType<SynchronizationState>();
73+
#ifdef ENABLE_WALLET
74+
qRegisterMetaType<WalletModel*>();
75+
#endif
76+
// Register typedefs (see http://qt-project.org/doc/qt-5/qmetatype.html#qRegisterMetaType)
77+
// IMPORTANT: if CAmount is no longer a typedef use the normal variant above (see https://doc.qt.io/qt-5/qmetatype.html#qRegisterMetaType-1)
78+
qRegisterMetaType<CAmount>("CAmount");
79+
qRegisterMetaType<size_t>("size_t");
80+
81+
qRegisterMetaType<std::function<void()>>("std::function<void()>");
82+
qRegisterMetaType<QMessageBox::Icon>("QMessageBox::Icon");
83+
}
84+
6885
static QString GetLangTerritory()
6986
{
7087
QSettings settings;
@@ -184,6 +201,7 @@ BitcoinApplication::BitcoinApplication(interfaces::Node& node):
184201
returnValue(0),
185202
platformStyle(nullptr)
186203
{
204+
RegisterMetaTypes();
187205
setQuitOnLastWindowClosed(false);
188206
}
189207

@@ -433,20 +451,6 @@ int GuiMain(int argc, char* argv[])
433451

434452
BitcoinApplication app(*node);
435453

436-
// Register meta types used for QMetaObject::invokeMethod and Qt::QueuedConnection
437-
qRegisterMetaType<bool*>();
438-
qRegisterMetaType<SynchronizationState>();
439-
#ifdef ENABLE_WALLET
440-
qRegisterMetaType<WalletModel*>();
441-
#endif
442-
// Register typedefs (see http://qt-project.org/doc/qt-5/qmetatype.html#qRegisterMetaType)
443-
// IMPORTANT: if CAmount is no longer a typedef use the normal variant above (see https://doc.qt.io/qt-5/qmetatype.html#qRegisterMetaType-1)
444-
qRegisterMetaType<CAmount>("CAmount");
445-
qRegisterMetaType<size_t>("size_t");
446-
447-
qRegisterMetaType<std::function<void()>>("std::function<void()>");
448-
qRegisterMetaType<QMessageBox::Icon>("QMessageBox::Icon");
449-
450454
/// 2. Parse command-line options. We do this after qt in order to show an error if there are problems parsing these
451455
// Command-line options take precedence:
452456
node->setupServerArgs();

0 commit comments

Comments
 (0)