Package: dgen / 1.23-12

sdl-segfault.diff Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Description: It solves sdl struct that causes a segfault on OpenGL
Author: Trevour Crow <bio_tube@yahoo.com>
--- a/sdl/sdl.cpp
+++ b/sdl/sdl.cpp
@@ -457,6 +457,9 @@
   
   // If you need to do any sort of locking before writing to the buffer, do so
   // here.
+#ifdef SDL_OPENGL_SUPPORT
+	if(!opengl) /*Don't do this in OpenGL mode; it crashes the emu*/
+#endif
   if(SDL_MUSTLOCK(screen))
     SDL_LockSurface(screen);
   
@@ -597,6 +600,9 @@
       q += mdscr.pitch;
     }
   // Unlock when you're done!
+#ifdef SDL_OPENGL_SUPPORT
+	if(!opengl)
+#endif
   if(SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen);
   // Update the screen
 #ifdef SDL_OPENGL_SUPPORT
@@ -917,6 +923,9 @@
 #ifdef HAVE_SDL_WM_TOGGLEFULLSCREEN
 	    int fullscreen = 0;
 	    // Switch out of fullscreen mode (assuming this is supported)
+#ifdef SDL_OPENGL_SUPPORT
+	if(!opengl)
+#endif
 	    if(screen->flags & SDL_FULLSCREEN) {
 	      fullscreen = 1;
 	      SDL_WM_ToggleFullScreen(screen);
@@ -1085,7 +1094,6 @@
 inline void pd_clear_message()
 {
   int i, j;
-  long *p = (long*)((char*)screen->pixels + (screen->pitch * ys));
 #ifdef SDL_OPENGL_SUPPORT
   if(opengl)
     {
@@ -1096,6 +1104,9 @@
   else
     {
 #endif
+	/*This line causes the problems in OpenGL mode, so we put it here*/
+	/*This is actually makes more sense, since it's not used up there*/
+	long *p = (long *)((char *)screen->pixels + (screen->pitch * ys));
       for(i = 0; i < 16; ++i, p += (screen->pitch >> 2))
         for(j = 0; j < 80 * screen->format->BytesPerPixel; ++j)
           p[j] = 0;