Suppress clang-tidy mem leak warning on QMetaObject::invokeMethod

We don't leak, but clang-tidy is printing this warning. Possibly because
it sees a new with no matched delete in the same context, ignoring the
fact that the pointer was gifted to the called function.

Fixes: QTBUG-119972
Pick-to: 6.6 6.5
Change-Id: I6e2677aad2ab45759db2fffd17a06c57c3a463ba
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit a337b8360f149313f5bf37dc5867413d846a3a97)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Thiago Macieira 2023-12-13 12:03:03 -03:00 committed by Qt Cherry-pick Bot
parent 3158aa546d
commit b0c031b51b
2 changed files with 2 additions and 0 deletions

View File

@ -622,6 +622,7 @@ private:
auto h = QtPrivate::invokeMethodHelper(ret, args...);
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
auto callable = new QtPrivate::QCallableObject<std::decay_t<Func>, ActualArguments,
typename Callable::ReturnType>(std::forward<Func>(function));
return invokeMethodImpl(object, callable, type, h.parameterCount(), h.parameters.data(),

View File

@ -622,6 +622,7 @@ namespace QtPrivate {
static_assert(int(ActualSignature::ArgumentCount) <= int(ExpectedSignature::ArgumentCount),
"Functor requires more arguments than what can be provided.");
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
return new QtPrivate::QCallableObject<std::decay_t<Functor>, ActualArguments, ExpectedReturnType>(std::forward<Functor>(func));
}