add dispose for GifAnimation

This commit is contained in:
Anthony Calosa
2023-02-16 05:37:34 +08:00
parent 25372c072e
commit 8dc33b82fc
5 changed files with 19 additions and 2 deletions

View File

@@ -1476,7 +1476,6 @@ public class FSkin {
addEncodingSymbol("TK", FSkinProp.IMG_TICKET); addEncodingSymbol("TK", FSkinProp.IMG_TICKET);
addEncodingSymbol("EXPERIENCE", FSkinProp.IMG_EXPERIENCE); addEncodingSymbol("EXPERIENCE", FSkinProp.IMG_EXPERIENCE);
addEncodingSymbol("A-", FSkinProp.IMG_ALCHEMY); addEncodingSymbol("A-", FSkinProp.IMG_ALCHEMY);
addEncodingSymbol("M", FSkinProp.ICO_MANASHARD);
// Set look and feel after skin loaded // Set look and feel after skin loaded
FView.SINGLETON_INSTANCE.setSplashProgessBarMessage("Setting look and feel..."); FView.SINGLETON_INSTANCE.setSplashProgessBarMessage("Setting look and feel...");

View File

@@ -997,13 +997,14 @@ public class Forge implements ApplicationListener {
currentScreen = null; currentScreen = null;
} }
FOverlay.hideAll(); FOverlay.hideAll();
assets.dispose();
Dscreens.clear(); Dscreens.clear();
graphics.dispose(); graphics.dispose();
SoundSystem.instance.dispose(); SoundSystem.instance.dispose();
try { try {
ExceptionHandler.unregisterErrorHandling(); ExceptionHandler.unregisterErrorHandling();
lastPreview.dispose(); lastPreview.dispose();
assets.dispose();
AdventureScreen.dispose();
} catch (Exception e) { } catch (Exception e) {
} }
} }

View File

@@ -42,4 +42,14 @@ public class GifAnimation extends ForgeAnimation {
@Override @Override
protected void onEnd(boolean endingAll) { protected void onEnd(boolean endingAll) {
} }
public void dispose() {
if (animation != null) {
for (TextureRegion tr: animation.getKeyFrames()) {
try {
tr.getTexture().dispose();
} catch (Exception e) {}
}
}
}
} }

View File

@@ -712,6 +712,7 @@ public class GifDecoder {
} }
Texture texture = new Texture(target); Texture texture = new Texture(target);
target.dispose();
Array<TextureRegion> texReg = new Array<>(); Array<TextureRegion> texReg = new Array<>();
for(h = 0; h < hzones; h++) { for(h = 0; h < hzones; h++) {

View File

@@ -64,4 +64,10 @@ public class AdventureScreen extends LaunchScreen {
if (Gdx.files.absolute(demo).exists()) if (Gdx.files.absolute(demo).exists())
animation = new GifAnimation(demo, Animation.PlayMode.LOOP); animation = new GifAnimation(demo, Animation.PlayMode.LOOP);
} }
public static void dispose() {
if (animation != null) {
animation.dispose();
}
animation = null;
}
} }