QDoc: Don't crash on unresolved \relates targets
A documentation comment can relate a free function to something QDoc
cannot use as a relation target, such as a module. QDoc copes by giving
that function its own proxy page. It builds the proxy while still
walking the list of items documented alongside the function, and that
construction quietly extends the very list being walked. Depending on
how those items happen to sit in memory, the walk then reads past the
end of the list and the generator crashes. The defect is latent: most
projects never disturb the layout enough to expose it, but a richer mix
of documented entities tips it into a hard crash.
QDoc now walks a const copy of the collection, so creating a proxy page
can no longer reach back into the walk in progress.
Fixes: QTBUG-147230
Pick-to: 6.12
Change-Id: I75f62d1fbd065785538b18d12b38bcde98612a78
Reviewed-by: Topi Reinio <topi.reinio@qt.io>