I've often seen ugly code bases that could be tidied up by applying the following transformation: `$smartpointer.data()->...` to `$smartpointer->...` E.g. this is bad: QScopedPointer<QObject*> myObj(new QObject); myObj.data()->deleteLater(); This is much nicer: QScopedPointer<QObject*> myObj(new QObject); myObj->deleteLater();
There's some gcc version that doesn't support this, but maybe old enough to ignore
https://codereview.qt-project.org/#/c/230337/ is an example of gcc 4.8 nagging about missing data()
Git commit 74686cc8c884dbcfabb12ea7a926e0eec486846d by Sergio Martins, on behalf of Waqar Ahmed. Committed on 23/07/2021 at 19:33. Pushed by smartins into branch 'master'. Add use-arrow-operator Suggest to use arrow operator with qt smart pointers instead of .data()->someFunc() print parent class name in warning Signed-off-by: Waqar Ahmed <waqar.17a@gmail.com> M +1 -0 CheckSources.cmake M +1 -0 ClazyTests.cmake M +7 -0 checks.json M +2 -0 src/Checks.h A +90 -0 src/checks/manuallevel/use-arrow-operator.cpp [License: LGPL (v2+)] A +39 -0 src/checks/manuallevel/use-arrow-operator.h [License: LGPL (v2+)] A +8 -0 tests/use-arrow-operator/config.json A +20 -0 tests/use-arrow-operator/main.cpp * A +3 -0 tests/use-arrow-operator/main.cpp.expected The files marked with a * at the end have a non valid license. Please read: https://community.kde.org/Policies/Licensing_Policy and use the headers which are listed at that page. https://invent.kde.org/sdk/clazy/commit/74686cc8c884dbcfabb12ea7a926e0eec486846d