Commit b315d537 authored by Bob Pendleton's avatar Bob Pendleton

Fixed many valgrind errors. But, I broke testdyngl.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402740
parent 011c8c6d
...@@ -51,9 +51,14 @@ X11_DispatchEvent(_THIS) ...@@ -51,9 +51,14 @@ X11_DispatchEvent(_THIS)
} }
data = NULL; data = NULL;
if (videodata &&
videodata->windowlist) {
for (i = 0; i < videodata->numwindows; ++i) { for (i = 0; i < videodata->numwindows; ++i) {
if (videodata->windowlist[i]->window == xevent.xany.window) { if ((videodata->windowlist[i] != NULL) &&
(videodata->windowlist[i]->window == xevent.xany.window)) {
data = videodata->windowlist[i]; data = videodata->windowlist[i];
break;
}
} }
} }
if (!data) { if (!data) {
......
...@@ -330,7 +330,7 @@ X11_InitKeyboard(_THIS) ...@@ -330,7 +330,7 @@ X11_InitKeyboard(_THIS)
} }
} }
if (j == SDL_arraysize(fingerprint)) { if (j == SDL_arraysize(fingerprint)) {
printf("Using scancode set %d\n", i); /* printf("Using scancode set %d\n", i); */
SDL_memcpy(&data->key_layout[min_keycode], scancode_set[i].table, SDL_memcpy(&data->key_layout[min_keycode], scancode_set[i].table,
sizeof(SDL_scancode) * scancode_set[i].table_size); sizeof(SDL_scancode) * scancode_set[i].table_size);
fingerprint_detected = SDL_TRUE; fingerprint_detected = SDL_TRUE;
......
...@@ -254,7 +254,7 @@ X11_GL_InitExtensions(_THIS) ...@@ -254,7 +254,7 @@ X11_GL_InitExtensions(_THIS)
_this->gl_data->glXDestroyContext(display, context); _this->gl_data->glXDestroyContext(display, context);
} }
XDestroyWindow(display, w); XDestroyWindow(display, w);
/* X11_PumpEvents(_this); */ /* can't do that because the windowlist may be inconsitent at this point */ X11_PumpEvents(_this);
} }
static int static int
......
...@@ -120,14 +120,14 @@ X11_CreateDevice(int devindex) ...@@ -120,14 +120,14 @@ X11_CreateDevice(int devindex)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
if (device) { if (!device) {
data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); SDL_OutOfMemory();
return NULL;
} }
if (!device || !data) { data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
if (!data) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if (device) {
SDL_free(device); SDL_free(device);
}
return NULL; return NULL;
} }
device->driverdata = data; device->driverdata = data;
......
...@@ -35,9 +35,11 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) ...@@ -35,9 +35,11 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
SDL_WindowData *data; SDL_WindowData *data;
int numwindows = videodata->numwindows; int numwindows = videodata->numwindows;
SDL_WindowData **windowlist = videodata->windowlist; SDL_WindowData **windowlist = videodata->windowlist;
int i;
int index;
/* Allocate the window data */ /* Allocate the window data */
data = (SDL_WindowData *) SDL_malloc(sizeof(*data)); data = (SDL_WindowData *) SDL_calloc(1, sizeof(*data));
if (!data) { if (!data) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return -1; return -1;
...@@ -56,6 +58,33 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) ...@@ -56,6 +58,33 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
data->created = created; data->created = created;
data->videodata = videodata; data->videodata = videodata;
/* Associate the data with the window */
index = -1;
if (windowlist) {
for (i = 0; i < numwindows; ++i) {
if (windowlist[i] == NULL) {
index = i;
break;
}
}
}
if (index >= 0) {
windowlist[index] = data;
} else {
windowlist =
(SDL_WindowData **) SDL_realloc(windowlist,
(numwindows + 1) * sizeof(*windowlist));
if (!windowlist) {
SDL_OutOfMemory();
SDL_free(data);
return -1;
}
windowlist[numwindows++] = data;
videodata->numwindows = numwindows;
videodata->windowlist = windowlist;
}
/* Fill in the SDL window with the window data */ /* Fill in the SDL window with the window data */
{ {
XWindowAttributes attrib; XWindowAttributes attrib;
...@@ -458,6 +487,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -458,6 +487,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
} }
#endif #endif
XDestroyWindow(data->display, w); XDestroyWindow(data->display, w);
X11_PumpEvents(_this);
return -1; return -1;
} }
return 0; return 0;
...@@ -625,9 +655,24 @@ void ...@@ -625,9 +655,24 @@ void
X11_DestroyWindow(_THIS, SDL_Window * window) X11_DestroyWindow(_THIS, SDL_Window * window)
{ {
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
window->driverdata = NULL;
if (data) { if (data) {
Display *display = data->videodata->display; SDL_VideoData *videodata = (SDL_VideoData *) data->videodata;
Display *display = videodata->display;
int numwindows = videodata->numwindows;
SDL_WindowData **windowlist = videodata->windowlist;
int i;
if (windowlist) {
for (i = 0; i < numwindows; ++i) {
if (windowlist[i] &&
(windowlist[i]->windowID == window->id)) {
windowlist[i] = NULL;
break;
}
}
}
#ifdef SDL_VIDEO_OPENGL_GLX #ifdef SDL_VIDEO_OPENGL_GLX
if (window->flags & SDL_WINDOW_OPENGL) { if (window->flags & SDL_WINDOW_OPENGL) {
X11_GL_Shutdown(_this); X11_GL_Shutdown(_this);
...@@ -640,9 +685,9 @@ X11_DestroyWindow(_THIS, SDL_Window * window) ...@@ -640,9 +685,9 @@ X11_DestroyWindow(_THIS, SDL_Window * window)
#endif #endif
if (data->created) { if (data->created) {
XDestroyWindow(display, data->window); XDestroyWindow(display, data->window);
X11_PumpEvents(_this);
} }
SDL_free(data); SDL_free(data);
window->driverdata = NULL;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment