From 706e37a42c4ab2bae47ead5045a582aed7607f4e Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Tue, 6 Sep 2022 10:15:00 -0400 Subject: Move multiple direct owner notes in TODO --- TODO | 52 +++++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/TODO b/TODO index 49d8be62..8bb9fcbe 100644 --- a/TODO +++ b/TODO @@ -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 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 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. -- cgit v1.2.3-54-g00ecf