Merge #17427: qt: Fix missing qRegisterMetaType for size_t

1828c6f05f refactor: Styling w/ clang-format, comment update (Hennadii Stepanov)
88a94f7bb8 qt: Fix missing qRegisterMetaType for size_t (Hennadii Stepanov)

Pull request description:

  On master (a7aec7ad97) this connection a7aec7ad97/src/qt/rpcconsole.cpp (L587) fails due to `ClientModel::mempoolSizeChanged()` signal has unregistered parameter type `size_t`: a7aec7ad97/src/qt/clientmodel.h (L102)

  More:
  ```
  $ QT_FATAL_WARNINGS=1 lldb src/qt/bitcoin-qt -- -debug=qt
  ...
  (lldb) bt
  * thread #17, name = 'QThread', stop reason = signal SIGABRT
    * frame #0: 0x00007ffff35fce97 libc.so.6`__GI_raise(sig=2) at raise.c:51
      frame #1: 0x00007ffff35fe801 libc.so.6`__GI_abort at abort.c:79
      frame #2: 0x00007ffff5901352 libQt5Core.so.5`QMessageLogger::warning(char const*, ...) const + 354
      frame #3: 0x00007ffff5b216fe libQt5Core.so.5`___lldb_unnamed_symbol2329$$libQt5Core.so.5 + 334
      frame #4: 0x00007ffff5b2456d libQt5Core.so.5`QMetaObject::activate(QObject*, int, int, void**) + 1933
      frame #5: 0x000055555566872e bitcoin-qt`ClientModel::mempoolSizeChanged(this=<unavailable>, _t1=<unavailable>, _t2=<unavailable>) at moc_clientmodel.cpp:260
  ...

  ```

  `debug.log`:
  ```
  [] GUI: QObject::connect: Cannot queue arguments of type 'size_t'
  (Make sure 'size_t' is registered using qRegisterMetaType().)
  ```

  This PR fixes it.

  Refs:
  - [Qt docs: qRegisterMetaType](https://doc.qt.io/qt-5/qmetatype.html#qRegisterMetaType)
  - #16348

  ---

  Side NOTE: Also I believe this line a7aec7ad97/src/qt/bitcoin.cpp (L63) is redundant since long `CAmount` is a `typedef`.

ACKs for top commit:
  laanwj:
    Tested ACK 1828c6f05f

Tree-SHA512: 2c7f9fe6a5ae70f2e1dd86b07f95d4b00c85c5706a9d722f063f80beb71880d012ec46556963fb1544c2af53d006936c2f7612eae60d9193f67db62ba3d86129
This commit is contained in:
Wladimir J. van der Laan 2019-11-10 11:29:51 +01:00
commit 89e93135ae
No known key found for this signature in database
GPG Key ID: 1E4AED62986CD25D

View File

@ -430,16 +430,19 @@ int GuiMain(int argc, char* argv[])
BitcoinApplication app(*node); BitcoinApplication app(*node);
// Register meta types used for QMetaObject::invokeMethod // Register meta types used for QMetaObject::invokeMethod and Qt::QueuedConnection
qRegisterMetaType< bool* >(); qRegisterMetaType<bool*>();
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
qRegisterMetaType<WalletModel*>(); qRegisterMetaType<WalletModel*>();
#endif #endif
// Need to pass name here as CAmount is a typedef (see http://qt-project.org/doc/qt-5/qmetatype.html#qRegisterMetaType) // Register typedefs (see http://qt-project.org/doc/qt-5/qmetatype.html#qRegisterMetaType)
// IMPORTANT if it is no longer a typedef use the normal variant above // IMPORTANT: if CAmount is no longer a typedef use the normal variant above (see https://doc.qt.io/qt-5/qmetatype.html#qRegisterMetaType-1)
qRegisterMetaType< CAmount >("CAmount"); qRegisterMetaType<CAmount>("CAmount");
qRegisterMetaType< std::function<void()> >("std::function<void()>"); qRegisterMetaType<size_t>("size_t");
qRegisterMetaType<std::function<void()>>("std::function<void()>");
qRegisterMetaType<QMessageBox::Icon>("QMessageBox::Icon"); qRegisterMetaType<QMessageBox::Icon>("QMessageBox::Icon");
/// 2. Parse command-line options. We do this after qt in order to show an error if there are problems parsing these /// 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: // Command-line options take precedence:
node->setupServerArgs(); node->setupServerArgs();