From 2880476b2ee10fd8b6e258da5f5c2b7a93746a07 Mon Sep 17 00:00:00 2001 From: Paul Gardiner Date: Wed, 6 Nov 2013 16:51:20 +0000 Subject: Place newly created annotations at the end of the annotation list This fixes bug 694755. Thank you to Michael Cadihac for the patch --- source/pdf/pdf-annot.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c index 338ca1ac..edab4cd5 100644 --- a/source/pdf/pdf-annot.c +++ b/source/pdf/pdf-annot.c @@ -710,6 +710,7 @@ pdf_create_annot(pdf_document *doc, pdf_page *page, fz_annot_type type) { fz_context *ctx = doc->ctx; pdf_annot *annot = NULL; + pdf_annot **lastptr; pdf_obj *annot_obj = pdf_new_dict(doc, 0); pdf_obj *ind_obj = NULL; @@ -753,10 +754,12 @@ pdf_create_annot(pdf_document *doc, pdf_page *page, fz_annot_type type) /* Linking must be done after any call that might throw because - pdf_free_annot below actually frees a list + pdf_free_annot below actually frees a list. Put the new annot + at the end of the list, so that it will be drawn last. */ - annot->next = page->annots; - page->annots = annot; + for (lastptr = &page->annots; *lastptr; lastptr = &(*lastptr)->next) + ; + *lastptr = annot; doc->dirty = 1; } -- cgit v1.2.3