Hello Francesco, hello all, > On 22 February 2018 at 12:20 Francesco Pretto <cez...@gmail.com> wrote: > > > This is also specified in the API documentation. Without the fix > there was a crash trying to insert page at index 0
where did it crash? What kind of crash was it, please? I've looked in the source code and couldn't find a reason for a crash, the index -1 for InsertPage(int, PdfPage*) just means "insert before the first page". > --- > src/doc/PdfPagesTree.cpp | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/src/doc/PdfPagesTree.cpp b/src/doc/PdfPagesTree.cpp > index 2ee8ea2..9d851d3 100644 > --- a/src/doc/PdfPagesTree.cpp > +++ b/src/doc/PdfPagesTree.cpp > @@ -247,11 +247,11 @@ PdfPage* PdfPagesTree::InsertPage( const PdfRect & > rSize, int atIndex) > { > PdfPage* pPage = new PdfPage( rSize, GetRoot()->GetOwner() ); > > - if (atIndex < 0 || atIndex >= this->GetTotalNumberOfPages()) { > - atIndex = this->GetTotalNumberOfPages() - 1; > - } > + if (atIndex < 0 || atIndex > this->GetTotalNumberOfPages()) { > + atIndex = this->GetTotalNumberOfPages(); > + } > > - InsertPage( atIndex - 1, pPage ); > + InsertPage(atIndex, pPage ); > m_cache.AddPageObject( atIndex, pPage ); > > return pPage; I'm sorry, I can't really recommend this your patch for acceptance and wouldn't commit it myself because: - insertion before the first page through this wouldn't be possible - insertion after the last one (giving the correct, by its doc comment, index this->GetTotalNumberOfPages() wouldn't work either: in the method InsertPage(int, PdfObject*) the index is taken as the page index after which to insert, which isn't found, messages of critical severity are output, no insertion is done, then AddPageObject() can't work either (even if it would add, that wouldn't be correct, because the page wasn't inserted into the pages tree) - I'd commit your changed if-clause together with doc-comment clarifying (and indentation fixes), acknowledging you gave me the idea Best regards, mabri ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Podofo-users mailing list Podofo-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/podofo-users