AppletLoader: clean up resources (images) when switching to the LWJGL Applet as opposed to when applet is destroyed

This commit is contained in:
kappa1 2010-07-24 20:00:58 +00:00
parent 3656b80763
commit a7b892b7ab
1 changed files with 14 additions and 2 deletions

View File

@ -368,12 +368,19 @@ public class AppletLoader extends Applet implements Runnable, AppletStub {
if (lwjglApplet != null) { if (lwjglApplet != null) {
lwjglApplet.destroy(); lwjglApplet.destroy();
} }
}
/**
* Clean up resources
*/
protected void cleanUp() {
progressbar = null; progressbar = null;
logo = null; logo = null;
logoBuffer = null; logoBuffer = null;
progressbarBuffer = null; progressbarBuffer = null;
offscreen = null;
} }
/** /**
@ -501,6 +508,9 @@ public class AppletLoader extends Applet implements Runnable, AppletStub {
*/ */
public boolean imageUpdate(Image img, int flag, int x, int y, int width, int height) { public boolean imageUpdate(Image img, int flag, int x, int y, int width, int height) {
// finish with this ImageObserver
if (state == STATE_DONE) return false;
// if image frame is ready to be drawn and is currently not being painted // if image frame is ready to be drawn and is currently not being painted
if (flag == ImageObserver.FRAMEBITS && !painting) { if (flag == ImageObserver.FRAMEBITS && !painting) {
Image buffer; Image buffer;
@ -750,7 +760,9 @@ public class AppletLoader extends Applet implements Runnable, AppletStub {
// switch to LWJGL Applet // switch to LWJGL Applet
switchApplet(); switchApplet();
state = STATE_DONE; state = STATE_DONE;
// clean up resources
cleanUp();
} catch (AccessControlException ace) { } catch (AccessControlException ace) {
fatalErrorOccured(ace.getMessage(), ace); fatalErrorOccured(ace.getMessage(), ace);
certificateRefused = true; certificateRefused = true;