summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qmainwindowlayout.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-01-12 11:33:30 +0100
committerMarc Mutz <marc.mutz@qt.io>2023-01-13 21:07:18 +0100
commitce104cac500096734a94e6d132e342d07d7e8af0 (patch)
tree0d81acb3df72835bd3db739f7be735e62f197f23 /src/widgets/widgets/qmainwindowlayout.cpp
parent36619181fb0e507d4a092d74d7ad31c513ddaead (diff)
QPermission: replace T data<T>() with std::optional<T> value<T>()
As discussed in API review, the default-constructed T() returned from a mismatched data<T>() call is indistinguishable from a real T with default state. To make them distinguishable, return optional<T>. Call the new function value<T>(), mimicking QVariant::value<T>(), and suggested in API review, because data() is usually used to return raw pointers, not values. Remove the qWarning() on requestedType and actualType mismatch, as the new function can be used in std::get_if/dynamic_cast-like if-then-else chains, in which failure is part of the normal operation, and a warning message misplaced: if (auto loc = perm.value<QLocationPermission>()) ~~~ use *loc ~~~ else if (auto con = perm.value<QContactsPermission>()) ~~~ use *con ~~~ ~~~ etc ~~~ Pick-to: 6.5 Change-Id: I799a58e930307323ebce8f9ac50a42455e9c017f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/widgets/widgets/qmainwindowlayout.cpp')
0 files changed, 0 insertions, 0 deletions