destroy even more images when closing

This commit is contained in:
yugecin
2017-01-18 19:40:31 +01:00
parent 156026bd9b
commit 0eac32505b
5 changed files with 74 additions and 27 deletions

View File

@@ -17,9 +17,11 @@
*/
package yugecin.opsudance.core;
import itdelatrisu.opsu.GameData;
import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.beatmap.Beatmap;
import itdelatrisu.opsu.ui.Fonts;
import org.lwjgl.Sys;
import org.lwjgl.openal.AL;
@@ -213,7 +215,9 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
public void teardown() {
InternalTextureLoader.get().clear();
GameImage.destroyAll();
GameImage.destroyImages();
GameData.Grade.destroyImages();
Beatmap.destroyBackgroundImageCache();
Display.destroy();
}

View File

@@ -0,0 +1,44 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin
*
* opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* opsu!dance is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with opsu!dance. If not, see <http://www.gnu.org/licenses/>.
*/
package yugecin.opsudance.utils;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
public class SlickUtil {
public static void destroyImages(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) {
}
}
}