Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use std::move to transfer ownership of DataBufs. #1956

Merged
merged 2 commits into from
Oct 15, 2021

Conversation

kevinbackhouse
Copy link
Collaborator

@kevinbackhouse kevinbackhouse commented Oct 10, 2021

DataBuf had a constructor that was used as a move constructor, but didn't have the correct type. This fixes that and changes the code to use std::move when transferring ownership of a DataBuf.

I also removed DataBufRef, because it is no longer used.

Everything here should be behavior preserving, except for the change that I made to this code in image.cpp:

exiv2/src/image.cpp

Lines 593 to 595 in 4901c5d

if (checkMode(mdIccProfile) & amWrite && iccProfile()) {
setIccProfile(*iccProfile());
}

That looks like a bug to me because it's not copying the icc profile from image unlike all the copy operations in that function. Also, the condition && iccProfile() could never fail, because iccProfile returned a pointer to the iccProfile_ field, so it could never be null. So I've changed that code to something that I think makes more sense. Unfortunately, we don't have any test coverage for it, so I don't know if I have broken anything with that change.

@codecov
Copy link

codecov bot commented Oct 10, 2021

Codecov Report

Merging #1956 (94ea0c6) into main (4901c5d) will increase coverage by 0.00%.
The diff coverage is 78.72%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1956   +/-   ##
=======================================
  Coverage   61.12%   61.12%           
=======================================
  Files          96       96           
  Lines       19055    19054    -1     
  Branches     9743     9732   -11     
=======================================
  Hits        11647    11647           
- Misses       5092     5094    +2     
+ Partials     2316     2313    -3     
Impacted Files Coverage Δ
include/exiv2/types.hpp 70.58% <ø> (+1.14%) ⬆️
src/actions.hpp 100.00% <ø> (ø)
src/crwimage_int.hpp 84.61% <ø> (ø)
src/bmffimage.cpp 71.42% <50.00%> (ø)
src/image.cpp 65.09% <50.00%> (ø)
src/tiffvisitor_int.cpp 76.23% <50.00%> (ø)
src/actions.cpp 61.13% <57.14%> (ø)
src/types.cpp 87.98% <84.61%> (-0.46%) ⬇️
src/crwimage_int.cpp 74.07% <91.66%> (ø)
include/exiv2/image.hpp 100.00% <100.00%> (ø)
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4901c5d...94ea0c6. Read the comment docs.

@neheb
Copy link
Collaborator

neheb commented Oct 11, 2021

No copy assignment operator is defined. I would define it as deleted l.

DataBuf& operator=(DataBuf&& rhs);

// No copy assignment.
DataBuf& operator=(const DataBuf&) = delete;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neheb: is this what you mean?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neheb: If you're happy, please could you approve this PR so that I can merge it? Thanks!

@kevinbackhouse kevinbackhouse merged commit aaf5843 into Exiv2:main Oct 15, 2021
@kevinbackhouse kevinbackhouse added this to the v1.00 milestone Dec 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants