[vtkusers] Migration problem vtk 5.8 - vtk 6.1
Lorenzo Cesario
lorenzo.cesario at softeco.it
Wed Jul 2 08:05:50 EDT 2014
Hi Marcus,
tks for your answer. Yes, I used the #pragma once directive inside my
InitVtkObjFactory.h, so the file has the following code:
#pragma once
#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkInteractionStyle);
VTK_MODULE_INIT(vtkRenderingFreeType);
VTK_MODULE_INIT(vtkRenderingFreeTypeOpenGL);
VTK_MODULE_INIT(vtkRenderingOpenGL);
Debugging the code, during the factories creation I can see that the
RegisteredFactories object defined in the file vtkObjectFactory.cxx,
contains all the 4 factories. Looking inside the items value of that object
I can see in the debug tooltip that each one is the related "factory"
object. So for the InteractionStyleObjectFactory I can see the class name
and the "mother" class vtkObjectBase.
Instead, during the exit of my appliation, when the UnRegisterAllFactories()
method is called, I can't see anymore this value on the item related to the
vtkInteractionStyleObjectFactory (I see only the vtkObjectBase), while for
the remaining object factories I continue to see the class name.
At last, I fixed this behaviour for the debug 64bit version of my
application calling the static method
vtkObjectFactory::UnRegisterAllFactories(); just before calling the
FreeLibrary of my dll. In this way, when this method is called by the
vtkClenaupObjectFactory, the RegisteredFactories is already NULL.
It doesn't crash anymore in Debug 32/64 bit and Release 32 bit. It continues
crashing in Release 64bit in the vtkCommonCore-6.1.dll.
I don't think that this could be a solution, could be a bug in the
vtkObjectFactory?
Tks,
Lorenzo
----- Original Message -----
From: "Marcus D. Hanwell" <marcus.hanwell at kitware.com>
To: <lorenzo.cesario at softeco.it>
Cc: "VTK Users" <vtkusers at vtk.org>
Sent: Tuesday, July 01, 2014 7:52 PM
Subject: Re: [vtkusers] Migration problem vtk 5.8 - vtk 6.1
> On Tue, Jul 1, 2014 at 4:52 AM, <lorenzo.cesario at softeco.it> wrote:
>> Hi,
>> my application has an executable and some dlls. Among them, there is one
>> dll that used vtk 5.8 and now I'm doing the migration to the vtk 6.1.
>> I'm using Visual Studio 2010 and my appliation is MFC-based.
>>
>> In the properties of the dll using vtk, I obviously included the
>> "Additional Include Directories" and "Additional Library" for the vtk
>> header files and .lib files.
>> Moreover I added in the "Preprocessor definition" field of the C/C++
>> Property of the same dll, this value:
>> vtkRenderingCore_INCLUDE="InitVtkObjFactory.h" and I added the file
>> InitVtkObjFactory.h with this code:
>>
>> #include <vtkAutoInit.h>
>> VTK_MODULE_INIT(vtkRenderingOpenGL);
>> VTK_MODULE_INIT(vtkInteractionStyle);
>> VTK_MODULE_INIT(vtkRenderingFreeType);
>> VTK_MODULE_INIT(vtkRenderingFreeTypeOpenGL);
>>
>> When I close the application it crashes and in the call stack there is
>> the last call on vtkCommonCore-6.1.dll.
>
> I have never tested the code in a scenario like this, although nothing
> jumps out as an issue. Do you have header guards around this init
> header to ensure it is just called once? It should be safe to call
> many times, but it is possible something odd is happening there.
>>
>> Then, I removed the line inside the file InitVtkObjFactory.h related to
>> the InteractionStyle as follows:
>>
>> #include <vtkAutoInit.h>
>> VTK_MODULE_INIT(vtkRenderingOpenGL);
>> VTK_MODULE_INIT(vtkRenderingFreeType);
>> VTK_MODULE_INIT(vtkRenderingFreeTypeOpenGL);
>>
>> and in this case, when the application starts, it shows a "warning"
>> window from vtk in which is written:
>>
>> Warning: In
>> ..\..\..\..\..\src\Vtk\Rendering\Core\vtkInteractorStyleSwitchBase.cxx,
>> line 43
>> vtkInteractorStyleSwitchBase (07EC7FB8): Warning: Link to
>> vtkInteractionStyle for default style selection.
>
> This is there to warn that no default interaction style will be used,
> many old applications relied upon this being present and we wanted a
> warning. It is just a warning, but it could be quite frustrating to
> track down. It is unlikely to cause other side effects if you chose to
> ignore it, but there is no way of silencing the warning.
>>
>> but when I close the application, this time it has no error or crashes.
>> I'm using a vtkInteractorStyleTrackballCamera for my RenderWindow.
>
> If you set a style then all will work as expected. This looks like a
> bug in the factory destruction, but I have not seen this in my testing
> (I have also not built any VTK-based applications without using
> CMake).
>>
>> Any ideas? Is there anything wrong in the migration related to the new
>> modules initialization?
>>
> It is odd that it would break on such a simple module, with only a
> single override. If you select a style you do not need that override,
> but it would be nice to figure out what is going wrong here. I am not
> aware of similar issues, do you have any more information on how/why
> it is crashing? Is the object factory NULL for example?
>
> Thanks,
>
> Marcus
>
>
More information about the vtkusers
mailing list