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>