Login  Register

Re: windowClosing causes GLCanvas to displose

Posted by Sven Gothel on Aug 31, 2010; 10:42pm
URL: https://forum.jogamp.org/windowClosing-causes-GLCanvas-to-displose-tp1380491p1397350.html

On Saturday, August 28, 2010 06:54:19 pm Demoscene Passivist [via jogamp] wrote:

>
> U are right this is indeed a strange behavior. Never noticed it myself.
>
> After looking at the
> http://github.com/sgothel/jogl/blob/master/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
> GLCanvas sourcecode on Github  the behavior became clear as there is an
> implicit closing listener registered when the display method is called on
> the GLCanvas.
>
>   public void display() {
>     maybeDoSingleThreadedWorkaround(displayOnEventDispatchThreadAction,
>                                     displayAction);
>     if(null==closingListener) {
>       synchronized(closingListenerLock) {
>         if(null==closingListener) {
>             closingListener=addClosingListener(this, new DestroyMethod() {
>                         public void destroyMethod() { destroy(); } });
>         }
>       }
>     }
>   }
>
> ... don't know why this was done. Seems wrong to me but maybe theres a valid
> reason for this and Sven/Michael could shed light on this issue.
>

Looks interesting, indeed.

We have to remove our GL/JOGL resources _before_ the native underlying window
has been closed!

Thats why we destroy on 'closing',
but IMHO 'closing' should be send only in case the window will be destroyed for sure.
Sounds like an AWT bug to me.

+++
void windowClosing(WindowEvent e)

    Invoked when the user attempts to close the window from the window's system menu.
+++

Or is such a use case (really close) valid in combination with 'closing' ?

The only pieces I have found involved a manual 'really closing' dialog like this:

http://forums.sun.com/thread.jspa?threadID=650850&tstart=0
http://forums.sun.com/thread.jspa?threadID=652071

In such case, we would need to opt-out the destroy() on 'closing' behavior in GLCanvas,
ie remove/not-add the listener for a user implemented 'closing' logic.

Proposal: New GLCanvas method 'disableDestroyOnClosing(boolean v)'

I guess that makes sense.

Questions, Comments, Remarks ?
 
Cheers, Sven

> As a workaround for this issue I would suggest extending the GLCanvas and
> overriding the display method and remove the implicit closing listener
> registration.
>
> ______________________________________
> View message @ http://jogamp.762907.n3.nabble.com/windowClosing-causes-GLCanvas-to-displose-tp1380491p1380604.html
> To start a new topic under jogamp, email [hidden email]
> To unsubscribe from jogamp, click http://jogamp.762907.n3.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_code&node=762907&code=c2dvdGhlbEBqYXVzb2Z0LmNvbXw3NjI5MDd8NDU1NjU4MjUx
>


--
health & wealth
mailto:[hidden email] ; http://jausoft.com
land : +49 (471) 4707742 ; cell: +49 (151) 28145941
Timezone CET: PST+9, EST+6, UTC+1