[vtkusers] [Python + wx] pb with wxVTKRenderWindow

Benoit Regrain benoit.regrain at creatis.insa-lyon.fr
Tue Oct 8 03:14:12 EDT 2002


----- Original Message -----
From: "Prabhu Ramachandran" <prabhu at aero.iitm.ernet.in>
To: "Benoit Regrain" <benoit.regrain at creatis.insa-lyon.fr>
Cc: "Mailing VTK Users" <vtkusers at public.kitware.com>
Sent: Friday, October 04, 2002 9:08 PM
Subject: Re: [vtkusers] [Python + wx] pb with wxVTKRenderWindow


> >>>>> "BR" == Benoit Regrain <benoit.regrain at creatis.insa-lyon.fr> writes:
>
>     BR> I believe I might have found two bugs in the class
>     BR> wxVTKRenderWindow as encountered in
>     BR> VTK/Wrapping/Python/vtk/wx/wxVTKRenderWindow.py.  I am working
>     BR> on Windows 2000 with the VTKNightly dated 10/02/2002.
>
>     BR> I could fix this problem, by changing the line 164 by : try:
>     BR> size = parent.GetSize() except: size = wxDefaultSize The
>     BR> try/except is used to protect the call to parent.
>
> 2 points here:
>
>  1. I think blanket except clauses are not a good idea (unless
>  unavoidable).  I'd prefer something like:
>
> try:
>     size = parent.GetSize()
> except AttributeError:
>     size = wxDefaultSize
>
> Or something like that.  I dont get an exception under Linux so don't
> know what exception you are trying to catch here.  Could you care to
> elaborate?
The AttributeError exception is the best here. Parent variable is always
defined but can be anything
other than a wxWindow (like None or other type). No other exception is
usefull to foresee bad
behaviors concerning this section of code.

>
>     BR>  - When the script wxVTKRenderWindow.py is launched and when
>     BR> killing the window (by clicking on the window close button,
>     BR> the one with a cross at the upper right), I get the following
>     BR> error message in the Python console : runtime error R6025 -
>
>     BR>    def __del__(self): renderers =
>     BR> self._RenderWindow.GetRenderers() numRenderers =
>     BR> renderers.GetNumberOfItems() self._CurrentRenderer = None
>     BR> renderers.InitTraversal() for i in range(0,numRenderers):
>     BR> self.GetRenderWindow().RemoveRenderer(renderers.GetNextItem())
>
> This could be added but I have one question here.  IIRC __del__ is
> actually called only after the window is killed and any "bad
> behaviour" can occur when the window is alive.  Ok, there is the case
> that the window is dead and the actors are still alive.  But are we
> guaranteed that __del__ will be called as soon as the window is
> destroyed?  The order of destruction of the objects also matters here.
> I dont remember clearly but is there a way to always call a function
> *before* a widget (I mean any widget) is destroyed and not at object
> destruction?  If the renderers maybe removed in that function.

The runtime error R6025 is a specific Windows error. But it seems that on
Linux,
we sometimes obtain a core dump. Unfortunately, I can't certify the
behaviour of
events between the closing and the destruction in memory of the window. But
the
problem that we have appears after the window's destruction.
I have discovered Python recently, and I don't know all mechanisms under
this langage.
But this destructor realize a clean destruction of the wxVTKRenderWindow
instance. So, I think this destructor isn't bad, moreover it solves runtime
error
problems on windows and core dump problems on linux.
But if these errors persist, I'm ready to search a best solution (when I'll
know all
specifications of garbage collector :) ).

Greetings
Benoit Regrain





More information about the vtkusers mailing list