qt: function filterAcceptsRow seems to be unused #18860

issue brakmic opened this issue on May 3, 2020
  1. brakmic commented at 9:16 PM on May 3, 2020: contributor

    I have read in @practicalswift 's Issue #18858 that there was an unused function found, so I thought, I could maybe also run a few simple searches through the code. Just for the sake of learning. For that I used cppcheck.

    cppcheck --enable=unusedFunction src/qt
    

    Of course, there are many false positives, but one function seems to be lying dormant for quite a long time: filterAcceptsRow from qt/transactionfilterproxy.cpp.

    Also, there is another one in addressbookpage.cpp. However, this one seems to have only a definition. I could not find its corresponding class member declaration. Not sure why, but there isn't one in addressbookpage.h.

    Another interesting aspect is, that filterAcceptsRow from transactionfilterproxy.cpp was present since 0.15, without ever having been used, if I am not mistaken. And there were no changes until 0.17, when the other variant from addressbookpage.cpp got implemented.

    I don't understand the reasons, and it could be that I am simply missing the forest for the trees, but I could compile, run and also qt-test my modified code without any failure. That is, without having compiled filterAcceptsRow in both of the classes.

    However, before opening a PR, I would like to ask experienced people for advice. Is there anything that I might have been missed? Do these functions maybe exist for testing purposes only?

    Regards,

    ---EDIT:

    There are a few more of them, but I did not check them thoroughly. Will have to recompile/retest the code first.

    src/qt/rpcconsole.cpp:123:0: style: The function 'Name' is never used. [unusedFunction]
    
    ^
    src/qt/rpcconsole.cpp:124:0: style: The function 'NewTimer' is never used. [unusedFunction]
    
    ^
    src/qt/bitcoinamountfield.cpp:45:0: style: The function 'fixup' is never used. [unusedFunction]
    
    ^
    src/qt/bitcoinamountfield.cpp:67:0: style: The function 'stepBy' is never used. [unusedFunction]
    
    ^
    src/qt/bitcoinamountfield.cpp:167:0: style: The function 'stepEnabled' is never used. [unusedFunction]
    
  2. MarcoFalke commented at 9:25 PM on May 3, 2020: member
  3. brakmic commented at 9:26 PM on May 3, 2020: contributor

    The function is virtual, see https://doc.qt.io/qt-5/qsortfilterproxymodel.html#filterAcceptsRow

    Ok, now I understand. Before C++11 there was no override keyword so it was a bit harder to distinguish between such functions and non-overridden ones.

  4. promag commented at 9:29 PM on May 3, 2020: member

    TransactionFilterProxy::filterAcceptsRow is called when any model filter is changed (when invalidateFilter is called). For instance see TransactionFilterProxy::setSearchString.

  5. brakmic commented at 9:32 PM on May 3, 2020: contributor

    TransactionFilterProxy::filterAcceptsRow is called when any model filter is changed (when invalidateFilter is called). For instance see TransactionFilterProxy::setSearchString.

    Yes, I see it. In several places. Qt Framework magic. Thanks for the explanation. Maybe it should be written down, somewhere, like a Qt/UI-doc.

  6. practicalswift commented at 9:33 PM on May 3, 2020: contributor

    @brakmic If you want to investigate unused functions generally in our code base then you might want to take a look at #18670 (comment) :)

  7. brakmic commented at 9:34 PM on May 3, 2020: contributor

    @brakmic If you want to investigate unused functions generally in our code base then you might want to take a look at #18670 (comment) :)

    Wow, that's an impressive collection you have there. :) Many thanks!

  8. promag commented at 9:36 PM on May 3, 2020: member

    Having override would be nice. I think this can be closed.

  9. brakmic closed this on May 3, 2020

  10. practicalswift commented at 9:37 PM on May 3, 2020: contributor

    @brakmic

    Wow, that's an impressive collection you have there. :)

    Please note that the list in #18670 (comment) is only a subset all unused functions.

    Proof: CCoinsViewCache::GetValueIn(…) was missing in the list :)

  11. hebasto commented at 11:07 PM on May 3, 2020: member

    @promag

    Having override would be nice. I think this can be closed.

    Do you mean #16710? :smiley:

  12. 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-13 15:14 UTC

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