Bug 361489 - qdeleteall: Do not warn on qDeleteAll(some_hash.values(some_key))
Summary: qdeleteall: Do not warn on qDeleteAll(some_hash.values(some_key))
Status: RESOLVED FIXED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Sergio Martins
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-07 09:23 UTC by Richard
Modified: 2016-04-08 16:34 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard 2016-04-07 09:23:32 UTC
I think the check should not warn and it should definitely not propose the wrong fix on code like this.
QHash <int, MyClass*> some_hash;
//...
qDeleteAll(some_hash.values(some_key))
Just the call without arguments should be flaged: qDeleteAll(some_hash.values())

Reproducible: Always
Comment 1 Sergio Martins 2016-04-07 12:10:09 UTC
I'll fix the warning message but not remove it.

hash.values(key), just like hash.values() will malloc to create a temporary list

hash.values(key) is a bit more cumbersome for you to fix though, you'd have to write a for loop.
So I've added QHash::equal_range(key), which will be available in Qt 5.7.
Comment 2 Sergio Martins 2016-04-08 16:34:27 UTC
Git commit 53963579d6cc4410cb414302b23772837d8577e1 by Sergio Martins.
Committed on 08/04/2016 at 16:33.
Pushed by smartins into branch 'master'.

qdeleteall: Fix warning when using the values(key) overload

M  +6    -1    checks/qdeleteall.cpp
M  +2    -0    tests/qdeleteall/main.cpp
M  +1    -0    tests/qdeleteall/main.cpp.expected

http://commits.kde.org/clazy/53963579d6cc4410cb414302b23772837d8577e1