destroy all images when closing

This commit is contained in:
yugecin 2017-01-18 19:33:58 +01:00
parent a02613bb76
commit 156026bd9b
2 changed files with 33 additions and 0 deletions

View File

@ -461,6 +461,37 @@ public enum GameImage {
} }
} }
public static void destroyAll() {
for (GameImage img : GameImage.values()) {
destroyAll(img.defaultImages);
destroyImage(img.defaultImage);
destroyAll(img.skinImages);
destroyImage(img.skinImage);
img.isSkinned = false;
img.defaultImages = img.skinImages = null;
img.defaultImage = img.skinImage = null;
}
}
public static void destroyAll(Image[] imgs) {
if (imgs == null) {
return;
}
for (Image i : imgs) {
destroyImage(i);
}
}
public static void destroyImage(Image image) {
if (image == null) {
return;
}
try {
image.destroy();
} catch (SlickException ignored) {
}
}
/** /**
* Returns the bitmask image type from a type string. * Returns the bitmask image type from a type string.
* @param type the type string * @param type the type string

View File

@ -212,6 +212,8 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
} }
public void teardown() { public void teardown() {
InternalTextureLoader.get().clear();
GameImage.destroyAll();
Display.destroy(); Display.destroy();
} }