QtHelp: Don't materialize gaps in the table of contents depths


The depth of each table of contents item is read from the .qch file.
When it jumped by more than one level, the gap was filled by appending
copies of the last item to the stack, one per missing level. A single
item with depth 0x7FFFFFFF made it append ~2 billion pointers.

Keep only the real items on the stack, together with their depths,
and pick the last item with a lower depth as the parent. This builds
the same tree as before, also for broken depths, without allocating
anything for the gaps.

Add a test for valid and broken depths. The rows without huge depths
pass with the old implementation, too.

Task-number: QTBUG-150684
Pick-to: 6.12 6.8
Change-Id: Ic5eee2e1c8a0875edfd575155253d1327966589f
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
commit37f6a5eacd3c8e3ab8c5ac4430519656048c3080
parent337595afc9b1b3f105006fa0e3413ff82da1c2df
authorJarek Kobus <jaroslaw.kobus@qt.io>
committerJarek Kobus <jaroslaw.kobus@qt.io>
commit timeThu, 1 Oct 2026 15:03:45 +0000