diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -69,6 +69,31 @@ // Config is non-copyable so we can only register pointers to it Q_DECLARE_METATYPE(Config *) +static void RegisterMetaTypes() { + // Register meta types used for QMetaObject::invokeMethod and + // Qt::QueuedConnection + qRegisterMetaType(); + qRegisterMetaType(); +#ifdef ENABLE_WALLET + qRegisterMetaType(); +#endif + qRegisterMetaType(); + // Register typedefs (see + // http://qt-project.org/doc/qt-5/qmetatype.html#qRegisterMetaType) + qRegisterMetaType("size_t"); + + qRegisterMetaType>("std::function"); + qRegisterMetaType("QMessageBox::Icon"); + + // Need to register any types Qt doesn't know about if you intend + // to use them with the signal/slot mechanism Qt provides. Even pointers. + // Note that class Config is noncopyable and so we can't register a + // non-pointer version of it with Qt, because Qt expects to be able to + // copy-construct non-pointers to objects for invoking slots + // behind-the-scenes in the 'Queued' connection case. + qRegisterMetaType(); +} + static QString GetLangTerritory() { QSettings settings; // Get desired locale (e.g. "de_DE") @@ -190,6 +215,7 @@ : QApplication(qt_argc, const_cast(&qt_argv)), coreThread(nullptr), optionsModel(nullptr), clientModel(nullptr), window(nullptr), pollShutdownTimer(nullptr), returnValue(0), platformStyle(nullptr) { + RegisterMetaTypes(); setQuitOnLastWindowClosed(false); } @@ -557,31 +583,6 @@ BitcoinApplication app; - // Register meta types used for QMetaObject::invokeMethod and - // Qt::QueuedConnection - qRegisterMetaType(); - qRegisterMetaType(); -#ifdef ENABLE_WALLET - qRegisterMetaType(); -#endif - // Register typedefs (see - // http://qt-project.org/doc/qt-5/qmetatype.html#qRegisterMetaType) - // IMPORTANT: if Amount is no longer a typedef use the normal variant above - // (see https://doc.qt.io/qt-5/qmetatype.html#qRegisterMetaType-1) - qRegisterMetaType("Amount"); - qRegisterMetaType("size_t"); - - qRegisterMetaType>("std::function"); - qRegisterMetaType("QMessageBox::Icon"); - - // Need to register any types Qt doesn't know about if you intend - // to use them with the signal/slot mechanism Qt provides. Even pointers. - // Note that class Config is noncopyable and so we can't register a - // non-pointer version of it with Qt, because Qt expects to be able to - // copy-construct non-pointers to objects for invoking slots - // behind-the-scenes in the 'Queued' connection case. - qRegisterMetaType(); - /// 2. Parse command-line options. We do this after qt in order to show an /// error if there are problems parsing these // Command-line options take precedence: