Author: boucman
Date: Sat Mar 19 20:51:23 2011
New Revision: 48935

URL: http://svn.gna.org/viewcvs/wesnoth?rev=48935&view=rev
Log:
fix for bug 17573 : wesnoth unusable on certain comination of glibc and sdl du 
to changes in memcopy

Modified:
    trunk/data/core/about.cfg
    trunk/src/display.cpp
    trunk/src/display.hpp

Modified: trunk/data/core/about.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/core/about.cfg?rev=48935&r1=48934&r2=48935&view=diff
==============================================================================
--- trunk/data/core/about.cfg (original)
+++ trunk/data/core/about.cfg Sat Mar 19 20:51:23 2011
@@ -1084,6 +1084,10 @@
         name = "Priit Laes (plaes)"
     [/entry]
     [entry]
+        name = "Richard Yao (srk9)"
+        comment = "Bug fixes"
+    [/entry]
+    [entry]
         name = "Rocco J Carello (rogue)"
     [/entry]
     [entry]

Modified: trunk/src/display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.cpp?rev=48935&r1=48934&r2=48935&view=diff
==============================================================================
--- trunk/src/display.cpp (original)
+++ trunk/src/display.cpp Sat Mar 19 20:51:23 2011
@@ -44,6 +44,12 @@
 #include <math.h>
 #endif
 #include <cmath>
+
+// Includes for bug #17573
+#if defined(__GLIBC__)
+#include <gnu/libc-version.h> 
+#include <cstdio>
+#endif
 
 static lg::log_domain log_display("display");
 #define ERR_DP LOG_STREAM(err, log_display)
@@ -130,6 +136,20 @@
        set_idle_anim_rate(preferences::idle_anim_rate());
 
        image::set_zoom(zoom_);
+
+#if defined(__GLIBC__)
+       // Runtime checks for bug #17573
+       // Get glibc runtime version information
+       int glibc, glibc_minor; 
+       sscanf(gnu_get_libc_version(), "%d.%d", &glibc, &glibc_minor);
+
+       // Get SDL runtime version information
+       const SDL_version* v = SDL_Linked_Version();
+
+       do_reverse_memcpy_workaround_ = (glibc > 2 || (glibc == 2 && 
glibc_minor >= 13)) &&
+               (v->major < 1 || (v->major == 1 && v->minor < 2) || 
+                       (v->major == 1 && v->minor == 2 && v->patch < 15) );
+#endif
 }
 
 display::~display()
@@ -1449,8 +1469,20 @@
        SDL_Rect srcrect = dstrect;
        srcrect.x -= dx;
        srcrect.y -= dy;
-       if (!screen_.update_locked())
-               sdl_blit(screen,&srcrect,screen,&dstrect);
+       if (!screen_.update_locked()) {
+
+// Hack to workaround bug #17573
+#if defined(__GLIBC__)
+               if (do_reverse_memcpy_workaround_) {
+                       surface screen_copy = make_neutral_surface(screen);
+                       SDL_BlitSurface(screen_copy,&srcrect,screen,&dstrect);
+               } else {
+                       SDL_BlitSurface(screen,&srcrect,screen,&dstrect);
+               }
+#else 
+               SDL_BlitSurface(screen,&srcrect,screen,&dstrect);
+#endif
+       }
 
 //This is necessary to avoid a crash in some SDL versions on some systems
 //see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=462794

Modified: trunk/src/display.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.hpp?rev=48935&r1=48934&r2=48935&view=diff
==============================================================================
--- trunk/src/display.hpp (original)
+++ trunk/src/display.hpp Sat Mar 19 20:51:23 2011
@@ -834,6 +834,11 @@
        typedef std::map<map_location, arrows_list_t > arrows_map_t;
        /** Maps the list of arrows for each location */
        arrows_map_t arrows_map_;
+
+#if defined(__GLIBC__)
+       /** Flag for bug #17573 - this is set in the constructor **/
+       bool do_reverse_memcpy_workaround_;
+#endif
 };
 
 #endif


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to