[vtk-developers] Re: [VTK + wxWindows] Reparenting bug fix
Charl P. Botha
c.p.botha at its.tudelft.nl
Tue Apr 1 03:57:02 EST 2003
Hi there Benoit,
On Tue, 2003-04-01 at 10:42, Benoit Regrain wrote:
> I have made last modifications concerning reparenting.
> Now, all work for me. But I don't know if my solutions are optimum.
>
> Modifications are :
> 1 - a bug fix concerning reparenting when the vtkRenderWindow has
> never been drawn in a window. The problem was in the destruction of
> a context which have never existed.
I'm not going to apply this fix, but something similar to it. It's good
that you found this bug... ALL gl statements in the WindowRemap method
should be protected with a this->Internal->ContextId check clause.
> 2 - the closure of the display. When we flip 2 vtkRenderWindow
> between to wxPanel, a segmentation fault appears. This closure
> solves the problem. (Example is done in
> http://www.creatis.insa-lyon.fr/~regrain/VTK/patch/testSplitter.py)
This should be harmless, as a new display gets allocated in
WindowInitialize which is called shortly after your change. However, I
would be very interested to know why this segfaults for you under
Linux. Re-using the display should work.
> 3 - bug fix concerning lose of actors after reparenting under linux.
> The solve it, manually I unplug and replug vtkProp elements in all
> renderers in the vtkRenderWindow. It's not probably the best solution
> but it's the simplest that I have found to change minimum files.(Examples
> are
> done in http://www.creatis.insa-lyon.fr/~regrain/VTK/patch/testRemap.py
> and testSplitter.py)
I don't like this as it's just a work-around. Until we find the real
reason why a reparent makes all actors go invisible only under Linux, do
this workaround in your user-code. I have a few ideas on why this is
happening and will look at it at a later stage.
> If you might apply these changes today, (only if you think they are good)
> because I am in hollidays tomorrow evening. I wouldn't let it not finished
> before going away.
No guarantees. :) My schedule is a bit hectic and I would like to have
a more serious look at this. Don't worry, I'll take good care of it, go
enjoy your holiday.
Best regards,
Charl
--
charl p. botha http://cpbotha.net/ http://visualisation.tudelft.nl/
-------------- next part --------------
--- old/vtkXOpenGLRenderWindow.cxx Tue Apr 1 10:54:59 2003
+++ new/vtkXOpenGLRenderWindow.cxx Tue Apr 1 10:55:31 2003
@@ -681,7 +681,10 @@
else
#endif
{
- glXDestroyContext( this->DisplayId, this->Internal->ContextId);
+ if(this->Internal->ContextId)
+ {
+ glXDestroyContext( this->DisplayId, this->Internal->ContextId);
+ }
// then close the old window
if (this->OwnWindow)
{
@@ -689,13 +692,50 @@
}
}
-
+ // If the display is not closed, it could generate a segmentation fault
+ // under linux
+ if(this->DisplayId)
+ {
+ XCloseDisplay(this->DisplayId);
+ this->DisplayId=0;
+ }
+
// set the default windowid
this->WindowId = this->NextWindowId;
this->NextWindowId = (Window)NULL;
// configure the window
this->WindowInitialize();
+
+ // Because of the destruction of the environnement,
+ // // after WindowRemap, no prop is visible
+ // // Actors must be removed and add to force their redraw
+ vtkRenderer *ren;
+ vtkProp *prop;
+ vtkPropCollection *props;
+ vtkPropCollection *tmpProps=vtkPropCollection::New();
+
+ this->Renderers->InitTraversal();
+ while ( (ren = this->Renderers->GetNextItem()) )
+ {
+ ren->Modified();
+ props=ren->GetProps();
+
+ props->InitTraversal();
+ while( (prop = props->GetNextProp()) )
+ {
+ tmpProps->AddItem(prop);
+ ren->RemoveProp(prop);
+ props->InitTraversal();
+ }
+
+ tmpProps->InitTraversal();
+ while( (prop = tmpProps->GetNextProp()) )
+ {
+ ren->AddProp(prop);
+ }
+ tmpProps->Delete();
+ }
}
// Begin the rendering process.
More information about the vtk-developers
mailing list