Don't save "orphaned" perspectives in defs
Migrated from https://bugs.launchpad.net/inkscape/+bug/197604
Steps to reproduce:
- open Inkscape
- Create a 3D box
- Delete it
What happened?
- left over Perspective object in defs (visible in XML editor).
What should have happened?
- Perspective object deleted, but only when no longer referenced.
Notes
!3592 (merged) does the exact opposite of this request, because removing the 3D box happens on group/ungroup/import/copy, leading to invalid 3D boxes during these operations after these operations as the 3D boxes were regenerated but not the perspective object.
I left some comments on that MR and !3698 (merged) . A brief summary would be:
I think the simplest solution would indeed be to stop deleting Persp3D in the SPBox3D destructor (what this MR does) and try to manage the destruction of the Persp3D object using
inkscape:collect="always"
.I admit, I didn't think about this solution too thoroughly, I'm just trying to think of an existing set of objects that are connected in the same way as SPBox3D and Persp3D. LPEs might be another example of a good link, but they aren't removed properly either. Anyway looking at gradients, they are managed with
inkscape:collect="always"
.
Inkscape Version and Operating System:
- Inkscape 1.2-dev (ae62f47f, 2022-01-18) Linux Mint 20