Skip to content

Commit

Permalink
Fix deallocation of pixmap before use in thread
Browse files Browse the repository at this point in the history
ref #216
Also does writeCache in thread now
  • Loading branch information
zxtej committed May 14, 2024
1 parent d5f7c3b commit a55d024
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions core/src/mindustry/maps/Maps.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,16 @@ public Map saveMap(ObjectMap<String, String> baseTags){
}

Pixmap pix = MapIO.generatePreview(world.tiles);
mainExecutor.submit(() -> map.previewFile().writePng(pix));
writeCache(map);

map.texture = new Texture(pix);
pix.dispose();
mainExecutor.submit(() -> {
try{
writeCache(map);
}catch(IOException e){
throw new RuntimeException(e);
}
map.previewFile().writePng(pix);
pix.dispose();
});
}
maps.add(map);
maps.sort();
Expand Down

0 comments on commit a55d024

Please sign in to comment.