[mythtv-commits] Ticket #13621: Convert from Qt foreach() macro to standard C++ range-for.

MythTV noreply at mythtv.org
Thu May 21 20:41:38 UTC 2020


#13621: Convert from Qt foreach() macro to standard C++ range-for.
--------------------------------------+---------------------------
     Reporter:  David Hampton         |      Owner:  David Hampton
         Type:  Bug Report - General  |     Status:  assigned
     Priority:  major                 |  Milestone:  32.0
    Component:  MythTV - General      |    Version:  Master Head
     Severity:  medium                |   Keywords:
Ticket locked:  0                     |
--------------------------------------+---------------------------
 The use of foreach has caused some unexpected problems in the scheduler,
 which were chased down to containers detaching in the call to get the last
 item of the range.  This detach guarantees that the current iterator is
 now invalid and the operation will eventually run off the end of the
 range.

 The Qt company is also planning to remove the foreach/Q_FOREACH macro in
 an (as yet unspecified) upcoming release.

 Replace all instances of the foreach macro with a standard C++ range-for
 iteration, and (in almost all cases) use the qAsConst macro mark to the
 ranges as constant to prevent detaching of the data. There are a couple of
 places where adding the qAsConst macro throws a compiler error, so omit
 qAsConst in those instances.  These cases all appear to occur with
 temporary lists, and this behavior is intentional on Qt's part (see
 https://doc.qt.io/qt-5/qtglobal.html#qAsConst-1).

-- 
Ticket URL: <https://code.mythtv.org/trac/ticket/13621>
MythTV <http://www.mythtv.org>
MythTV Media Center


More information about the mythtv-commits mailing list