2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-05-28 16:00:53 +00:00

Move multiple direct owner notes in TODO

This commit is contained in:
Jay Berkenbilt 2022-09-06 10:15:00 -04:00
parent 259eec3a94
commit 706e37a42c

52
TODO
View File

@ -26,31 +26,6 @@ Pending changes:
Soon: Break ground on "Document-level work"
Fix Multiple Direct Object Owner Issue
======================================
These are some ideas I've had, but I'm parking them until I fully
understand m-holger's proposal to split QPDFObject into QPDFObject and
QPDFValue.
* Add std::weak_ptr<QPDFObject> parent to QPDFObject. When adding a
direct object to an array or dictionary, set its parent. When
removing it, clear the parent pointer.
* When a direct object that already has a parent is added to
something, it is a warning and will become an error in qpdf 12.
There needs to be unsafe add methods used by unsafeShallowCopy.
These will add but not modify the parent pointer.
This allows an object to be moved from one object to another by
removing it, which returns the now orphaned object, and then inserting
it somewhere else. It also doesn't break the pattern of adding a
direct object to something and subsequently mutating it. It just
prevents the same object from being added to more than one thing.
Note that arrays and dictionaries still need to contain
QPDFObjectHandle because of indirect objects. This only pertains to
direct objects, which are always "resolved" in QPDFObjectHandle.
Possible future JSON enhancements
=================================
@ -815,3 +790,30 @@ Rejected Ideas
circular references. It seems to be too much trouble in the library
and too much toil for library users to be worth the small benefit of
not having to call resetObjGen in QPDF's destructor.
* Fix Multiple Direct Object Owner Issue
These are some ideas I had before m-holger's changes to split
QPDFValue from QPDFObject. These notes were written prior to the
split of QPDFObject into QPDFValueProxy and QPDFValue and don't work
directly with the new implementation. I think they are still basic
valid after adjusting to the new structure, but I think they would
come at too high a performance cost to be worth doing.
* Add std::weak_ptr<QPDFObject> parent to QPDFObject. When adding a
direct object to an array or dictionary, set its parent. When
removing it, clear the parent pointer.
* When a direct object that already has a parent is added to
something, it is a warning and will become an error in qpdf 12.
There needs to be unsafe add methods used by unsafeShallowCopy.
These will add but not modify the parent pointer.
This allows an object to be moved from one object to another by
removing it, which returns the now orphaned object, and then inserting
it somewhere else. It also doesn't break the pattern of adding a
direct object to something and subsequently mutating it. It just
prevents the same object from being added to more than one thing.
Note that arrays and dictionaries still need to contain
QPDFObjectHandle because of indirect objects. This only pertains to
direct objects, which are always "resolved" in QPDFObjectHandle.