Fix stack overflow caused by recursive calls of destructors
When a deeply nested SVG file runs on a platform with a limited
stack size, recursive calls of destructors will lead to a stack
overflow. This fix adds a function in QSvgDocument that will
flatten the tree resulting in a stack depth of 1. This function
will not be called when AssumeTrustedSource flag is set to true.
Task-number: QTBUG-145916
Pick-to: 6.11
Change-Id: I0fbdeb8222ca39c2db091ebb1ad5c5c4ad44633a
Reviewed-by: Robert Löhning <robert.loehning@qt.io>