qt, refactor: Drop unneeded Q_DECLARE_METATYPE #19108

pull hebasto wants to merge 1 commits into bitcoin:master from hebasto:200529-metatype changing 2 files +5 −2
  1. hebasto commented at 5:32 PM on May 29, 2020: member

    For typedefs, which is CAmount, qRegisterMetaType(const char*) only is required.

  2. qt, refactor: Drop unneeded Q_DECLARE_METATYPE
    For typedefs, which is CAmount, qRegisterMetaType(const char*) only is
    required.
    ad113aeb29
  3. jonasschnelli added the label GUI on May 29, 2020
  4. promag commented at 10:26 AM on June 3, 2020: member

    I think you could also drop

    --- a/src/qt/overviewpage.cpp
    +++ b/src/qt/overviewpage.cpp
    @@ -23,8 +23,6 @@
     #define DECORATION_SIZE 54
     #define NUM_ITEMS 5
    
    -Q_DECLARE_METATYPE(interfaces::WalletBalances)
    -
     class TxViewDelegate : public QAbstractItemDelegate
     {
         Q_OBJECT
    

    cc @ryanofsky

  5. hebasto commented at 9:47 AM on June 4, 2020: member

    @promag

    I think you could also drop

    --- a/src/qt/overviewpage.cpp
    +++ b/src/qt/overviewpage.cpp
    @@ -23,8 +23,6 @@
     #define DECORATION_SIZE 54
     #define NUM_ITEMS 5
    
    -Q_DECLARE_METATYPE(interfaces::WalletBalances)
    -
     class TxViewDelegate : public QAbstractItemDelegate
     {
         Q_OBJECT
    

    cc @ryanofsky

    https://github.com/bitcoin/bitcoin/blob/76e64525ff38eaedccf8c2b847eccfffb69be27f/src/qt/walletmodel.h#L193-L195

  6. promag commented at 10:03 AM on June 4, 2020: member

    That doesn't matter with Qt5 connection style. We also don't use QVariant::fromValue with interfaces::WalletBalances. FWIW I've tested without and it worked with QT_FATAL_WARNINGS=1. Maybe I missed something?

  7. hebasto commented at 10:14 AM on June 4, 2020: member

    That doesn't matter with Qt5 connection style. We also don't use QVariant::fromValue with interfaces::WalletBalances. FWIW I've tested without and it worked with QT_FATAL_WARNINGS=1. Maybe I missed something?

    I'm totally agree with you. I mentioned balanceChanged() signal with idea: if it would use Qt::QueuedConnection it will require qRegisterMetaType() and Q_DECLARE_METATYPE().

    The alone Q_DECLARE_METATYPE() (without paired qRegisterMetaType()) only matters for usage with QVariant.

  8. promag commented at 10:16 AM on June 4, 2020: member

    if it would use Qt::QueuedConnection it will require qRegisterMetaType() and Q_DECLARE_METATYPE().

    Are you sure about this?

  9. hebasto commented at 10:19 AM on June 4, 2020: member

    @promag

    if it would use Qt::QueuedConnection it will require qRegisterMetaType() and Q_DECLARE_METATYPE().

    Are you sure about this?

    https://doc.qt.io/qt-5/qt.html#ConnectionType-enum:

    With queued connections, the parameters must be of types that are known to Qt's meta-object system, because Qt needs to copy the arguments to store them in an event behind the scenes.

    Call qRegisterMetaType() to register the data type before you establish the connection.

    https://doc.qt.io/qt-5/qmetatype.html#qRegisterMetaType-1:

    Call this function to register the type T. T must be declared with Q_DECLARE_METATYPE().

    To use the type T in QVariant, using Q_DECLARE_METATYPE() is sufficient. To use the type T in queued signal and slot connections, qRegisterMetaType<T>() must be called before the first connection is established.

  10. luke-jr commented at 4:53 PM on June 5, 2020: member

    Is not needing it for typedefs considered defined behaviour?

  11. hebasto commented at 6:22 PM on June 5, 2020: member

    Is not needing it for typedefs considered defined behaviour?

    Sorry, mind re-wording your question to be clear for me, please?

  12. promag commented at 11:11 AM on June 11, 2020: member

    ACK ad113aeb29c7db6df94cebd784c0c6b668bfd9a5.

  13. DrahtBot commented at 8:46 PM on July 8, 2020: member

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #19471 (util: Make default arg values more specific by hebasto)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  14. fanquake commented at 3:21 PM on July 9, 2020: member

    @laanwj or @jonasschnelli can you weigh in here?

  15. fanquake commented at 7:57 AM on August 10, 2020: member

    Given there's been no follow up for > a month. Can you move this to the GUI repo.

  16. fanquake closed this on Aug 10, 2020

  17. hebasto commented at 12:50 PM on August 14, 2020: member
  18. DrahtBot locked this on Feb 15, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-21 18:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me