[gthumb] file chooser: correctly get the filename extension



commit fbbbb90cdc25d1b9bf90f90a74ede1e3b3d375bf
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sat Apr 17 12:34:43 2021 +0200

    file chooser: correctly get the filename extension
    
    Do not use _g_uri_get_extension on a local path, use
    _g_path_get_extension instead.

 gthumb/gth-file-chooser-dialog.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
---
diff --git a/gthumb/gth-file-chooser-dialog.c b/gthumb/gth-file-chooser-dialog.c
index dc1de5a7..013244c8 100644
--- a/gthumb/gth-file-chooser-dialog.c
+++ b/gthumb/gth-file-chooser-dialog.c
@@ -219,11 +219,11 @@ static Format *
 get_format_from_extension (GthFileChooserDialog *self,
                           const char           *filename)
 {
-       char       *ext;
+       const char *ext;
        const char *only_ext;
        GList      *scan;
 
-       ext = _g_uri_get_extension (filename);
+       ext = _g_path_get_extension (filename);
        if (ext == NULL)
                return NULL;
 
@@ -234,14 +234,10 @@ get_format_from_extension (GthFileChooserDialog *self,
                int     i;
 
                for (i = 0; format->extensions[i] != NULL; i++)
-                       if (g_ascii_strcasecmp (only_ext, format->extensions[i]) == 0) {
-                               g_free (ext);
+                       if (g_ascii_strcasecmp (only_ext, format->extensions[i]) == 0)
                                return format;
-                       }
        }
 
-       g_free (ext);
-
        return NULL;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]