diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh index 42097425..bcd85cd2 100644 --- a/include/qpdf/QPDF.hh +++ b/include/qpdf/QPDF.hh @@ -843,7 +843,7 @@ class QPDF // it can resolve indirect references. class Resolver { - friend class QPDFObjectHandle; + friend class QPDFObject; private: static void diff --git a/include/qpdf/QPDFObject.hh b/include/qpdf/QPDFObject.hh index 7bb7c6e1..751a5736 100644 --- a/include/qpdf/QPDFObject.hh +++ b/include/qpdf/QPDFObject.hh @@ -153,10 +153,19 @@ class QPDFObject } bool - isUnresolved() + isUnresolved() const { return value->type_code == ::ot_unresolved; } + void + resolve() + { + if (isUnresolved()) { + doResolve(); + } + } + void doResolve(); + template T* as() diff --git a/libqpdf/QPDFObject.cc b/libqpdf/QPDFObject.cc index 8df2b480..8b538021 100644 --- a/libqpdf/QPDFObject.cc +++ b/libqpdf/QPDFObject.cc @@ -1 +1,10 @@ #include + +#include + +void +QPDFObject::doResolve() +{ + auto og = value->og; + QPDF::Resolver::resolve(value->qpdf, og); +} diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index 8a38352f..c55506a5 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -2595,9 +2595,7 @@ QPDFObjectHandle::dereference() if (!isInitialized()) { return false; } - if (this->obj->isUnresolved()) { - QPDF::Resolver::resolve(this->qpdf, getObjGen()); - } + this->obj->resolve(); return true; }