Skip to content

Commit 4f49d52

Browse files
committed
gui, refactor: Register Qt meta types in application constructor
1 parent de369c7 commit 4f49d52

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

@@ -435,20 +453,6 @@ int GuiMain(int argc, char* argv[])
435453

436454
BitcoinApplication app(*node);
437455

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

0 commit comments

Comments
 (0)