Nifty NullPointerException crash

Hello to everyone,

I ran jme3test.awt.TestCanvas and nifty crashes at :

  1. “switch look and feel”.
  2. “set size to 0”.

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

    java.lang.NullPointerException

    at de.lessvoid.nifty.Nifty.displayResolutionChanged(Nifty.java:685)

    at de.lessvoid.nifty.Nifty.render(Nifty.java:270)

    at com.jme3.niftygui.NiftyJmeDisplay.postQueue(NiftyJmeDisplay.java:170)

    at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1121)

    at com.jme3.renderer.RenderManager.render(RenderManager.java:1173)

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

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

    at com.jme3.system.lwjgl.LwjglCanvas.runLoop(LwjglCanvas.java:228)

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

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


  3. Also i noticed something strange, after using start/stop application, my init was called again, ambient light was recreated thus scene got brighter every time i used it.

Sounds like a bug in nifty. @void256: know anything about this?



About the start/stop issue, it assumes you’re not caching the scene since the entire application is restarted. If you store the scene somewhere then of course it will get corrupted each time the init is called

no, void256 knows nothing about that but when I suppose tralala uses Nifty 1.3 then the lines where it crashes is accessing the currentScreen instance variable of the Nifty instance. So could it be that this resolutionChanged() event is happening without having a valid screen yet?



jme3test.awt.TestCanvas in jMonkeyPlattform crashes here as well but I really don’t see any reference to Nifty in this example at all o_O

TestCanvas is actually loading another test internally. I think resolutionChanged() should still work even if there’s no screen

  1. yes i am using nifty 1.3.
  2. jme3test.awt.TestCanvas doesnt use nifty. I modified the code to add my application which has nifty.
  3. before pressing those 2 buttons “change look and feel”, “set size to 0” everything was running fine.

can you send your example in a zip or something for me to check? I don’t know what exactly you modified so it’s kinda hard to reproduce.

hello, i just returned,



replace method startApp() in jme3test.awt.TestCanvas with the following :



[java]

public static void startApp()

{

app.startCanvas();

app.enqueue(new Callable<Void>()

{

public Void call()

{

if (app instanceof SimpleApplication)

{

SimpleApplication simpleApp = (SimpleApplication) app;

simpleApp.getFlyByCamera().setDragToRotate(true);



Nifty nifty;

NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(app.getAssetManager(), app.getInputManager(), app.getAudioRenderer(), app.getGuiViewPort());

nifty = niftyDisplay.getNifty();

app.getGuiViewPort().addProcessor(niftyDisplay);// attach the nifty display to the gui view port as a processor

}

return null;

}

});

}

[/java]