NullPointerException with Nifty

Can anyone give me any hints on why im getting this exception. It doesnt happen all the time.

It seems to happen when I hit the button to goto my Nifty GUI Screen

Thanks,

Greg



[java]SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.NullPointerException

at de.lessvoid.nifty.screen.Screen.forwardMouseEventToLayers(Screen.java:302)

at de.lessvoid.nifty.screen.Screen.mouseEvent(Screen.java:289)

at de.lessvoid.nifty.Nifty.forwardMouseEventToScreen(Nifty.java:244)

at de.lessvoid.nifty.Nifty.access$1100(Nifty.java:66)

at de.lessvoid.nifty.Nifty$NiftyInputConsumerImpl.processEvent(Nifty.java:1249)

at de.lessvoid.nifty.Nifty$NiftyInputConsumerImpl.processMouseEvent(Nifty.java:1222)

at com.jme3.niftygui.InputSystemJme.onMouseButtonEventQueued(InputSystemJme.java:126)

at com.jme3.niftygui.InputSystemJme.forwardEvents(InputSystemJme.java:169)

at de.lessvoid.nifty.Nifty.update(Nifty.java:226)

at com.jme3.niftygui.InputSystemJme.endInput(InputSystemJme.java:92)

at com.jme3.input.InputManager.processQueue(InputManager.java:551)

at com.jme3.input.InputManager.update(InputManager.java:600)

at com.jme3.app.Application.update(Application.java:463)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:228)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:143)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:171)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:217)

at java.lang.Thread.run(Thread.java:662)

Inconsistency detected by ld.so: dl-close.c: 736: _dl_close: Assertion `map->l_init_called’ failed![/java]

You being on Linux isn’t helping me, but it seems ld.so (some library) is having some inconsistency… (that’s on the last line)

I can’t find that line in the current Nifty probably because the source has been changed on other places. Can you try to find the line in the source for the specific nifty/jme build you’re using?

Im using the jar file from the nightly build

nifty-1.3-SNAPSHOT.jar



I looked in the SorceForge



http://nifty-gui.svn.sourceforge.net/viewvc/nifty-gui/nifty/trunk/src/main/java/de/lessvoid/nifty/screen/Screen.java?revision=1330&view=markup



I think the code is[java]

mouseOverHandler.reset();

[/java]



[java]

/

283 * Handle Mouse Events for this screen. Forwards the event to the layers.

284 * @param inputEvent MouseInputEvent

285 * @return true when processed and false when not

286 */

287 public final boolean mouseEvent(final MouseInputEvent inputEvent) {

288 if (!popupElements.isEmpty()) {

289 return forwardMouseEventToLayers(popupElements, inputEvent);

290 } else {

291 return forwardMouseEventToLayers(layerElements, inputEvent);

292 }

293 }

294

295 /


296 * forward mouse event to the given layer list.

297 * @param layerList layer list

298 * @param inputEvent TODO

299 * @return TODO

300 */

301 private boolean forwardMouseEventToLayers(final List < Element > layerList, final MouseInputEvent inputEvent) {

302 mouseOverHandler.reset();

303

304 long eventTime = timeProvider.getMsTime();

305 for (int i=0; i<layerList.size(); i++) {

306 Element layer = layerList.get(i);

307 layer.buildMouseOverElements(inputEvent, eventTime, mouseOverHandler);

308 }

309

310 if (log.isLoggable(Level.FINE)) {

311 log.fine(mouseOverHandler.getInfoString());

312 }

313

314 mouseOverHandler.processMouseOverEvent(rootElement, inputEvent, eventTime);

315 mouseOverHandler.processMouseEvent(inputEvent, eventTime);

316

317 return mouseOverHandler.hitsElement();

318 }

[/java]



Any thoughts?

mouseOverHandler should never be null o_O It’s created in the Screen constructor. No idea at the moment. Do you have any unusual things going on, like calling Nifty from multiple screens.



When all else failes, would it be possible to zip the whole source in a way that I can E-A-S-I-L-Y build and test it here?

I commented out the nifty==null check in my code and the error goes away.

But that reintroduces a old error

I have 3 Nifty Screens

Menu (ESC)

Console/Chat (TAB)

Inventory(I)

If Im in my menu screen and I hit the I key by accident it will open both Nifty Screens

I guess I need to know if I should kill nifty each time or if I should hold a reference to it and make it open different

Screens

[java]nifty.fromXml("Interfaces/niftytest.xml", "start");[/java]

[java]

public void initNiftyGui() {

Logger.getLogger("de.lessvoid").setLevel( Level.OFF );

// if(nifty==null){

NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager,

inputManager, audioRenderer, guiViewPort);

nifty = niftyDisplay.getNifty();

guiViewPort.addProcessor(niftyDisplay);

// }

nifty.fromXml("Interfaces/niftytest.xml", "start");

guiState();

}[/java]



My Project is here http://code.google.com/p/script-blocks/