LWJGL 3 - NullPointerException - MemoryUtil.memGlobalRefToObject

Started by h1, September 06, 2015, 10:20:21

Previous topic - Next topic

h1

After closing two windows in a row, the next Window which opens throws the following NullPointerException:
java.lang.NullPointerException
	at org.lwjgl.system.MemoryUtil.memGlobalRefToObject(Native Method)
	at org.lwjgl.system.libffi.Closure.create(Closure.java:195)
	at org.lwjgl.glfw.GLFW.glfwSetErrorCallback(GLFW.java:554)


on opening a window i set up all the glfw stuff and the callbacks like this:
glfwSetErrorCallback(errorCallback = errorCallbackPrint(System.err));


on close i only release all my callbacks as follows:
    public void onStop() {
        errorCallback.release();
        keyCallback.release();
        mouseButtonCallback.release();
        cursorPosCallback.release();
        scrollCallback.release();
        windowCloseCallback.release();
        windowSizeCallback.release();

        glfwDestroyWindow(window);
    }


It seemed that I solved this issue by simply not releasing the errorCallback in my onStop method:
    public void onStop() {
        //errorCallback.release();
        keyCallback.release();
        mouseButtonCallback.release();
        cursorPosCallback.release();
        scrollCallback.release();
        windowCloseCallback.release();
        windowSizeCallback.release();

        glfwDestroyWindow(window);
    }


Could anyone explain this to me or is this a bug?

FortressBuilder

The error callback is global and not per window, so you should only set it at the beginning and release it at the end of the program instead of every time a window is created or destroyed.