refactor: remove obsolete qt algorithm usage #16674

pull fanquake wants to merge 3 commits into bitcoin:master from fanquake:remove_obselete_qt_usage changing 5 files +19 −9
  1. fanquake commented at 3:29 AM on August 21, 2019: member

    qStablesort, qSort, qLowerBound and qUpperBound have been marked as obsolete since at least Qt 5.9: Obsolete Members for QtAlgorithms.

    This pull request replaces their usage with the suggested std:: replacements.

    This also removes some warning spam when compiling against newer Qt (5.13.0 via brew):

      CXX      qt/libbitcoinqt_a-walletcontroller.o
    qt/transactiontablemodel.cpp:96:52: warning: 'qLowerBound<QList<TransactionRecord>::iterator, uint256, TxLessThan>' is deprecated: Use std::lower_bound [-Wdeprecated-declarations]
            QList<TransactionRecord>::iterator lower = qLowerBound(
    qt/transactiontablemodel.cpp:98:52: warning: 'qUpperBound<QList<TransactionRecord>::iterator, uint256, TxLessThan>' is deprecated: Use std::upper_bound [-Wdeprecated-declarations]
            QList<TransactionRecord>::iterator upper = qUpperBound(
    
      CXX      qt/libbitcoinqt_a-moc_walletcontroller.o
    qt/bantablemodel.cpp:64:13: warning: 'qStableSort<QList<CCombinedBan>::iterator, BannedNodeLessThan>' is deprecated: Use std::stable_sort [-Wdeprecated-declarations]
                qStableSort(cachedBanlist.begin(), cachedBanlist.end(), BannedNodeLessThan(sortColumn, sortOrder));
    
      CXX      qt/libbitcoinqt_a-sendcoinsentry.o
    qt/recentrequeststablemodel.cpp:205:5: warning: 'qSort<QList<RecentRequestEntry>::iterator, RecentRequestEntryLessThan>' is deprecated: Use std::sort [-Wdeprecated-declarations]
        qSort(list.begin(), list.end(), RecentRequestEntryLessThan(column, order));
    
  2. fanquake added the label GUI on Aug 21, 2019
  3. fanquake added the label Refactoring on Aug 21, 2019
  4. hebasto commented at 5:19 AM on August 21, 2019: member

    Concept ACK

  5. in src/qt/addresstablemodel.cpp:89 in aa9ee5e064 outdated
      88 | @@ -89,7 +89,7 @@ class AddressTablePriv
      89 |          // qLowerBound() and qUpperBound() require our cachedAddressTable list to be sorted in asc order
    


    hebasto commented at 5:24 AM on August 21, 2019:

    Could the comment be fixed by removing/replacement mentions of qLowerBound() and qUpperBound()?


    laanwj commented at 7:35 AM on August 21, 2019:

    Agree, let's keep the comment but with the new method names


    fanquake commented at 7:40 AM on August 21, 2019:

    Have reinstated the comment, using the new method names.

  6. laanwj commented at 7:35 AM on August 21, 2019: member

    Thanks, makes sense, if std has something that's usually preferable to using third party APIs.

  7. fanquake force-pushed on Aug 21, 2019
  8. practicalswift commented at 7:46 AM on August 21, 2019: contributor

    Concept ACK: less cruft is better.

  9. Sjors commented at 9:40 AM on August 21, 2019: member

    ACK c19ceb4. Tested on macOS 10.14.6 against depends (always spits out a trillion warnings at the end) as well as homebrew 5.13.0 (quite a few deprecation warnings remaining, but not these).

  10. laanwj approved
  11. laanwj commented at 9:47 AM on August 21, 2019: member

    ACK c19ceb4ea964a11d36ed108eb4d0975bbb38ac3a

  12. MarcoFalke added this to the milestone 0.19.0 on Aug 21, 2019
  13. hebasto commented at 5:14 PM on August 21, 2019: member

    May I suggest to add include <algorithm> to the all modified *.cpp files?

    From Developer Notes - Source code organization:

    • Every .cpp and .h file should #include every header file it directly uses classes, functions or other definitions from, even if those headers are already included indirectly through other headers.
      • Rationale: Excluding headers because they are already indirectly included results in compilation failures when those indirect dependencies change. Furthermore, it obscures what the real code dependencies are.

    Ref: Standard library header <algorithm>

  14. refactor: replace qStableSort with std::stable_sort fea33cbbdf
  15. refactor: replace qSort with std::sort 59373e3e94
  16. refactor: replace qLowerBound & qUpperBound with std:: upper_bound & lower_bound 153d9dd9ac
  17. fanquake force-pushed on Aug 22, 2019
  18. promag commented at 6:23 AM on August 22, 2019: member

    ACK 153d9dd9acffa95bb97a4b1579bd20237fdc9c52.

  19. jonasschnelli approved
  20. jonasschnelli commented at 7:11 AM on August 22, 2019: contributor

    utACK 153d9dd9acffa95bb97a4b1579bd20237fdc9c52

  21. hebasto commented at 7:15 AM on August 22, 2019: member

    ACK 153d9dd9acffa95bb97a4b1579bd20237fdc9c52

  22. fanquake commented at 10:06 AM on August 22, 2019: member

    FWIW looks like these were marked deprecated in Qt 5.2:

    • QtAlgorithms With STL no longer being optional for building and using Qt, a number of parts of QtAlgorithms no longer make sense, and have therefore been deprecated.
  23. fanquake referenced this in commit 868a8cea15 on Aug 22, 2019
  24. fanquake merged this on Aug 22, 2019
  25. fanquake closed this on Aug 22, 2019

  26. fanquake deleted the branch on Aug 22, 2019
  27. jasonbcox referenced this in commit 826e21daed on Dec 20, 2019
  28. PastaPastaPasta referenced this in commit 3c0434f962 on Jun 27, 2021
  29. PastaPastaPasta referenced this in commit 9ed7eb5e58 on Jun 28, 2021
  30. PastaPastaPasta referenced this in commit c10a4b8a73 on Jun 29, 2021
  31. PastaPastaPasta referenced this in commit 453725ac0d on Jul 1, 2021
  32. PastaPastaPasta referenced this in commit 70e6a7a720 on Jul 1, 2021
  33. PastaPastaPasta referenced this in commit a69e18ea70 on Jul 12, 2021
  34. PastaPastaPasta referenced this in commit 77c46e07dc on Jul 13, 2021
  35. MarcoFalke locked this on Dec 16, 2021

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