PDF Viewing Support (poppler-qt4)
Adam Batkin
adam at batkin.net
Fri Feb 15 14:21:00 CET 2008
I've had a lot of trouble getting everything just right. I put some debugging code in my
PdfDocument and PdfPage destructors to notify me when they are called, so I can tell when
the C++ objects are actually destructed.
The interesting bit is the typesystem file for the PdfDocument class:
<object-type name="PdfDocument">
<modify-function signature="page(int)const" access="private"
rename="page_helper">
<modify-argument index="return">
<reference-count action="ignore"/>
<define-ownership class="java" owner="java"/>
</modify-argument>
</modify-function>
<inject-code class="java">
public PdfPage page(int num) {
PdfPage page = page_helper(num);
page.theDocument = this;
return page;
}
</inject-code>
</object-type>
Does that look reasonable? It seems to work. That's basically letting Java keep ownership
of everything, which should work since the PdfPage class now has a Java reference back to
its PdfDocument.
I did some testing with a giant List of every PdfPage ever obtained, and made sure that no
PdfDocuments were ever garbage collected (without the <modify-argument bits the
PdfDocuments would often be GCed too early).
Thanks,
-Adam Batkin
More information about the Qt-jambi-interest
mailing list