[Insight-users] BCB5 and itk - please help
John Biddiscombe
john.biddiscombe@mirada-solutions.com
Wed, 19 Feb 2003 11:30:21 -0000
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
6.0.6249.1">
<TITLE>[Insight-users] BCB5 and itk - please help</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT FACE=3D"Times New Roman">Dean<BR>
<BR>
Does it still crash if you do this...<BR>
filter =3D FilterType::New();<BR>
filter->Unregister();<BR>
filter =3D NULL;<BR>
<BR>
ie explicitly delete the filter and set the pointer to null before =
exit.<BR>
<BR>
JB<BR>
<BR>
----- Original Message -----<BR>
From: <<U></U></FONT><U><FONT COLOR=3D"#0000FF" FACE=3D"Times New =
Roman">dean.inglis@on.aibn.com <<A =
HREF=3D"mailto:dean.inglis@on.aibn.com">mailto:dean.inglis@on.aibn.com</A=
>></FONT></U><FONT FACE=3D"Times New Roman">><BR>
To: <</FONT><U><FONT COLOR=3D"#0000FF" FACE=3D"Times New =
Roman">insight-users@public.kitware.com <<A =
HREF=3D"mailto:insight-users@public.kitware.com">mailto:insight-users@pub=
lic.kitware.com</A>></FONT></U><FONT FACE=3D"Times New =
Roman">><BR>
Sent: Tuesday, February 18, 2003 3:08 PM<BR>
Subject: [Insight-users] BCB5 and itk - please help<BR>
<BR>
<BR>
> Ok, last ditch appeal for help. Here is the call stack for<BR>
> simple Borland C++ Builder GUI app that instantiates an itk<BR>
> object (BinomialBlurImageFilter) in the form's constructor.<BR>
> On exiting the app, it appears that the itk object proceeds<BR>
> through its destruction sequence, but after the form that<BR>
> owns it is destroyed, thereby resulting in memory access<BR>
> violation:<BR>
><BR>
><BR>
> 77F85C41 ntdll.dll<BR>
> 77F85BD1 ntdll.dll<BR>
> 004279FD itk::TimeStamp::Modified<BR>
> 004215A9 itk::Object::Modified<BR>
> 0041CF8D itk::DataObject::Initialize<BR>
> 00425097 itk::ProcessObject::~ProcessObject<BR>
> 004055E7 itk::ImageSource<itk::Image<float, 2><BR>
>::~ImageSource<itk::Image<float, 2> =
>(this=3D:01044E54)<BR>
> 00408E33 itk::ImageToImageFilter<itk::Image<float, 2>, =
itk::Image<float,<BR>
2> >::~ImageToImageFilter<itk::Image<float, 2>, =
itk::Image<float, 2><BR>
>(this=3D:01044E54)<BR>
> 004054CB itk::BinomialBlurImageFilter<itk::Image<float, =
2>,<BR>
itk::Image<float, 2> =
>::~BinomialBlurImageFilter<itk::Image<float, 2>,<BR>
itk::Image<float, 2> >(this=3D:01044E54)<BR>
> 0041F4AE itk::LightObject::UnRegister<BR>
> 00421B85 itk::Object::UnRegister<BR>
> 004036D5 =
itk::SmartPointer<itk::BinomialBlurImageFilter<itk::Image<float,=
<BR>
2>, itk::Image<float, 2> > =
>::UnRegister(this=3D:01042FC0)<BR>
> 00403644 =
itk::SmartPointer<itk::BinomialBlurImageFilter<itk::Image<float,=
<BR>
2>, itk::Image<float, 2> ><BR>
>::~SmartPointer<itk::BinomialBlurImageFilter<itk::Image<floa=
t, 2>,<BR>
itk::Image<float, 2> > >(this=3D:01042FC0)<BR>
> 0040386E TForm1::~TForm1(this=3D:01042CEC)<BR>
> 0045BD31 Classes::TComponent::DestroyComponents<BR>
> 0047EB3B __init_exit_proc<BR>
> 0047EB8A __cleanup<BR>
> 0047DE4C _exit<BR>
> 0047ED60 __startup<BR>
><BR>
> Here is what happens if the filter is initialized with =
->DebugOn() :<BR>
><BR>
> 77F85C41 ntdll.dll<BR>
> 77F85BD1 ntdll.dll<BR>
> 004279F5 itk::TimeStamp::Modified<BR>
> 004215A1 itk::Object::Modified<BR>
> 00421FA5 itk::Object::Object<BR>
> 004243BE itk::OutputWindow::OutputWindow<BR>
> 00424882 itk::Win32OutputWindow::New<BR>
> 00424778 itk::OutputWindow::GetInstance<BR>
> 004245A0 itk::OutputWindowDisplayDebugText<BR>
> 00421A28 itk::Object::UnRegister<BR>
> 004036CD =
itk::SmartPointer<itk::BinomialBlurImageFilter<itk::Image<float,=
<BR>
2>, itk::Image<float, 2> > =
>::UnRegister(this=3D:01042FC0)<BR>
> 0040363C =
itk::SmartPointer<itk::BinomialBlurImageFilter<itk::Image<float,=
<BR>
2>, itk::Image<float, 2> ><BR>
>::~SmartPointer<itk::BinomialBlurImageFilter<itk::Image<floa=
t, 2>,<BR>
itk::Image<float, 2> > >(this=3D:01042FC0)<BR>
> 00403866 TForm1::~TForm1(this=3D:01042CEC)<BR>
> 0045BD29 Classes::TComponent::DestroyComponents<BR>
> 0047EB33 __init_exit_proc<BR>
> 0047EB82 __cleanup<BR>
> 0047DE44 _exit<BR>
> 0047ED58 __startup<BR>
><BR>
><BR>
> I have enclosed the relevant files for anyone who would like to<BR>
> verify this behaviour. ITK is build with CMake 1.6.4, =
MinSizeRel,<BR>
> Borland compiler on Win 2k, single Pentium 4 processor. I have<BR>
> also posted to the Borland newsgroups but without much success.<BR>
> Any help would be great,<BR>
><BR>
><BR>
> Dean<BR>
><BR>
><BR>
> Here is the form's class definition (itkObjectTest.h):<BR>
><BR>
><BR>
//-----------------------------------------------------------------------=
---<BR>
-<BR>
><BR>
> #ifndef itkObjectTestH<BR>
> #define itkObjectTestH<BR>
><BR>
//-----------------------------------------------------------------------=
---<BR>
-<BR>
> #include <Classes.hpp><BR>
> #include <Controls.hpp><BR>
> #include <StdCtrls.hpp><BR>
> #include <Forms.hpp><BR>
><BR>
> #include "itkImage.h"<BR>
> #include "itkBinomialBlurImageFilter.h"<BR>
><BR>
><BR>
//-----------------------------------------------------------------------=
---<BR>
-<BR>
> class TForm1 : public TForm<BR>
> {<BR>
> __published: // IDE-managed Components<BR>
> TLabel *Label1;<BR>
> private: // User declarations<BR>
> public: // User declarations<BR>
> __fastcall TForm1(TComponent* Owner);<BR>
> __fastcall ~TForm1();<BR>
><BR>
> typedef itk::Image<float, 2> ImageType;<BR>
> typedef itk::BinomialBlurImageFilter< ImageType, ImageType =
><BR>
FilterType;<BR>
> FilterType::Pointer filter;<BR>
><BR>
> };<BR>
><BR>
//-----------------------------------------------------------------------=
---<BR>
-<BR>
> extern PACKAGE TForm1 *Form1;<BR>
><BR>
//-----------------------------------------------------------------------=
---<BR>
-<BR>
> #endif<BR>
><BR>
><BR>
> Here is the implementation (itkObjectTest.cpp):<BR>
><BR>
><BR>
//-----------------------------------------------------------------------=
---<BR>
-<BR>
><BR>
> #include <vcl.h><BR>
> #pragma hdrstop<BR>
><BR>
> #include "itkObjectTest.h"<BR>
><BR>
//-----------------------------------------------------------------------=
---<BR>
-<BR>
> #pragma package(smart_init)<BR>
> #pragma resource "*.dfm"<BR>
> TForm1 *Form1;<BR>
><BR>
//-----------------------------------------------------------------------=
---<BR>
-<BR>
> __fastcall TForm1::TForm1(TComponent* Owner)<BR>
> : TForm(Owner)<BR>
> {<BR>
> filter =3D FilterType::New();<BR>
> }<BR>
><BR>
//-----------------------------------------------------------------------=
---<BR>
-<BR>
> __fastcall TForm1::~TForm1()<BR>
> {<BR>
> return;<BR>
> }<BR>
><BR>
><BR>
> Here is the form's GUI element description (itkObjectTest.dfm):<BR>
><BR>
> object Form1: TForm1<BR>
> Left =3D 197<BR>
> Top =3D 304<BR>
> Width =3D 279<BR>
> Height =3D 181<BR>
> Caption =3D 'Form1'<BR>
> Color =3D clBtnFace<BR>
> Font.Charset =3D DEFAULT_CHARSET<BR>
> Font.Color =3D clWindowText<BR>
> Font.Height =3D -11<BR>
> Font.Name =3D 'MS Sans Serif'<BR>
> Font.Style =3D []<BR>
> OldCreateOrder =3D False<BR>
> PixelsPerInch =3D 96<BR>
> TextHeight =3D 13<BR>
> object Label1: TLabel<BR>
> Left =3D 80<BR>
> Top =3D 48<BR>
> Width =3D 100<BR>
> Height =3D 32<BR>
> Caption =3D 'ITK Test'<BR>
> Font.Charset =3D DEFAULT_CHARSET<BR>
> Font.Color =3D clWindowText<BR>
> Font.Height =3D -27<BR>
> Font.Name =3D 'MS Sans Serif'<BR>
> Font.Style =3D []<BR>
> ParentFont =3D False<BR>
> end<BR>
> end<BR>
><BR>
><BR>
><BR>
> Here is the application implementation (itkObjTestPrj.cpp):<BR>
><BR>
><BR>
//-----------------------------------------------------------------------=
---<BR>
-<BR>
><BR>
> #include <vcl.h><BR>
> #pragma hdrstop<BR>
> USERES("itkObjTestPrj.res");<BR>
> USEFORM("itkObjectTest.cpp", Form1);<BR>
> USELIB("..\..\Backup\VXLNumerics.lib");<BR>
> USELIB("..\..\Backup\ITKBasicFilters.lib");<BR>
> USELIB("..\..\Backup\ITKCommon.lib");<BR>
> USELIB("..\..\Backup\ITKAlgorithms.lib");<BR>
><BR>
//-----------------------------------------------------------------------=
---<BR>
-<BR>
> WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)<BR>
> {<BR>
> try<BR>
> {<BR>
> Application->Initialize();<BR>
> Application->CreateForm(__classid(TForm1), &Form1);<BR>
> Application->Run();<BR>
> }<BR>
> catch (Exception &exception)<BR>
> {<BR>
> Application->ShowException(&exception);<BR>
> }<BR>
> return 0;<BR>
> }<BR>
><BR>
//-----------------------------------------------------------------------=
---<BR>
-<BR>
><BR>
> _______________________________________________<BR>
> Insight-users mailing list<BR>
></FONT><U> <FONT COLOR=3D"#0000FF" FACE=3D"Times New =
Roman">Insight-users@public.kitware.com <<A =
HREF=3D"mailto:Insight-users@public.kitware.com">mailto:Insight-users@pub=
lic.kitware.com</A>></FONT></U><BR>
<FONT FACE=3D"Times New Roman">></FONT><U> <FONT COLOR=3D"#0000FF" =
FACE=3D"Times New Roman"><<A =
HREF=3D"http://public.kitware.com/mailman/listinfo/insight-users">http://=
public.kitware.com/mailman/listinfo/insight-users</A>></FONT></U><BR>
</P>
</BODY>
</HTML>