Commit a171ebb9427e41559efbeb1f144a19b73bb3eca6
1 parent
0aae54d3
Refactor QPDF_Array::disconnect
Showing
4 changed files
with
9 additions
and
15 deletions
include/qpdf/QPDFObjectHandle.hh
| @@ -1494,10 +1494,8 @@ class QPDFObjectHandle | @@ -1494,10 +1494,8 @@ class QPDFObjectHandle | ||
| 1494 | // disconnected(). | 1494 | // disconnected(). |
| 1495 | class DisconnectAccess | 1495 | class DisconnectAccess |
| 1496 | { | 1496 | { |
| 1497 | - friend class QPDF_Array; | ||
| 1498 | friend class QPDF_Dictionary; | 1497 | friend class QPDF_Dictionary; |
| 1499 | friend class QPDF_Stream; | 1498 | friend class QPDF_Stream; |
| 1500 | - friend class SparseOHArray; | ||
| 1501 | 1499 | ||
| 1502 | private: | 1500 | private: |
| 1503 | static void | 1501 | static void |
libqpdf/QPDF_Array.cc
| @@ -116,11 +116,16 @@ void | @@ -116,11 +116,16 @@ void | ||
| 116 | QPDF_Array::disconnect() | 116 | QPDF_Array::disconnect() |
| 117 | { | 117 | { |
| 118 | if (sparse) { | 118 | if (sparse) { |
| 119 | - sp_elements.disconnect(); | 119 | + for (auto& item: sp_elements.elements) { |
| 120 | + auto& obj = item.second; | ||
| 121 | + if (!obj->getObjGen().isIndirect()) { | ||
| 122 | + obj->disconnect(); | ||
| 123 | + } | ||
| 124 | + } | ||
| 120 | } else { | 125 | } else { |
| 121 | - for (auto const& iter: elements) { | ||
| 122 | - if (iter) { | ||
| 123 | - QPDFObjectHandle::DisconnectAccess::disconnect(iter); | 126 | + for (auto& obj: elements) { |
| 127 | + if (!obj->getObjGen().isIndirect()) { | ||
| 128 | + obj->disconnect(); | ||
| 124 | } | 129 | } |
| 125 | } | 130 | } |
| 126 | } | 131 | } |
libqpdf/SparseOHArray.cc
| 1 | #include <qpdf/SparseOHArray.hh> | 1 | #include <qpdf/SparseOHArray.hh> |
| 2 | 2 | ||
| 3 | -void | ||
| 4 | -SparseOHArray::disconnect() | ||
| 5 | -{ | ||
| 6 | - for (auto& iter: this->elements) { | ||
| 7 | - QPDFObjectHandle::DisconnectAccess::disconnect(iter.second); | ||
| 8 | - } | ||
| 9 | -} | ||
| 10 | - | ||
| 11 | SparseOHArray | 3 | SparseOHArray |
| 12 | SparseOHArray::copy() | 4 | SparseOHArray::copy() |
| 13 | { | 5 | { |
libqpdf/qpdf/SparseOHArray.hh