mbrlabs / Mundus

A 3D world/level editor built with Java, Kotlin & libGDX.
Apache License 2.0
214 stars 36 forks source link

NPE when setting Fog color for first time. #22

Closed krukhlis closed 8 years ago

krukhlis commented 8 years ago

When I try to set Fog params, selection of the color for Fog results in [23:19][Fatal][Log] java.lang.NullPointerException at com.mbrlabs.mundus.ui.modules.dialogs.FogDialog$4.selected(FogDialog. java:124) at com.mbrlabs.mundus.ui.widgets.ColorPickerField$1.finished(ColorPicker Field.java:97) at com.kotcrab.vis.ui.widget.color.ColorPicker$2.changed(ColorPicker.jav a:118) at com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.handle(ChangeLis tener.java:28)

Note, if you save project -- next time it works ok. If you see some values in the Fog dialog -- it will work. According to code, either getFog(), either getFog().color is null.

mbrlabs commented 8 years ago

I can't reproduce this. Are you using the latest version? If so could you please provide the exact steps you take to reproduce this?

If you have used Mundus before, there might be some save files on your system, that are not compatible any more. Try deleting everthing in ~/.mundus and ~/MundusProjects

krukhlis commented 8 years ago

Yes, I always post bugs for the recent version :) I can reproduce it 100% 1) Run mundus 2) Open the Fog params dialog( Environment->Fog) 3) Untick "Use fog" 4) Now, click on the button to "select" color. The pallete selection dialog appears. Click any color and click "Ok" 5) Enjoy NPE :)

The fix is to disable the "select" button if "Use fog" is unticked. The same way as you disable all other controls of this dialog. Or/and we can add protection to the selected callback at line 124: Instead of projectContext.currScene.environment.getFog().color.set(color); we will use if( projectContext.currScene.environment.getFog()!=null && projectContext.currScene.environment.getFog().color!=null) projectContext.currScene.environment.getFog().color.set(color);

mbrlabs commented 8 years ago

Alright, fixed the issue by disabling the color selection. Thanks for the report ;)