Accessing the parameter manager inside ~CurveConverter() is undefined behaviour because it will be accessed after the main() function
has been exited.
Fixes#13622
Fixes#13621.
Currently the legacy DXF importer creates a main group with the DXF name if a DXF is imported into an existing FreeCAD document. For each DXF layer it then creates a sub-group (or Draft Layer) inside that main group. Objects are nested in the sub-groups (or Draft Layers).
This does not make sense for Draft Layers as they should be nested in the LayerContainer, which should be in the root of the FreeCAD document.
Both for Draft Layers and sub-groups there is the issue that if mutliple DXF files are imported in the same FreeCAD document, exising Draft Layers and sub-groups are not taken into account. For each DXF a new "0" group/layer is created (with a Label that is not "0" and therefore not recognized), and if there are objects on that layer a new group/layer is created for each object (labelled "0001", "0002", "0003", etc).
To solve this the main group with the DXF name is no longer created in the revised code and the layers variable is initialized with the groups/layers that already exist in the FreeCAD document.
Additionally the formatObject function should not format objects that are in Draft Layers. Its action conflicts with the layer mechanism resulting in the last imported object having an incorrect color.
The class MaterialLibrary has a shared pointer to its Material objects and the class Material has a shared pointer to the MaterialLibrary.
The class MaterialManager owns all MaterialLibrary and Material objects in static containers. To resolve the cyclic references the method
cleanup() has been added.
The class ModelLibrary has a shared pointer to its Model objects and the class Model has a shared pointer to the ModelLibrary.
The class ModelManager owns all ModelLibrary and Model objects in static containers. To resolve the cyclic references the method
cleanup() has been added.
The Materials module registers a function to App::CleanupProcess that calls the above cleanup() methods.
NOTE: This registration is only done in debug mode mainly to satisfy memory checkers
If an exception is thrown then the allocated buffer won't be cleaned up. To make this exception-safe the class
StringBufferCleaner is added using the RAII idiom
* Set parent object to FileCardDelegate so that it will be destroyed if the list view is destroyed
* Inside FileCardDelegate::paint() delete the widget