From a1642b0dcfdb2f162d11490c5d4e545aaa59ff94 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Thu, 22 Jul 2004 08:52:25 +0000 Subject: [PATCH] Linux: Fix context NULL'ed before free'ing --- src/native/linux/display.cpp | 6 ++++-- src/native/linux/org_lwjgl_opengl_Display.cpp | 15 ++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/native/linux/display.cpp b/src/native/linux/display.cpp index fc3e1f46..23db29ae 100644 --- a/src/native/linux/display.cpp +++ b/src/native/linux/display.cpp @@ -81,8 +81,8 @@ static bool getDisplayModes(Display *disp, int screen, int *num_modes, XF86VidMo } static bool setMode(Display *disp, int screen, int width, int height, bool lock_mode) { - int num_modes, i; - XF86VidModeModeInfo **avail_modes; + int num_modes, i; + XF86VidModeModeInfo **avail_modes; if (!getDisplayModes(disp, screen, &num_modes, &avail_modes)) { printfDebug("Could not get display modes\n"); return false; @@ -191,6 +191,7 @@ void switchDisplayMode(JNIEnv * env, jobject mode) { void resetDisplayMode(JNIEnv *env) { int screen; Display *disp = XOpenDisplay(NULL); +// Display *disp = incDisplay(env); if (disp == NULL) return; screen = DefaultScreen(disp); @@ -201,6 +202,7 @@ void resetDisplayMode(JNIEnv *env) { XF86VidModeSetGammaRamp(disp, screen, gamma_ramp_length, r_ramp, g_ramp, b_ramp); freeSavedGammaRamps(); } +// decDisplay(); XCloseDisplay(disp); } diff --git a/src/native/linux/org_lwjgl_opengl_Display.cpp b/src/native/linux/org_lwjgl_opengl_Display.cpp index ef2408d0..cdb6e6f7 100644 --- a/src/native/linux/org_lwjgl_opengl_Display.cpp +++ b/src/native/linux/org_lwjgl_opengl_Display.cpp @@ -39,7 +39,6 @@ * @version $Revision$ */ - #include #include #include @@ -59,8 +58,8 @@ static GLXContext context = NULL; // OpenGL rendering context static GLXWindow glx_window; -static XVisualInfo * vis_info; -static GLXFBConfig *configs; +static XVisualInfo *vis_info = NULL; +static GLXFBConfig *configs = NULL; static Atom delete_atom; static Colormap cmap; @@ -87,11 +86,11 @@ static char error_message[ERR_MSG_SIZE]; static Atom warp_atom; Atom getWarpAtom(void) { - return warp_atom; + return warp_atom; } int getCurrentScreen(void) { - return current_screen; + return current_screen; } bool checkXError(JNIEnv *env) { @@ -273,7 +272,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_nSetTitle env->ReleaseStringUTFChars(title_obj, title); } -static void destroyWindow() { +static void destroyWindow(void) { setRepeatMode(AutoRepeatModeDefault); XDestroyWindow(getDisplay(), current_win); XFreeColormap(getDisplay(), cmap); @@ -517,13 +516,15 @@ static void dumpVisualInfo(XVisualInfo *vis_info) { static void destroyContext(void) { releaseContext(); - context = NULL; if (USEGLX13) { glXDestroyWindow(getDisplay(), glx_window); XFree(configs); + configs = NULL; } XFree(vis_info); + vis_info = NULL; glXDestroyContext(getDisplay(), context); + context = NULL; } static bool initWindowGLX13(JNIEnv *env, jobject pixel_format) {