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
This commit is contained in:
Syping 2023-01-08 18:18:28 +01:00
parent a704ee046a
commit 96eae4f957

View file

@ -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;