DocumentParsePlan: don't cache often-invalidated cend()
The loop in DocumentParsePlan::removeTargetsForListener()
caches
m_targets.cend()
, which can become invalidated when a target is erased
inside this loop. Comparing to the invalidated end
iterator leads to
undefined behavior.
This undefined behavior makes QmlJS
's test_files crash every other time,
both on my system and on the CI. The alternating crashes of this test
can be seen by clicking Next Build repeatedly starting from the first
build since the bug was introduced:
https://build.kde.org/job/KDevelop/job/kdevelop/job/kf5-qt5%20SUSEQt5.15/165/testReport/junit/projectroot.plugins.qmljs/tests/test_files/
KDevelop often crashes because of this undefined behavior too (see the bug report referenced below).
This bug was introduced in 5ee9b9fe.