Author: boucman
Date: Sat Mar 19 20:29:54 2011
New Revision: 48934

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

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

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

Modified: branches/1.8/src/display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.8/src/display.cpp?rev=48934&r1=48933&r2=48934&view=diff
==============================================================================
--- branches/1.8/src/display.cpp (original)
+++ branches/1.8/src/display.cpp Sat Mar 19 20:29:54 2011
@@ -51,6 +51,12 @@
 #include <cmath>
 #include <iostream>
 #include <sstream>
+
+// 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)
@@ -139,6 +145,20 @@
        std::fill(reportRects_,reportRects_+reports::NUM_REPORTS,empty_rect);
 
        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()
@@ -1433,8 +1453,20 @@
        SDL_Rect srcrect = dstrect;
        srcrect.x -= dx;
        srcrect.y -= dy;
-       if (!screen_.update_locked())
+       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: branches/1.8/src/display.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.8/src/display.hpp?rev=48934&r1=48933&r2=48934&view=diff
==============================================================================
--- branches/1.8/src/display.hpp (original)
+++ branches/1.8/src/display.hpp Sat Mar 19 20:29:54 2011
@@ -838,6 +838,11 @@
        bool draw_coordinates_;
        /** Debug flag - overlay terrain codes on tiles */
        bool draw_terrain_codes_;
+
+#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