[Tux4kids-commits] r1254 - tuxmath/trunk/src

B. Luchen cheezmeister-guest at alioth.debian.org
Thu Jul 23 00:24:06 UTC 2009


Author: cheezmeister-guest
Date: 2009-07-23 00:24:05 +0000 (Thu, 23 Jul 2009)
New Revision: 1254

Modified:
   tuxmath/trunk/src/loaders.c
Log:
Look for SVG if raster image is requested but not found

Modified: tuxmath/trunk/src/loaders.c
===================================================================
--- tuxmath/trunk/src/loaders.c	2009-07-22 19:39:21 UTC (rev 1253)
+++ tuxmath/trunk/src/loaders.c	2009-07-23 00:24:05 UTC (rev 1254)
@@ -301,7 +301,7 @@
   /* run loader depending on file extension */
 
   /* add path prefix */
-  sprintf(fn, "%s/images/%s", DATA_PREFIX, file_name);
+  snprintf(fn, PATH_MAX, "%s/images/%s", DATA_PREFIX, file_name);
   fn_len = strlen(fn);
 
   if(strcmp(fn + fn_len - 4, ".svg"))
@@ -309,8 +309,14 @@
     DEBUGMSG(debug_loaders, "load_image(): %s is not an SVG, loading using IMG_Load()\n", fn);
     loaded_pic = IMG_Load(fn);
     is_svg = false;
+    if (NULL == loaded_pic)
+    {
+      is_svg = true;
+      DEBUGMSG(debug_loaders, "load_image(): Trying to load SVG equivalent of %s\n", fn);
+      sprintf(strrchr(fn, '.'), ".svg");
+    }
   }
-  else
+  if (is_svg)
   {
 #ifdef HAVE_RSVG
     DEBUGMSG(debug_loaders, "load_image(): trying to load %s as SVG.\n", fn);




More information about the Tux4kids-commits mailing list