Hello, it follows a series of patches to add automatic ownership handling to PdfObject. The issue with current handling of PdfObject ownership is that it's inconsistent and hacky: objects retrieved directly from PdfDictionary or PdfArray won't have owner set, even if one PdfObject is actually storing these containers. The hack currently performed is to set the owner when retrieving objects trough PdfObject::GetIndirectKey(), but this work only for dictionaries (not arrays) and looks fragile as the objects inside dictionaries have inconsistent state despite being part of the document hierarchy.
The patch introduce a mechanism to maintain the ownership of PdfObject automatically by: - Adding PdfObject ownership to both PdfDictionary and PdfArray by inheriting a common PdfOwnedDataType; - Adding a proper semantics for setting owner of PdfObjects: copying objects won't copy owner (it will stay NULL) and assigning objects will keep current owner; - Inserting an object into a PdfDctionary or a PdfArray will set the ownership in the copied object recursively. Some convenience method are also added to PdfArray and PdfDictionaries: - PdfDictionary::FindKey(key) : find objects following references, same as previous PdfObject::GetIndirectKey(); - PdfDictionary::FindKeyParent(key): find objects following references and "/Parent" references. Useful for PdfField and super classes; - PdfArray::FindAt(idx) : find objects following references. The patch introduces some ABI changes to add some common base class functionalities to PdfDictionary, PdfArray. It's also potentially API breaking since PdfObject::SetOwner() is now private. Of course it's possible to leave it public but I don't recommend it since owner handling should be totally hidden to API user and the compilation fix is just to remove the call. The patch applies to r1957 and can be splitted in 5 separate changes: 1) PdfVariant: m_eDataType is really a EPdfDataType 2) PdfDictionary: Removed 2 unneeed lookups in AddKey and RemoveKey functions 3) PdfArray: Removed inheritance from std::vector 4) PdfObject: Introduced automatic ownership handling 5) PdfFontFactory: Fix lookup Type 0 fonts with inline DescendantFonts array 1-2 are just cleaning and small optimizations. 3) takes advantage of the changes to clean PdfArray from fishy inheritance from std::vector and follows approach of PdfDictionary to just wrap it preserving API compatibility. 4) is the core change while 5) is the first PoDoFo bug fixed taking advantage of the change that allows to fix it without hacks. I run the changeset against unit tests and it succeeded, with the exception of test id 49 which is already broken in r1957, so it can't be caused by this patch series. Next steps could be: - Extensively use PdfDictionary::FindKeyParent(key) in PdfField and super classes to support fields hierarchies; - Evaluate deprecation of PdfObject::GetIndirectKey() as same functionality is now provided directly inside PdfDictionary in a more consistent API. _______________________________________________ Podofo-users mailing list Podofo-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/podofo-users