kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=2c35a349ea82f0bc2ac410a036a7304b71a1869b

commit 2c35a349ea82f0bc2ac410a036a7304b71a1869b
Author: Kim Woelders <[email protected]>
Date:   Sat Nov 16 17:49:45 2019 +0100

    image.c: Rework some obscure file name stuff in __imlib_SaveImage()
---
 src/lib/image.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/src/lib/image.c b/src/lib/image.c
index 1d0089b..c09b565 100644
--- a/src/lib/image.c
+++ b/src/lib/image.c
@@ -1176,25 +1176,13 @@ __imlib_SaveImage(ImlibImage * im, const char *file,
    /* ok - just check all our loaders are up to date */
    __imlib_RescanLoaders();
 
-   /* set the filename to the saved one */
-   pfile = im->file;
-   im->file = strdup(file);
-
-   if (im->real_file)
-      free(im->real_file);
-
-   im->real_file = strdup(im->file);
-
    /* find the laoder for the format - if its null use the extension */
-   l = __imlib_FindBestLoaderForFileFormat(im->real_file, im->format, 1);
+   l = __imlib_FindBestLoaderForFileFormat(file, im->format, 1);
    /* no loader - abort */
    if (!l)
      {
         if (er)
            *er = IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT;
-        /* set the filename back to the laoder image filename */
-        free(im->file);
-        im->file = pfile;
         return;
      }
 
@@ -1202,12 +1190,16 @@ __imlib_SaveImage(ImlibImage * im, const char *file,
    if (er)
       *er = IMLIB_LOAD_ERROR_NONE;
 
+   /* set the filename to the user supplied one */
+   pfile = im->real_file;
+   im->real_file = strdup(file);
+
    /* call the saver */
    e = l->save(im, progress, progress_granularity);
 
    /* set the filename back to the laoder image filename */
-   free(im->file);
-   im->file = pfile;
+   free(im->real_file);
+   im->real_file = pfile;
 
    /* if there's an error return and the save faile (e = 0) figure it out */
    if ((er) && (e == 0))

-- 


Reply via email to