From 96eae4f95736b273db47c87bcdb367d599dbbee1 Mon Sep 17 00:00:00 2001 From: Syping Date: Sun, 8 Jan 2023 18:18:28 +0100 Subject: [PATCH] change setData() attitude with the internal data object - when takeOwnership is false, instead of deleting the old object and generating a new object from scratch, it clears now the old object --- src/RagePhoto.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/RagePhoto.cpp b/src/RagePhoto.cpp index ea94721..90a982e 100644 --- a/src/RagePhoto.cpp +++ b/src/RagePhoto.cpp @@ -939,18 +939,18 @@ inline void RagePhoto::setBufferOffsets(RagePhotoData *ragePhotoData) bool RagePhoto::setData(RagePhotoData *ragePhotoData, bool takeOwnership) { - std::free(m_data->jpeg); - std::free(m_data->description); - std::free(m_data->json); - std::free(m_data->header); - std::free(m_data->title); - delete m_data; - if (takeOwnership) { + std::free(m_data->jpeg); + std::free(m_data->description); + std::free(m_data->json); + std::free(m_data->header); + std::free(m_data->title); + delete m_data; + m_data = ragePhotoData; } else { - m_data = new RagePhotoData { 0 }; + clear(); m_data->photoFormat = ragePhotoData->photoFormat;