fix [#26478] New image extension is appended to the old one instead of replacing it
authorAndrea Weikert <elubie@gmx.net>
Mon, 14 Mar 2011 21:13:30 +0000 (21:13 +0000)
committerAndrea Weikert <elubie@gmx.net>
Mon, 14 Mar 2011 21:13:30 +0000 (21:13 +0000)
Note:
Extension is replaced with the new extension if it's a known image extension.
Brings back old behaviour, a little bit refined.

source/blender/blenkernel/intern/image.c

index bbcc28629004fd7ac5c3e065d7ebba87e5cbe5a3..f7011daaf0e1f2ae7e387dc7d958bc81da839ef9 100644 (file)
@@ -850,9 +850,15 @@ int BKE_add_image_extension(char *string, int imtype)
 
        if(extension) {
                /* prefer this in many cases to avoid .png.tga, but in certain cases it breaks */
-               /* return BLI_replace_extension(string, FILE_MAX, extension); */
-               strcat(string, extension);
-               return TRUE;
+               /* remove any other known image extension */
+               if(BLI_testextensie_array(string, imb_ext_image)
+                                 || (G.have_quicktime && BLI_testextensie_array(string, imb_ext_image_qt))) {
+                       return BLI_replace_extension(string, FILE_MAX, extension);
+               } else {
+                       strcat(string, extension);
+                       return TRUE;
+               }
+               
        }
        else {
                return FALSE;