Linux: Fix context NULL'ed before free'ing

This commit is contained in:
Elias Naur 2004-07-22 08:52:25 +00:00
parent 19f32b3d63
commit a1642b0dcf
2 changed files with 12 additions and 9 deletions

View File

@ -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) { static bool setMode(Display *disp, int screen, int width, int height, bool lock_mode) {
int num_modes, i; int num_modes, i;
XF86VidModeModeInfo **avail_modes; XF86VidModeModeInfo **avail_modes;
if (!getDisplayModes(disp, screen, &num_modes, &avail_modes)) { if (!getDisplayModes(disp, screen, &num_modes, &avail_modes)) {
printfDebug("Could not get display modes\n"); printfDebug("Could not get display modes\n");
return false; return false;
@ -191,6 +191,7 @@ void switchDisplayMode(JNIEnv * env, jobject mode) {
void resetDisplayMode(JNIEnv *env) { void resetDisplayMode(JNIEnv *env) {
int screen; int screen;
Display *disp = XOpenDisplay(NULL); Display *disp = XOpenDisplay(NULL);
// Display *disp = incDisplay(env);
if (disp == NULL) if (disp == NULL)
return; return;
screen = DefaultScreen(disp); screen = DefaultScreen(disp);
@ -201,6 +202,7 @@ void resetDisplayMode(JNIEnv *env) {
XF86VidModeSetGammaRamp(disp, screen, gamma_ramp_length, r_ramp, g_ramp, b_ramp); XF86VidModeSetGammaRamp(disp, screen, gamma_ramp_length, r_ramp, g_ramp, b_ramp);
freeSavedGammaRamps(); freeSavedGammaRamps();
} }
// decDisplay();
XCloseDisplay(disp); XCloseDisplay(disp);
} }

View File

@ -39,7 +39,6 @@
* @version $Revision$ * @version $Revision$
*/ */
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
@ -59,8 +58,8 @@
static GLXContext context = NULL; // OpenGL rendering context static GLXContext context = NULL; // OpenGL rendering context
static GLXWindow glx_window; static GLXWindow glx_window;
static XVisualInfo * vis_info; static XVisualInfo *vis_info = NULL;
static GLXFBConfig *configs; static GLXFBConfig *configs = NULL;
static Atom delete_atom; static Atom delete_atom;
static Colormap cmap; static Colormap cmap;
@ -87,11 +86,11 @@ static char error_message[ERR_MSG_SIZE];
static Atom warp_atom; static Atom warp_atom;
Atom getWarpAtom(void) { Atom getWarpAtom(void) {
return warp_atom; return warp_atom;
} }
int getCurrentScreen(void) { int getCurrentScreen(void) {
return current_screen; return current_screen;
} }
bool checkXError(JNIEnv *env) { bool checkXError(JNIEnv *env) {
@ -273,7 +272,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_nSetTitle
env->ReleaseStringUTFChars(title_obj, title); env->ReleaseStringUTFChars(title_obj, title);
} }
static void destroyWindow() { static void destroyWindow(void) {
setRepeatMode(AutoRepeatModeDefault); setRepeatMode(AutoRepeatModeDefault);
XDestroyWindow(getDisplay(), current_win); XDestroyWindow(getDisplay(), current_win);
XFreeColormap(getDisplay(), cmap); XFreeColormap(getDisplay(), cmap);
@ -517,13 +516,15 @@ static void dumpVisualInfo(XVisualInfo *vis_info) {
static void destroyContext(void) { static void destroyContext(void) {
releaseContext(); releaseContext();
context = NULL;
if (USEGLX13) { if (USEGLX13) {
glXDestroyWindow(getDisplay(), glx_window); glXDestroyWindow(getDisplay(), glx_window);
XFree(configs); XFree(configs);
configs = NULL;
} }
XFree(vis_info); XFree(vis_info);
vis_info = NULL;
glXDestroyContext(getDisplay(), context); glXDestroyContext(getDisplay(), context);
context = NULL;
} }
static bool initWindowGLX13(JNIEnv *env, jobject pixel_format) { static bool initWindowGLX13(JNIEnv *env, jobject pixel_format) {