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 | 1494 | // disconnected(). |
| 1495 | 1495 | class DisconnectAccess |
| 1496 | 1496 | { |
| 1497 | - friend class QPDF_Array; | |
| 1498 | 1497 | friend class QPDF_Dictionary; |
| 1499 | 1498 | friend class QPDF_Stream; |
| 1500 | - friend class SparseOHArray; | |
| 1501 | 1499 | |
| 1502 | 1500 | private: |
| 1503 | 1501 | static void | ... | ... |
libqpdf/QPDF_Array.cc
| ... | ... | @@ -116,11 +116,16 @@ void |
| 116 | 116 | QPDF_Array::disconnect() |
| 117 | 117 | { |
| 118 | 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 | 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