From 8ba9003f1978ad7bb500bac0a199fb5d73f07366 Mon Sep 17 00:00:00 2001 From: Kevin Backhouse Date: Sat, 30 Jul 2022 12:16:28 -0400 Subject: [PATCH] Fix clang-tidy warning about double move. --- src/tiffcomposite_int.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/tiffcomposite_int.cpp b/src/tiffcomposite_int.cpp index 1bbb2fd0..2e1e9db4 100644 --- a/src/tiffcomposite_int.cpp +++ b/src/tiffcomposite_int.cpp @@ -474,8 +474,11 @@ TiffComponent* TiffDirectory::doAddPath(uint16_t tag, TiffPath& tiffPath, TiffCo return tc->addPath(tag, tiffPath, pRoot, std::move(object)); auto atc = [&] { - if (tiffPath.size() == 1 && object) - return std::move(object); + if (tiffPath.size() == 1 && object) { + TiffComponent::UniquePtr tempObject; + std::swap(object, tempObject); + return tempObject; + } return TiffCreator::create(tpi.extendedTag(), tpi.group()); }(); @@ -508,8 +511,11 @@ TiffComponent* TiffSubIfd::doAddPath(uint16_t tag, TiffPath& tiffPath, TiffCompo return (*it)->addPath(tag, tiffPath, pRoot, std::move(object)); auto tc = [&] { - if (tiffPath.size() == 1 && object) - return addChild(std::move(object)); + if (tiffPath.size() == 1 && object) { + TiffComponent::UniquePtr tempObject; + std::swap(object, tempObject); + return addChild(std::move(tempObject)); + } return addChild(std::make_unique(tpi1.tag(), tpi2.group())); }(); setCount(ifds_.size()); @@ -562,8 +568,11 @@ TiffComponent* TiffBinaryArray::doAddPath(uint16_t tag, TiffPath& tiffPath, Tiff return (*it)->addPath(tag, tiffPath, pRoot, std::move(object)); auto atc = [&] { - if (tiffPath.size() == 1 && object) - return std::move(object); + if (tiffPath.size() == 1 && object) { + TiffComponent::UniquePtr tempObject; + std::swap(object, tempObject); + return tempObject; + } return TiffCreator::create(tpi.extendedTag(), tpi.group()); }(); auto tc = addChild(std::move(atc));