[Insight-users] ImportImageFilter segfault
Miklos Espak
espakm at gmail.com
Wed Jun 30 03:09:47 EDT 2010
Hi,
I created a filter for reading certain kind of images. It extends
ImportImageFilter. It imports the image well, but I can use the output
image as long as the importer is alive.
The buffer with the raw image is set by the SetImportPointer member
function. Its last bool argument decides if the filter is responsible
for deallocating the buffer when it dies or not. If I set it to true,
its destructor frees the buffer and accessing the pixels of the output
image causes segfault. If it's false, I get memory leak. (I don't have
a pointer to the buffer from outside of the filter itself.)
I find this behaviour unusual. E.g. the output of an ImageFileReader
can be used freely even the reader dies, and I guess this is the case
with other input filters as well.
Is there a way to delegate the responsibility of freeing the buffer to
the output image? Is it intentional that this is not the default
behaviour of ImportImageFilter?
I attached a code that demonstrates the problem. Sorry for cppunit.
Thanks,
Miklos
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ImportFilterTest.cpp
Type: application/octet-stream
Size: 4848 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100630/ff3fb2b2/attachment.obj>
More information about the Insight-users
mailing list