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("EXPERIENCE", FSkinProp.IMG_EXPERIENCE);
addEncodingSymbol("A-", FSkinProp.IMG_ALCHEMY);
addEncodingSymbol("M", FSkinProp.ICO_MANASHARD);
// Set look and feel after skin loaded
FView.SINGLETON_INSTANCE.setSplashProgessBarMessage("Setting look and feel...");

View File

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

View File

@@ -42,4 +42,14 @@ public class GifAnimation extends ForgeAnimation {
@Override
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);
target.dispose();
Array<TextureRegion> texReg = new Array<>();
for(h = 0; h < hzones; h++) {

View File

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