From: Kenneth B. R. <kbr...@al...> - 2002-04-06 05:03:08
|
> The windowClosing method in GLCanvas calls cvsDispose for some reason. > In my application I only hide a JFrame instead of disposing it on close > (BTW this is default behavior), but this makes the GLCanvas has dispose > itself. Now when the JFrame in question is set visible again, the > GLCanvas is gone. I commented the entire windowClosing implementation in > GLCanvas out and it seems to work fine. Was there any reason this code > was put there? It seems to me the GLCanvas will get the windowClosed > event when a containing window is disposed, so doing dispose on > windowClosing seems unnecessary. I can't answer this definitively but can probably offer some insight. The OpenGL context needs to be associated with the underlying widget/HWND/etc. and discarded at the appropriate time. The problem (as I understand it) is that by the time the underlying window has been disposed, it's "too late" to dispose of the OpenGL context since the associated HWND is gone. This is probably why the OpenGL context is being disposed of eagerly, in anticipation that the window might get destroyed. There probably needs to be some sort of re-initialization code put into place rather than removal of the context cleanup code, or applications which really do create and destroy GLCanvas objects will have a memory leak. |