diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-07-31 16:15:31 +0300 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-08-10 15:14:14 +0300 |
commit | 075fa6203856bdf9f58e737ee2f5d2a843a85cad (patch) | |
tree | 10f99f678bee744e04de2ba80da1d43223fa693e /src/imports | |
parent | ba875f66b8bb4b696f33223638edb2a9e7ba0996 (diff) |
AVFCameraUtility: fix UB (std::sort with unfit predicate)
ResolutionPredicate defines an order on the resolutions (expressed as
QSize) of AVCaptureDeviceFormats, from smallest (width as primary,
height as secondary sort key) to largest, as the lexicographical
less-than of width and height. A a lexicographical order over Strict
Weak Orders is a Strict Weak Order of the product type. So far, so
good.
The logical negation of a Stict Weak Order is, however, not a Strict
Weak Order (not-less-than is greater-or-equal, not greater-than), so
it cannot be used as the predicate in std::sort.
Rewrite the ResolutionPredicate as an adapter that can be used with
std::less _or_ std::greater (or even std::equal_to), piggy-backing on
std::tuple to implement the lexicographical sort for us, then replace
not2(ResolutionPredicate) with ResolutionPredicate<std::greater>.
Rename the predicate to something more apt.
This also solves the use of deprecated (and in C++20, removed)
std::not2.
Change-Id: I6f81b149e53a5b4299b188bf3ce996f638bf3334
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/imports')
0 files changed, 0 insertions, 0 deletions