thread event leads to deadlock
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
The problem comes from the following macro in vtkFixedPointVolumeRayCastHelper.h :
if( 0==threadID && ( j%10 || j==imageInUseSize-1 ) ) /if ( j%32 == 31 )/
fargs = static_cast<double>(j)/static_cast<float>(imageInUseSize-1);
mapper->InvokeEvent( vtkCommand::VolumeMapperRenderProgressEvent, fargs );
I have a vtkCommand observing the event that calls a method SetProgressState(value) of an object containing a wxProgressDialog that will be updated with the value comming from 'fargs'.
The problem is that wxProgressDialog calls a "SendMessage" (windows) and if the event has been fired in a thread that is not the main one, all that leads to a deadlock when trying to draw the progress bar.
For example if we have two threads for the raycast, the main one will be in charge of the pair values for the j variable and the event will be fired by the other thread (when j%32 == 31, j is not pair)
So a solution to avoid that is replacing the "if" line in the #define by this one:
if( 0==threadID && ( j%10 || j==imageInUseSize-1 ) )
In that case the event is only fired by the main thread. ( j%10 is to have a more precise progression and j==imageInUseSize-1 is to have the value 1.0 with the ProgressEvent and not only for the EndProgressEvent ).