From c833c25499257662ab3bad8083989283fdbe0736 Mon Sep 17 00:00:00 2001 From: m-holger Date: Fri, 16 Dec 2022 17:48:34 +0000 Subject: Delay adding ObjGen to object descriptions until necessary --- libqpdf/qpdf/QPDFValue.hh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libqpdf/qpdf/QPDFValue.hh b/libqpdf/qpdf/QPDFValue.hh index d6fab5ca..c7e63d6c 100644 --- a/libqpdf/qpdf/QPDFValue.hh +++ b/libqpdf/qpdf/QPDFValue.hh @@ -36,9 +36,10 @@ class QPDFValue void setDefaultDescription(QPDF* a_qpdf, QPDFObjGen const& a_og) { + static auto default_description{ + std::make_shared("object $OG")}; if (!object_description) { - object_description = - std::make_shared("object " + a_og.unparse(' ')); + object_description = default_description; } qpdf = a_qpdf; og = a_og; @@ -48,6 +49,9 @@ class QPDFValue { qpdf_p = qpdf; description = object_description ? *object_description : ""; + if (auto pos = description.find("$OG"); pos != std::string::npos) { + description.replace(pos, 3, og.unparse(' ')); + } return qpdf != nullptr; } bool -- cgit v1.2.3-54-g00ecf