Hi, currently, an Annots object owns the various Annot* objects thus, if you want to keep them, you have to keep the "parent" Annots object around as well. My goal is to have each Annot object stored in each "wrapper" Annotation object of the Qt4 frontend, but without the need to tie them to a Page object. The less "destructive" solution I have so far is a takeAnnot() method (see attached patch) which would get an Annot object and give its ownership to the callee. This also could help the glib frontend, which currently keeps an Annots object around for each page.
What do you think? -- Pino Toscano
diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 4bba3b5..a0f54df 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -4477,7 +4477,7 @@ Annot *Annots::findAnnot(Ref *ref) {
int i;
for (i = 0; i < nAnnots; ++i) {
- if (annots[i]->match(ref)) {
+ if (annots[i] && annots[i]->match(ref)) {
return annots[i];
}
}
@@ -4493,3 +4493,10 @@ Annots::~Annots() {
}
gfree(annots);
}
+
+Annot *Annots::takeAnnot(int i)
+{
+ Annot *a = annots[i];
+ annots[i] = NULL;
+ return a;
+}
diff --git a/poppler/Annot.h b/poppler/Annot.h
index b83c1db..23b2af1 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -1318,6 +1318,10 @@ public:
int getNumAnnots() { return nAnnots; }
Annot *getAnnot(int i) { return annots[i]; }
+ // request the i-th Annot object, which won't be in this Annots object anymore
+ // and replaces it with NULL
+ Annot *takeAnnot(int i);
+
private:
Annot* createAnnot(XRef *xref, Dict* dict, Catalog *catalog, Object *obj);
Annot *findAnnot(Ref *ref);
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
