Nifty Console crash

Hi!

I’ve just implemented the nifty console to display some in game messages.

I’ve encountered a problem that i think is within nifty.

Here’s the repro:

I have two different nifty “screens”. One has a console, one hasn’t.

  1. I launch the game with the one that hasn’t a console.
  2. I switch to the one with the console. Console is fine.
  3. I switch back to the screen without a console.
  4. I switch back to the console screen. Bang!


Exception in thread "LWJGL Renderer Thread" java.lang.NullPointerException
at de.lessvoid.nifty.controls.listbox.ListBoxControl.applyWidthConstraints(ListBoxControl.java:304)
at de.lessvoid.nifty.controls.listbox.ListBoxControl.ensureWidthConstraints(ListBoxControl.java:284)
at de.lessvoid.nifty.controls.listbox.ListBoxControl.display(ListBoxControl.java:207)
at de.lessvoid.nifty.controls.listbox.ListBoxImpl.updateView(ListBoxImpl.java:42)
at de.lessvoid.nifty.controls.listbox.ListBoxImpl.changeSelectionMode(ListBoxImpl.java:81)
at de.lessvoid.nifty.controls.listbox.ListBoxControl.initSelectionMode(ListBoxControl.java:482)
at de.lessvoid.nifty.controls.listbox.ListBoxControl.bind(ListBoxControl.java:106)
at de.lessvoid.nifty.controls.NiftyInputControl.bindControl(NiftyInputControl.java:124)
at de.lessvoid.nifty.elements.Element.bindControls(Element.java:1704)
at de.lessvoid.nifty.elements.Element.bindControls(Element.java:1708)
at de.lessvoid.nifty.elements.Element.bindControls(Element.java:1708)
at de.lessvoid.nifty.screen.Screen.bindControls(Screen.java:752)
at de.lessvoid.nifty.screen.Screen.startScreen(Screen.java:192)
at de.lessvoid.nifty.Nifty.gotoScreenInternal(Nifty.java:587)
at de.lessvoid.nifty.Nifty.access$200(Nifty.java:70)
at de.lessvoid.nifty.Nifty$1.perform(Nifty.java:561)
at de.lessvoid.nifty.screen.Screen$EndScreenEndNotify.perform(Screen.java:600)
at de.lessvoid.nifty.screen.Screen$LocalEndNotify.perform(Screen.java:557)
at de.lessvoid.nifty.elements.Element$LocalEndNotify.perform(Element.java:1652)
at de.lessvoid.nifty.elements.Element$LocalEndNotify.perform(Element.java:1652)
at de.lessvoid.nifty.elements.Element$LocalEndNotify.perform(Element.java:1652)
at de.lessvoid.nifty.effects.EffectProcessor.checkFinish(EffectProcessor.java:299)
at de.lessvoid.nifty.effects.EffectProcessor.renderActive(EffectProcessor.java:84)
at de.lessvoid.nifty.effects.EffectProcessor.renderPre(EffectProcessor.java:57)
at de.lessvoid.nifty.effects.EffectManager$RenderPhasePre.render(EffectManager.java:318)
at de.lessvoid.nifty.effects.EffectManager.render(EffectManager.java:120)
at de.lessvoid.nifty.effects.EffectManager.renderPre(EffectManager.java:135)
at de.lessvoid.nifty.elements.Element.render(Element.java:569)
at de.lessvoid.nifty.elements.Element.renderInternalChildElements(Element.java:604)
at de.lessvoid.nifty.elements.Element.renderChildren(Element.java:597)
at de.lessvoid.nifty.elements.Element.render(Element.java:564)
at de.lessvoid.nifty.elements.Element.renderInternalChildElements(Element.java:604)
at de.lessvoid.nifty.elements.Element.renderChildren(Element.java:597)
at de.lessvoid.nifty.elements.Element.render(Element.java:564)
at de.lessvoid.nifty.screen.Screen.renderLayers(Screen.java:293)
at de.lessvoid.nifty.Nifty.render(Nifty.java:265)
at com.jme3.niftygui.NiftyJmeDisplay.postQueue(NiftyJmeDisplay.java:164)
at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:740)


ListBoxControl.java:
[java]
302 SizeValue newWidthSizeValue = new SizeValue(width + "px");
303 for (Element element : labelElements) {
304 element.setConstraintWidth(newWidthSizeValue);
305 }[/java]

On a slightly other topic, but worth mentioning:
I downloaded the latest nifty nightly build (from the 29th), and it seems the pop up menu doesn't register clicks on menu items (neither in my project, or the test app). Didn't want to create a whole new topic since it's still a "nightly".

And thirdly, for anyone reading this far, i can really recommend checking out the examples jar, if you haven't. It's a gold mine when it comes to nifty development :)

Hi Rickard,



that is the same issue as reported here: http://hub.jmonkeyengine.org/groups/gui/forum/topic/reopening-a-screen-with-a-listbox/ (the console does use a listbox internally for output).



And I introduced the popup menu bug while fixing and improving how the builders work internally. I’ve found the problem today. I’ll commit that tommorow together with the ListBox/control fixes.



Consider it fixed in the next two days :wink:



void

1 Like

Awesome. Thanks!

The next Nifty build should fix that issue here as well :slight_smile:

1 Like

Tested with the 110604 build, and both work nicely!