projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fixed old and embarrassing memory hole when freeing engine snapshots
[rocksndiamonds.git]
/
src
/
libgame
/
sdl.c
diff --git
a/src/libgame/sdl.c
b/src/libgame/sdl.c
index 2217842e8c8b132e7e17193360b7dcd236de158a..327d20b5be58a33ef9d664a594d4ae13dde4e73d 100644
(file)
--- a/
src/libgame/sdl.c
+++ b/
src/libgame/sdl.c
@@
-198,6
+198,9
@@
boolean SDLSetNativeSurface(SDL_Surface **surface)
new_surface = SDL_ConvertSurface(*surface, backbuffer->surface->format, 0);
new_surface = SDL_ConvertSurface(*surface, backbuffer->surface->format, 0);
+ if (new_surface == NULL)
+ Error(ERR_EXIT, "SDL_ConvertSurface() failed: %s", SDL_GetError());
+
SDL_FreeSurface(*surface);
*surface = new_surface;
SDL_FreeSurface(*surface);
*surface = new_surface;
@@
-207,22
+210,20
@@
boolean SDLSetNativeSurface(SDL_Surface **surface)
SDL_Surface *SDLGetNativeSurface(SDL_Surface *surface)
{
SDL_Surface *SDLGetNativeSurface(SDL_Surface *surface)
{
- if (surface == NULL ||
- backbuffer == NULL ||
-
backbuffer->
surface == NULL)
+ SDL_Surface *new_surface;
+
+
if (
surface == NULL)
return NULL;
return NULL;
- return SDL_ConvertSurface(surface, backbuffer->surface->format, 0);
-}
+ if (backbuffer && backbuffer->surface)
+ new_surface = SDL_ConvertSurface(surface, backbuffer->surface->format, 0);
+ else
+ new_surface = SDL_ConvertSurface(surface, surface->format, 0);
-SDL_Surface *SDL_DisplayFormat(SDL_Surface *surface)
-{
- if (surface == NULL ||
- backbuffer == NULL ||
- backbuffer->surface == NULL)
- return NULL;
+ if (new_surface == NULL)
+ Error(ERR_EXIT, "SDL_ConvertSurface() failed: %s", SDL_GetError());
- return
SDL_ConvertSurface(surface, backbuffer->surface->format, 0)
;
+ return
new_surface
;
}
#else
}
#else
@@
-231,7
+232,9
@@
boolean SDLSetNativeSurface(SDL_Surface **surface)
{
SDL_Surface *new_surface;
{
SDL_Surface *new_surface;
- if (surface == NULL)
+ if (surface == NULL ||
+ *surface == NULL ||
+ !video.initialized)
return FALSE;
new_surface = SDL_DisplayFormat(*surface);
return FALSE;
new_surface = SDL_DisplayFormat(*surface);
@@
-248,10
+251,17
@@
boolean SDLSetNativeSurface(SDL_Surface **surface)
SDL_Surface *SDLGetNativeSurface(SDL_Surface *surface)
{
SDL_Surface *SDLGetNativeSurface(SDL_Surface *surface)
{
- SDL_Surface *new_surface = SDL_DisplayFormat(surface);
+ SDL_Surface *new_surface;
+
+ if (video.initialized)
+ new_surface = SDL_DisplayFormat(surface);
+ else
+ new_surface = SDL_ConvertSurface(surface, surface->format, SURFACE_FLAGS);
if (new_surface == NULL)
if (new_surface == NULL)
- Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError());
+ Error(ERR_EXIT, "%s() failed: %s",
+ (video.initialized ? "SDL_DisplayFormat" : "SDL_ConvertSurface"),
+ SDL_GetError());
return new_surface;
}
return new_surface;
}
@@
-706,9
+716,12
@@
boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen)
SDLRedrawWindow(); // map window
#endif
SDLRedrawWindow(); // map window
#endif
+#ifdef DEBUG
+#if defined(PLATFORM_WIN32)
+ // experimental drag and drop code
+
SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
-#if defined(PLATFORM_WIN32)
{
SDL_SysWMinfo wminfo;
HWND hwnd;
{
SDL_SysWMinfo wminfo;
HWND hwnd;
@@
-733,6
+746,7
@@
boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen)
DragAcceptFiles(hwnd, TRUE);
}
}
DragAcceptFiles(hwnd, TRUE);
}
}
+#endif
#endif
return success;
#endif
return success;
@@
-2363,7
+2377,10
@@
void SDLNextEvent(Event *event)
void SDLHandleWindowManagerEvent(Event *event)
{
void SDLHandleWindowManagerEvent(Event *event)
{
+#ifdef DEBUG
#if defined(PLATFORM_WIN32)
#if defined(PLATFORM_WIN32)
+ // experimental drag and drop code
+
SDL_SysWMEvent *syswmevent = (SDL_SysWMEvent *)event;
SDL_SysWMmsg *syswmmsg = (SDL_SysWMmsg *)(syswmevent->msg);
SDL_SysWMEvent *syswmevent = (SDL_SysWMEvent *)event;
SDL_SysWMmsg *syswmmsg = (SDL_SysWMmsg *)(syswmevent->msg);
@@
-2401,6
+2418,7
@@
void SDLHandleWindowManagerEvent(Event *event)
#endif
}
#endif
#endif
}
#endif
+#endif
}
}