disposing assets that weren't properly disposed

This commit is contained in:
Harrison Deng 2017-12-05 09:16:01 -06:00
parent 72b91a53fe
commit 8f03c3310d
4 changed files with 18 additions and 1 deletions

View File

@ -119,6 +119,12 @@ public class BasicVisualizer extends VisualizerCore {
@Override @Override
public void dispose() { public void dispose() {
bar.dispose(); bar.dispose();
for (int i = 0; i < textures.length; i++) {
textures[i].dispose();
}
if (mm != null) {
mm.dispose();
}
super.dispose(); super.dispose();
} }

View File

@ -116,6 +116,7 @@ public class TitleBarVisualizer extends Group implements Disposable {
@Override @Override
public void dispose() { public void dispose() {
visual.dispose();
bgTexture.dispose(); bgTexture.dispose();
} }

View File

@ -4,11 +4,12 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.scenes.scene2d.ui.Widget; import com.badlogic.gdx.scenes.scene2d.ui.Widget;
import com.badlogic.gdx.utils.Disposable;
import zero1hd.rhythmbullet.audio.MusicManager; import zero1hd.rhythmbullet.audio.MusicManager;
import zero1hd.rhythmbullet.audio.visualizer.BasicVisualizer; import zero1hd.rhythmbullet.audio.visualizer.BasicVisualizer;
public class Visualizer extends Widget { public class Visualizer extends Widget implements Disposable {
private BasicVisualizer vis; private BasicVisualizer vis;
private boolean updatePositioning = true; private boolean updatePositioning = true;
private boolean mmSet; private boolean mmSet;
@ -45,6 +46,9 @@ public class Visualizer extends Widget {
public void setMM(MusicManager mm) { public void setMM(MusicManager mm) {
if (mm != null) {
mm.dispose();
}
this.mm = mm; this.mm = mm;
mmSet = false; mmSet = false;
} }
@ -90,4 +94,9 @@ public class Visualizer extends Widget {
return vis; return vis;
} }
@Override
public void dispose() {
vis.dispose();
}
} }

View File

@ -107,6 +107,7 @@ public class MainPage extends Page implements Observer {
@Override @Override
public void dispose() { public void dispose() {
titleBar.dispose();
super.dispose(); super.dispose();
} }