From 71c82701b2ae71184224343b6360e3c7b63b39b9 Mon Sep 17 00:00:00 2001 From: Tobias Weihs Date: Wed, 10 Feb 2021 12:10:13 +0100 Subject: [PATCH] #419 do not delete a shallow copied frame, only delete if necessary --- libsrc/ImageSEGConverter.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libsrc/ImageSEGConverter.cpp b/libsrc/ImageSEGConverter.cpp index 5e4005a2..3f8e8bcb 100644 --- a/libsrc/ImageSEGConverter.cpp +++ b/libsrc/ImageSEGConverter.cpp @@ -563,7 +563,7 @@ namespace dcmqi { // ImagePositionPatient, set non-zero pixels to the segment number. Notify // about pixels that are initialized more than once. - DcmIODTypes::Frame *unpackedFrame = NULL; + const DcmIODTypes::Frame *unpackedFrame = NULL; JSONSegmentationMetaInformationHandler metaInfo; @@ -735,12 +735,15 @@ namespace dcmqi { unsigned slice = frameOriginIndex[2]; + bool deleteFrame(true); if(segdoc->getSegmentationType() == DcmSegTypes::ST_BINARY) unpackedFrame = DcmSegUtils::unpackBinaryFrame(frame, imageSize[1], // Rows imageSize[0]); // Cols - else - unpackedFrame = new DcmIODTypes::Frame(*frame); + else { + unpackedFrame = frame; + deleteFrame = false; + } // initialize slice with the frame content for(unsigned row=0;row