Use forward declaration for Exiv2::Image, port to std::unique_ptr
ClosedPublic

Authored by bruns on Dec 30 2018, 3:00 PM.

Details

Summary

Instead of the Exiv2::Image::AutoPtr typedef just use a forward declaration
for Exiv2::Image, and use std::unique_ptr instead of std::auto_ptr.

The forward declaration avoids pulling in Exiv2 declarations everywhere,
e.g. via document.h.

Although it would be possible to use std::auto_ptr, unique_ptr is
preferable for two reasons:

  • ownership transfer is explicit (std::move, release()/reset())
  • Exiv2 0.28 will use std::unique_ptr as well, i.e. the code is forward

compatible.

Diff Detail

Repository
R260 Gwenview
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
bruns created this revision.Dec 30 2018, 3:00 PM
Restricted Application added a project: Gwenview. · View Herald TranscriptDec 30 2018, 3:00 PM
bruns requested review of this revision.Dec 30 2018, 3:00 PM

Why is that hpp in the header?

Still failed to build with the following error, which is why I had to enable exceptions in my patch to make it work:

In file included from /usr/include/exiv2/types.hpp:34,
                 from /usr/include/exiv2/datasets.hpp:31,
                 from /usr/include/exiv2/exiv2.hpp:33,
                 from /var/tmp/portage/kde-apps/gwenview-18.12.0/work/gwenview-18.12.0/lib/cms/cmsprofile.cpp:46:
/usr/include/exiv2/slice.hpp: In constructor ‘Exiv2::Internal::SliceBase::SliceBase(size_t, size_t)’:
/usr/include/exiv2/slice.hpp:99:77: error: exception handling disabled, use -fexceptions to enable
                     throw std::out_of_range("Begin must be smaller than end");
                                                                             ^
bruns added a comment.Dec 30 2018, 3:11 PM

Why is that hpp in the header?

Hm?

bruns added a comment.Dec 30 2018, 3:11 PM

Still failed to build with the following error, which is why I had to enable exceptions in my patch to make it work:

In file included from /usr/include/exiv2/types.hpp:34,
                 from /usr/include/exiv2/datasets.hpp:31,
                 from /usr/include/exiv2/exiv2.hpp:33,
                 from /var/tmp/portage/kde-apps/gwenview-18.12.0/work/gwenview-18.12.0/lib/cms/cmsprofile.cpp:46:
/usr/include/exiv2/slice.hpp: In constructor ‘Exiv2::Internal::SliceBase::SliceBase(size_t, size_t)’:
/usr/include/exiv2/slice.hpp:99:77: error: exception handling disabled, use -fexceptions to enable
                     throw std::out_of_range("Begin must be smaller than end");
                                                                             ^

See D17873

See D17873

Yes, build finished just fine seconds ago. :)

bruns updated this revision to Diff 48406.Dec 30 2018, 4:02 PM

fix test build

ngraham added a subscriber: ngraham.
ngraham added inline comments.
lib/cms/cmsprofile.h
37

Indentation

pino removed a reviewer: pino.Jan 1 2019, 2:59 AM
bruns added a subscriber: lbeltrame.Jan 1 2019, 1:50 PM
bruns updated this revision to Diff 48476.Jan 1 2019, 2:35 PM

fix indentation

bruns marked an inline comment as done.Jan 1 2019, 2:37 PM
ngraham accepted this revision.Jan 1 2019, 11:16 PM
This revision is now accepted and ready to land.Jan 1 2019, 11:16 PM
This revision was automatically updated to reflect the committed changes.