Skip to content

Add null check when displaying project icons for MapContentView.#12239

Closed
m1cxzfw3q wants to merge 8 commits into
Anuken:masterfrom
m1cxzfw3q:master
Closed

Add null check when displaying project icons for MapContentView.#12239
m1cxzfw3q wants to merge 8 commits into
Anuken:masterfrom
m1cxzfw3q:master

Conversation

@m1cxzfw3q

@m1cxzfw3q m1cxzfw3q commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

The game crashes because the new project icon is empty.

java.lang.NullPointerException: Cannot invoke "arc.graphics.g2d.TextureRegion.found()" because "u.uiIcon" is null
	at mindustry.editor.data.MapContentView.build(MapContentView.java:85)
	at mindustry.editor.data.MapAssetsDialog.rebuild(MapAssetsDialog.java:130)
	at mindustry.editor.data.MapContentView.lambda$addContent$28(MapContentView.java:188)
	at mindustry.core.UI.lambda$loadAnd$10(UI.java:295)
	at arc.util.Timer$1.run(Timer.java:88)
	at arc.util.TaskQueue.run(TaskQueue.java:17)
	at arc.backend.sdl.SdlApplication.loop(SdlApplication.java:216)
	at arc.backend.sdl.SdlApplication.<init>(SdlApplication.java:58)
	at mindustry.desktop.DesktopLauncher.main(DesktopLauncher.java:53)

So, this PR solves this issue by adding empty check for the image display part.

If your pull request is not translation or serverlist-related, read the list of requirements below and check each box:

  • I have read the contribution guidelines.
  • I have ensured that my code compiles, if applicable.
  • I have ensured that any new features in this PR function correctly in-game, if applicable.

@m1cxzfw3q
m1cxzfw3q marked this pull request as ready for review June 18, 2026 17:51
@Anuken

Anuken commented Jun 19, 2026

Copy link
Copy Markdown
Owner

uiIcon should never be allowed to be null, and never appears as null in my tests. A null icon would crash other parts of the game. Can you provide steps to reproduce this in-game?

@m1cxzfw3q

Copy link
Copy Markdown
Contributor Author

Create buildings with errors in the game by data patches.

Even with fullIcon and uiIcon configured, it will crash.

@Anuken

Anuken commented Jun 21, 2026

Copy link
Copy Markdown
Owner

The root cause has been fixed, but I added an extra check just in case.

@Anuken Anuken closed this Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants