Skip to content
This repository was archived by the owner on Jan 8, 2024. It is now read-only.

Commit d167b33

Browse files
committed
Fix use of smart pointers for Poppler > 0.85.
Fixes: pdf2djvu.cc: In function ‘int get_page_for_goto_link(pdf::link::GoTo*, pdf::Catalog*)’: pdf2djvu.cc:84:60: error: no matching function for call to ‘std::unique_ptr<LinkDest>::reset(std::unique_ptr<LinkDest>)’ /usr/include/c++/8/bits/unique_ptr.h:377:7: note: candidate: ‘void std::unique_ptr<_Tp, _Dp>::reset(std::unique_ptr<_Tp, _Dp>::pointer) [with _Tp = LinkDest; _Dp = std::default_delete<LinkDest>; std::unique_ptr<_Tp, _Dp>::pointer = LinkDest*]’ /usr/include/c++/8/bits/unique_ptr.h:377:7: note: no known conversion for argument 1 from ‘std::unique_ptr<LinkDest>’ to ‘std::unique_ptr<LinkDest>::pointer’ {aka ‘LinkDest*’}
1 parent fffd48c commit d167b33

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

pdf2djvu.cc

+15-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,20 @@ class NoLinkDestination : public std::runtime_error
7373
{ }
7474
};
7575

76+
// for POPPLER_VERSION < 8600
77+
template <typename T>
78+
void unique_reset(std::unique_ptr<T> &up, T* ptr)
79+
{
80+
up.reset(ptr);
81+
}
82+
83+
// for POPPLER_VERSION >= 8600
84+
template <typename T>
85+
void unique_reset(std::unique_ptr<T> &up, std::unique_ptr<T> ptr)
86+
{
87+
up = std::move(ptr);
88+
}
89+
7690
static int get_page_for_goto_link(pdf::link::GoTo *goto_link, pdf::Catalog *catalog)
7791
{
7892
std::unique_ptr<pdf::link::Destination> dest;
@@ -81,7 +95,7 @@ static int get_page_for_goto_link(pdf::link::GoTo *goto_link, pdf::Catalog *cata
8195
#endif
8296
pdf::link::Destination *orig_dest = goto_link->getDest();
8397
if (orig_dest == nullptr)
84-
dest.reset(catalog->findDest(goto_link->getNamedDest()));
98+
unique_reset(dest, catalog->findDest(goto_link->getNamedDest()));
8599
else
86100
dest.reset(orig_dest->copy());
87101
if (dest.get() != nullptr)

0 commit comments

Comments
 (0)