qt6: register meta-types for types used in signal/slots
Summary:
Qt6 seems to have stricter rules than Qt5 regarding registration of meta types. Not registering these two types leads to runtime errors:
QObject::connect: Cannot queue arguments of type 'RPCServer*' (Make sure 'RPCServer*' is registered using qRegisterMetaType().)
After adding these qRegisterMetaType calls, which solve the issue with Qt6, we now also need the Q_DECLARE_METATYPE calls so the code keeps working with Qt5.
/usr/include/x86_64-linux-gnu/qt5/QtCore/qmetatype.h: In instantiation of ‘constexpr int qMetaTypeId() [with T = RPCServer*]’:
/usr/include/x86_64-linux-gnu/qt5/QtCore/qmetatype.h:1916:5: error: static assertion failed: Type is not registered, please use the Q_DECLARE_METATYPE macro to make it known to Qt's meta-object system
1916 | Q_STATIC_ASSERT_X(QMetaTypeId2<T>::Defined, "Type is not registered, please use the Q_DECLARE_METATYPE macro to make it known to Qt's meta-object system");
| ^~~~~~~~~~~~~~~~~Test Plan:
With Qt5 and Qt6:
ninja test_bitcoin-qt src/qt/test/test_bitcoin-qt
Check that there is not runtime error logged as a warning and that the unit tests all pass.
Run bitcoin-qt -debug=qt, check that everything works (without this diff it would be stuck on the loading screen)
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D18206