hushaojie04 / libgdx

Automatically exported from code.google.com/p/libgdx
0 stars 0 forks source link

JoglApplication.exit() and WindowClose event #639

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi friends,
in JOGL calling the exit method has an other behavior than closing the window.

On Linux operating system, calling exit doesn't free all resources and the 
window remains hanging until i kill it by brute force;)

My system configuration:
Linux x86_64, 2.6.38-gentoo-r6
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)

I've fixed this in my local source by changing the exit method as follows:

OLD METHOD:

public void exit () {
    postRunnable(new Runnable() {
        @Override
        public void run () {
            JoglApplication.this.graphics.listener.pause();
            JoglApplication.this.graphics.listener.dispose();
            System.exit(-1);
        }

NEW METHOD:

@Override
public void exit () {
    postRunnable(new Runnable() {
        @Override
        public void run () {
            frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
        }

I simply simulated the close event, which is caught by you own event handler.
This solution worked fine for me.
I would suggest to test it on you OS too before changing the SVN-trunk.

Greetings from Austria

Original issue reported on code.google.com by ridiculousRPG on 3 Jan 2012 at 3:15

GoogleCodeExporter commented 9 years ago
Good call, fixed in SVN, nightlies are building. Thanks!

Greetings from Graz :)

Original comment by badlogicgames on 10 Jan 2012 at 10:44

GoogleCodeExporter commented 9 years ago
This results in Screen#dispose() being called from within JoglGraphics#display 
(line 114) afterwards JoglGraphics#display continues to call listener.render().
Since the renderers resources are now properly disposed this results in a 
GLException.

Solution could be to reorder the contents of JoglGraphics#display to render 
first, process input next or it could set a flag whether or not it should 
render.

My platform is linux-amd64, with the latest libgdx from svn.

Original comment by seraphim...@gmail.com on 20 Feb 2012 at 5:00