mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 19:08:59 +00:00
Make QPDFValue::object_description a shared pointer
This commit is contained in:
parent
218f069a69
commit
e684d8169b
@ -2176,7 +2176,8 @@ QPDFObjectHandle::setObjectDescription(
|
||||
// This is called during parsing on newly created direct objects,
|
||||
// so we can't call dereference() here.
|
||||
if (isInitialized() && obj.get()) {
|
||||
obj->setDescription(owning_qpdf, object_description);
|
||||
auto descr = std::make_shared<std::string>(object_description);
|
||||
obj->setDescription(owning_qpdf, descr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -419,11 +419,10 @@ QPDFParser::setDescription(
|
||||
qpdf_offset_t parsed_offset) const
|
||||
{
|
||||
if (auto& obj = oh.obj) {
|
||||
obj->setDescription(
|
||||
context,
|
||||
(input->getName() + ", " + object_description + " at offset " +
|
||||
std::to_string(descr_offset)),
|
||||
parsed_offset);
|
||||
auto descr = std::make_shared<std::string>(
|
||||
input->getName() + ", " + object_description + " at offset " +
|
||||
std::to_string(descr_offset));
|
||||
obj->setDescription(context, descr, parsed_offset);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,10 +123,9 @@ QPDF_Stream::QPDF_Stream(
|
||||
throw std::logic_error("stream object instantiated with non-dictionary "
|
||||
"object for dictionary");
|
||||
}
|
||||
setDescription(
|
||||
qpdf,
|
||||
qpdf->getFilename() + ", stream object " + og.unparse(' '),
|
||||
offset);
|
||||
auto descr = std::make_shared<std::string>(
|
||||
qpdf->getFilename() + ", stream object " + og.unparse(' '));
|
||||
setDescription(qpdf, descr, offset);
|
||||
}
|
||||
|
||||
std::shared_ptr<QPDFObject>
|
||||
@ -284,7 +283,7 @@ QPDF_Stream::getStreamJSON(
|
||||
|
||||
void
|
||||
QPDF_Stream::setDescription(
|
||||
QPDF* qpdf, std::string const& description, qpdf_offset_t offset)
|
||||
QPDF* qpdf, std::shared_ptr<std::string>& description, qpdf_offset_t offset)
|
||||
{
|
||||
this->QPDFValue::setDescription(qpdf, description, offset);
|
||||
setDictDescription();
|
||||
|
@ -70,7 +70,9 @@ class QPDFObject
|
||||
}
|
||||
void
|
||||
setDescription(
|
||||
QPDF* qpdf, std::string const& description, qpdf_offset_t offset = -1)
|
||||
QPDF* qpdf,
|
||||
std::shared_ptr<std::string>& description,
|
||||
qpdf_offset_t offset = -1)
|
||||
{
|
||||
return value->setDescription(qpdf, description, offset);
|
||||
}
|
||||
|
@ -40,7 +40,6 @@ class QPDFParser
|
||||
void warn(qpdf_offset_t offset, std::string const& msg) const;
|
||||
void warn(std::string const& msg) const;
|
||||
static void warn(QPDF*, QPDFExc const&);
|
||||
|
||||
void setDescription(
|
||||
QPDFObjectHandle oh,
|
||||
qpdf_offset_t descr_offset,
|
||||
|
@ -25,7 +25,9 @@ class QPDFValue
|
||||
virtual JSON getJSON(int json_version) = 0;
|
||||
virtual void
|
||||
setDescription(
|
||||
QPDF* qpdf_p, std::string const& description, qpdf_offset_t offset)
|
||||
QPDF* qpdf_p,
|
||||
std::shared_ptr<std::string>& description,
|
||||
qpdf_offset_t offset)
|
||||
{
|
||||
qpdf = qpdf_p;
|
||||
object_description = description;
|
||||
@ -34,8 +36,9 @@ class QPDFValue
|
||||
void
|
||||
setDefaultDescription(QPDF* a_qpdf, QPDFObjGen const& a_og)
|
||||
{
|
||||
if (object_description.empty()) {
|
||||
object_description = "object " + a_og.unparse(' ');
|
||||
if (!object_description) {
|
||||
object_description =
|
||||
std::make_shared<std::string>("object " + a_og.unparse(' '));
|
||||
}
|
||||
qpdf = a_qpdf;
|
||||
og = a_og;
|
||||
@ -44,13 +47,14 @@ class QPDFValue
|
||||
getDescription(QPDF*& qpdf_p, std::string& description)
|
||||
{
|
||||
qpdf_p = qpdf;
|
||||
description = object_description;
|
||||
description = object_description ? *object_description : "";
|
||||
return qpdf != nullptr;
|
||||
}
|
||||
bool
|
||||
hasDescription()
|
||||
{
|
||||
return qpdf != nullptr && !object_description.empty();
|
||||
return qpdf != nullptr && object_description &&
|
||||
!object_description->empty();
|
||||
}
|
||||
void
|
||||
setParsedOffset(qpdf_offset_t offset)
|
||||
@ -109,7 +113,7 @@ class QPDFValue
|
||||
private:
|
||||
QPDFValue(QPDFValue const&) = delete;
|
||||
QPDFValue& operator=(QPDFValue const&) = delete;
|
||||
std::string object_description;
|
||||
std::shared_ptr<std::string> object_description;
|
||||
|
||||
const qpdf_object_type_e type_code{::ot_uninitialized};
|
||||
char const* type_name{"uninitialized"};
|
||||
|
@ -26,8 +26,8 @@ class QPDF_Stream: public QPDFValue
|
||||
virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
|
||||
virtual std::string unparse();
|
||||
virtual JSON getJSON(int json_version);
|
||||
virtual void
|
||||
setDescription(QPDF*, std::string const&, qpdf_offset_t offset);
|
||||
virtual void setDescription(
|
||||
QPDF*, std::shared_ptr<std::string>& description, qpdf_offset_t offset);
|
||||
virtual void disconnect();
|
||||
QPDFObjectHandle getDict() const;
|
||||
bool isDataModified() const;
|
||||
|
Loading…
Reference in New Issue
Block a user