[Insight-users] destruction of itk objects

dean.inglis@on.aibn.com dean.inglis@on.aibn.com
Thu, 13 Feb 2003 16:20:42 -0500


Hi John,

I'll try one more symptomtic approach: 
I moved the template declaration out of the body
of the form's class definition and put it directly in the constructor:

typedef itk::Image<float, 2> ImageType;
typedef itk::VTKImageImport<ImageType> ImageImportType;
ImageImportType::Pointer itkImporter;
itkImporter = ImageImportType::New();
itkImporter->Register();
itkImporter->DebugOn();
itkImporter->SetGlobalWarningDisplay(true);

The importer exists to do its job, even
when other non-templated objects connected to it 
(as observers) use it out of the scope of the
constructor. The good news is that the object
destroys itself quietly in this case without raising any exceptions: normal program termination.
The only problem is that without a name declaration in the body of the form's class, I cannot directly
invoke any of the importer's methods out of the
scope of the constructor.

Do you have any idea as to why 'auto' destruction works in this case (that uses reference counting)?

I have tried increasing the reference count of the
importer in the form's constructor before (with
class body declaration of the
ImageImportType::Pointer itkImporter) but this does
not work either: in the form's destructor, there is
always a problem. Is there a compiler switch that I
am missing?

Dean

> is the itkImporter trying to delete it's "pointer to whatever image it
> thinks it owns"? Just Guessing right now, (can you not step into the ikt
> code?) - I'll have a think later...
> 
> JB
> I'm sure someone like Luis will answer you with the correct explanation
> before I get a change to ponder it