v0.8.1: fixed a NPE when fonts are reset before being initialized

This commit is contained in:
Evan Debenham 2020-06-26 13:11:50 -04:00
parent 2d2a595655
commit 62e795a4d7
2 changed files with 28 additions and 24 deletions

View File

@ -309,21 +309,23 @@ public class AndroidPlatformSupport extends PlatformSupport {
@Override
public void resetGenerators() {
for (FreeTypeFontGenerator generator : fonts.keySet()){
for (BitmapFont f : fonts.get(generator).values()){
f.dispose();
if (fonts != null) {
for (FreeTypeFontGenerator generator : fonts.keySet()) {
for (BitmapFont f : fonts.get(generator).values()) {
f.dispose();
}
fonts.get(generator).clear();
generator.dispose();
}
fonts.get(generator).clear();
generator.dispose();
}
fonts.clear();
if (packer != null){
for (PixmapPacker.Page p : packer.getPages()){
p.getTexture().dispose();
fonts.clear();
if (packer != null) {
for (PixmapPacker.Page p : packer.getPages()) {
p.getTexture().dispose();
}
packer.dispose();
}
packer.dispose();
fonts = null;
}
fonts = null;
setupFontGenerators(pageSize, systemfont);
}

View File

@ -135,21 +135,23 @@ public class DesktopPlatformSupport extends PlatformSupport {
@Override
public void resetGenerators() {
for (FreeTypeFontGenerator generator : fonts.keySet()){
for (BitmapFont f : fonts.get(generator).values()){
f.dispose();
if (fonts != null) {
for (FreeTypeFontGenerator generator : fonts.keySet()) {
for (BitmapFont f : fonts.get(generator).values()) {
f.dispose();
}
fonts.get(generator).clear();
generator.dispose();
}
fonts.get(generator).clear();
generator.dispose();
}
fonts.clear();
if (packer != null){
for (PixmapPacker.Page p : packer.getPages()){
p.getTexture().dispose();
fonts.clear();
if (packer != null) {
for (PixmapPacker.Page p : packer.getPages()) {
p.getTexture().dispose();
}
packer.dispose();
}
packer.dispose();
fonts = null;
}
fonts = null;
setupFontGenerators(pageSize, systemfont);
}