Commit d7b85252356da91293d9c11428a5a1c797c5dd0d
Committed by
Jay Berkenbilt
1 parent
0289b21c
Refactor QPDFObjectHandle::unsafeShallowCopy
Showing
2 changed files
with
4 additions
and
14 deletions
include/qpdf/QPDFObjectHandle.hh
| @@ -1634,7 +1634,6 @@ class QPDFObjectHandle | @@ -1634,7 +1634,6 @@ class QPDFObjectHandle | ||
| 1634 | bool first_level_only, | 1634 | bool first_level_only, |
| 1635 | bool stop_at_streams); | 1635 | bool stop_at_streams); |
| 1636 | void shallowCopyInternal1(QPDFObjectHandle& oh, bool first_level_only); | 1636 | void shallowCopyInternal1(QPDFObjectHandle& oh, bool first_level_only); |
| 1637 | - void shallowCopyInternal2(QPDFObjectHandle& oh); | ||
| 1638 | void copyObject( | 1637 | void copyObject( |
| 1639 | std::set<QPDFObjGen>& visited, | 1638 | std::set<QPDFObjGen>& visited, |
| 1640 | bool cross_indirect, | 1639 | bool cross_indirect, |
libqpdf/QPDFObjectHandle.cc
| @@ -2298,20 +2298,11 @@ QPDFObjectHandle::copyObject1( | @@ -2298,20 +2298,11 @@ QPDFObjectHandle::copyObject1( | ||
| 2298 | QPDFObjectHandle | 2298 | QPDFObjectHandle |
| 2299 | QPDFObjectHandle::unsafeShallowCopy() | 2299 | QPDFObjectHandle::unsafeShallowCopy() |
| 2300 | { | 2300 | { |
| 2301 | - QPDFObjectHandle result; | ||
| 2302 | - shallowCopyInternal2(result); | ||
| 2303 | - return result; | ||
| 2304 | -} | ||
| 2305 | - | ||
| 2306 | -void | ||
| 2307 | -QPDFObjectHandle::shallowCopyInternal2(QPDFObjectHandle& new_obj) | ||
| 2308 | -{ | ||
| 2309 | - assertInitialized(); | ||
| 2310 | - | ||
| 2311 | - if (isStream()) { | ||
| 2312 | - throw std::runtime_error("attempt to make a shallow copy of a stream"); | 2301 | + if (!dereference()) { |
| 2302 | + throw std::logic_error("operation attempted on uninitialized " | ||
| 2303 | + "QPDFObjectHandle"); | ||
| 2313 | } | 2304 | } |
| 2314 | - new_obj = QPDFObjectHandle(obj->copy(true)); | 2305 | + return QPDFObjectHandle(obj->copy(true)); |
| 2315 | } | 2306 | } |
| 2316 | 2307 | ||
| 2317 | void | 2308 | void |