From b5d77dc7cf5181bb5fab1440b8c0b6351b1184bd Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 29 Dec 2025 19:46:35 -0500 Subject: [PATCH] Possible crash fix with editor saving --- core/src/mindustry/maps/Map.java | 14 +++++++------- core/src/mindustry/maps/Maps.java | 5 ++++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/core/src/mindustry/maps/Map.java b/core/src/mindustry/maps/Map.java index 36877c4124..36e78ef555 100644 --- a/core/src/mindustry/maps/Map.java +++ b/core/src/mindustry/maps/Map.java @@ -31,7 +31,7 @@ public class Map implements Comparable, Publishable{ /** Map width/height, shorts. */ public int width, height; /** Preview texture. */ - public Texture texture; + public @Nullable Texture texture; /** Build that this map was created in. -1 = unknown or custom build. */ public int build; /** All teams present on this map.*/ @@ -123,7 +123,7 @@ public class Map implements Comparable, Publishable{ } return maps.readFilters(tags.get("genfilters", "")); } - + public String name(){ return tag("name"); } @@ -135,7 +135,7 @@ public class Map implements Comparable, Publishable{ public String description(){ return tag("description"); } - + public String plainName() { return Strings.stripColors(name()); } @@ -165,13 +165,13 @@ public class Map implements Comparable, Publishable{ public void addSteamID(String id){ tags.put("steamid", id); editor.tags.put("steamid", id); - + try{ ui.editor.save(); }catch(Exception e){ Log.err(e); } - + Events.fire(new MapPublishEvent()); } @@ -179,7 +179,7 @@ public class Map implements Comparable, Publishable{ public void removeSteamID(){ tags.remove("steamid"); editor.tags.remove("steamid"); - + try{ ui.editor.save(); }catch(Exception e){ @@ -225,7 +225,7 @@ public class Map implements Comparable, Publishable{ public boolean prePublish(){ tags.put("author", player.name); editor.tags.put("author", player.name); - + ui.editor.save(); return true; } diff --git a/core/src/mindustry/maps/Maps.java b/core/src/mindustry/maps/Maps.java index 69398741ca..eefa52e6f5 100644 --- a/core/src/mindustry/maps/Maps.java +++ b/core/src/mindustry/maps/Maps.java @@ -238,10 +238,13 @@ public class Maps{ } Pixmap pix = MapIO.generatePreview(world.tiles); - mainExecutor.submit(() -> map.previewFile().writePng(pix)); writeCache(map); map.texture = new Texture(pix); + mainExecutor.submit(() -> { + map.previewFile().writePng(pix); + pix.dispose(); + }); } maps.add(map); maps.sort();