[vtkusers] Render window

Charl P. Botha c.p.botha at its.tudelft.nl
Mon Mar 3 03:44:08 EST 2003


Hi there Tuhin,

Note to developers: it appears that vtkWin32OpenGLRenderWindow handles
WM_DESTROY events in an almost sane fashion, whereas
vtkXOpenGLRendererWindow has no handling whatsoever.  Your opinion/advice on
this matter would be appreciated.

On Sun, Mar 02, 2003 at 06:46:16PM -0600, Tuhin Sinha wrote:
> 	I am a bit confused with the reference counting architecture in VTK.  My 
> understanding was that reference counting was used by an object to make sure 
> it deleted itself when it wasn't needed anymore.  However, does this imply 
> that the object _must_ wait until its reference count is 1 to delete itself?  
> Or, can it delete itself regardless of who/how many things are pointed at it?

An object MUST wait until its reference count is 0 before destructing.  Of
course there is nothing stopping the user forcing a destruct, but that is at
her own risk.  If you dig around in the VTK source, you'll note that that is
assumed everywhere: if an object takes out a reference on another object, it
EXPECTS that object to be there and available until it removes its
reference.

> The implication here is that the pointing object must make sure the 
> dereference is valid.  Any clarification on this would be greatly 
> appreciated.

"Pointing" objects do not do this.  I hope this is now clear. :)

> 	Also, I did some searching through the VTK source and found that the 
> vtkWin32OpenGLRenderWindow actually does window management (i.e. handles the 
> Win32 WM_DESTROY message).  There isn't a corresponding code segment in the 
> vtkXOpenGLRenderWindow class.  As a result of this difference, the code I 
> have attached to this e-mail runs "correctly" under Windows, but fails under 
> Linux.  I think that good window management can be done without any object 
> management.  That is, while the vtkRenderWindow object exists (regardless of 
> its reference count), it should maintain the status of its system specific 
> window properties unless told otherwise.  In my experience, 
> vtkXOpenGLRenderWindow does not do this... it creates the window, but then 
> expects the user to manage its consistency.  vtkWin32OpenGLRenderWindow does 
> the window management properly.

Whether this window management is "proper" is debatable.  I noticed this
event handler in vtkWin32OpenGLRenderWindow the other day, also during our
conversation.  It deallocates system resources and _partially_ disconnects
renderers. To complete the process, the user still has to know about the
destroy event and remove her remaining references to the RW as well.

> 	I am a relative newbie to VTK and I understand that there might be some 
> platform specific reasons for the discrepancy in the way these two classes 
> operate.  I am just wondering why and is there room for a way to make these 
> two classes operate more similarly?

I agree with you that it should be more consistent, although I would have to
defer to other more experienced VTK developers, as I see this as a more
fundamental change to the code.

Thanks,
Charl

-- 
charl p. botha http://cpbotha.net/ http://visualisation.tudelft.nl/



More information about the vtkusers mailing list