dfaure added a comment.
Don't confuse the two rules of porting to range-for (for Qt containers) 1. The container should be const, to avoid paying for a detach. So either a local const var, or qAsConst() over a non-const var (but never a temporary returned by a function!) 2. The container should not be modified inside the loop. If it is, we'll get a crash. Much worse than a detach. You need the qAsConst if the container isn't const, EVEN if it's not modified in the loop. REPOSITORY R241 KIO REVISION DETAIL https://phabricator.kde.org/D23902 To: ahmadsamir, kde-frameworks-devel, dfaure Cc: kde-frameworks-devel, LeGast00n, GB_2, michaelh, ngraham, bruns