[Insight-users] itk smart pointer

Luis Ibanez luis.ibanez at kitware.com
Sat Dec 10 10:24:52 EST 2005


Hi Xiahai,

There shouldn't be any problem with mixing SmartPointers
and the std::ifstream classes. There is something particular
happening with your code.

A common mistake is to create ITK objects with the New()
operator, and to assign them to normal raw pointers instead
of SmartPointer.  Please make sure that you create the object
as

     myObjectType::Pointer  toto = myObjectType::New();

DON'T DO:

     myObjectType *         toto = myObjectType::New();


In any case, from your short description it is very hard for
us to figure out what is wrong with your code.

Please post a minimal example of compilable code where you can
reproduce the problem that you are experiencing.


  Thanks


     Luis


--------------------------
庄吓海(Xiahai Zhuang) wrote:
> Hello all
>    when I new a C++ object, call a method which employs std::ifstream to read data from file;
> then when back from that calling , when I use itk::Object::New() or other operation that might
> use smart pointer to new a object, there would be a exception in 
> __cdecl _CrtIsValidHeapPointer(
>         const void * pUserData) // file: dbgheap.c
> 
> when I donot call the method that employs std::ifstream method, it would meet this problem.
> 
> Is that any method to avoid this problem.
> Thanks alot!!
> 
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 
> 



More information about the Insight-users mailing list