[vtkusers] R: Migration problem vtk 5.8 - vtk 6.1

Lorenzo Cesario lorenzo.cesario at softeco.it
Fri Jul 11 03:59:32 EDT 2014


Hi Marcus,
great news I fixed it! :)
I moved the initVtkObjFactory.h from my .dll to my executable project as I 
already told you, but instead of calling it using the preprocessor 
properties (in this way the ::New() inside my .dll returns always NULL), I 
included that file in the "stdafx.h" of the .exe project.
In this way it doesn't crash anymore and I can use without problems the vtk 
objects in my dll.
The reason because I didn't use untile now the vtk init in my .exe project 
was that I didn't want to include vtk libraries dependencies in this 
project, but only in the project (dll) that uses them. In this way, a user 
is quite "forced" to add vtk dependencies in the .exe project even if it 
doesn't really need them.
However, tks a lot for your support.

Regards,
Lorenzo

-----Messaggio originale----- 
From: Marcus D. Hanwell
Sent: Thursday, July 10, 2014 4:31 PM
To: Lorenzo Cesario
Cc: VTK Users
Subject: Re: [vtkusers] R: Migration problem vtk 5.8 - vtk 6.1

Lorenzo,

Apologies, really busy right now. Why don't you think you can use the
object factory in Display3d.dll if you move the init to the .exe? The
intended use of the macro was to be compiled into the application
executable, the object factory initialization is process wide we just
need the object factories to be initialized before any objects are
created in a given process.

I will try to find some time to look at why it is failing in the dll
init method, but I would advise you to initialize the object factories
from the executable code if you possibly can.

Marcus

On Thu, Jul 10, 2014 at 7:59 AM, Lorenzo Cesario
<lorenzo.cesario at softeco.it> wrote:
> Hi Marcus,
> I modified the code I gave you last time, moving the call to the file
> initVtkObjFactory.h from the Display3d.dll to the .exe project.
> In this case it doesn't crash anymore, but I can't use the object factory 
> in
> the Display3d.dll.
> Is this information of help?
>
> Bye,
>
> Lorenzo
>
>
> -----Messaggio originale----- From: Lorenzo Cesario
> Sent: Thursday, July 10, 2014 8:54 AM
>
> To: Marcus D. Hanwell
> Cc: VTK Users
> Subject: Re: [vtkusers] R: Migration problem vtk 5.8 - vtk 6.1
>
> Hi Marcus,
> I tried to semplify the code I sent in my last mail.
> Now the class exported by my .dll doesn't do anything. I left only the 
> "auto
> init" of the modules inside the file initVtkObjFactory.h.
> Now it gives memory leaks in all the debug architectures, but still 
> crashes
> only in Release x64 when I close the application.
> I hope this example code can be clear for you.
> Tks,
> Lorenzo
>
>
> -----Messaggio originale----- From: Lorenzo Cesario
> Sent: Monday, July 07, 2014 4:33 PM
> To: Marcus D. Hanwell
> Cc: VTK Users
> Subject: Re: [vtkusers] R: Migration problem vtk 5.8 - vtk 6.1
>
>
> Hi Marcus,
> please find attached a simple test project I made extracting and 
> simplifying
> as much as I could my original software application.
> Inside the file Test_VtkMFC.zip there is a README.txt file explaining how 
> to
> build and reproduce the bug.
> It is a templated MFC-based application from VS2010 (single doc and Office
> 2007 Ribbon style).
> Let me know if it crashes in Release 64 bit and if you can see where it is
> the problem (e.g. in one of my project settings).
> Tks,
>
> Lorenzo
>
> -----Messaggio originale----- From: Marcus D. Hanwell
> Sent: Thursday, July 03, 2014 5:27 PM
> To: Lorenzo Cesario
> Cc: markus.hanwell at kitware.com ; VTK Users
> Subject: Re: [vtkusers] R: Migration problem vtk 5.8 - vtk 6.1
>
> Hi Lorenzo,
>
> On Thu, Jul 3, 2014 at 7:40 AM, Lorenzo Cesario
> <lorenzo.cesario at softeco.it> wrote:
>>
>>
>> Anyway, I think that the problem is that I could fix it (although not in
>> all
>> the configurations/architecture) calling the
>> vtkObjectFactory::UnRegisterAllFactories(); that it should be done by 
>> “vtk
>> itself”.
>
>
> To be totally clear I agree, I still need a minimal example I can
> reproduce in order to fix it.
>>
>>
>> My application is a single-document MFC executable, that uses for the
>> visualization in its main CWnd another dll including vtk libraries.
>>
>> As I think it isn’t correct to call that method, could be a bug in vtk? 
>> or
>> in any properties of my visual studio projects?
>>
> Yes, and figuring out which one is the challenge. If you try removing
> the init from the Visual Studio properties, and simply include it in
> your application code does this help? I have not seen this method of
> injecting code, it should work but I am not aware of others using it.
> I never work with Visual Studio projects without using CMake to
> generate them, but the object factory code is pretty robust.
>
> To be clear this is not expected behavior, but it is unclear to me if
> it is an issue with your Visual Studio build files or in VTK's C++
> code.
>
> Marcus
>
>





More information about the vtkusers mailing list