[gimp] app: fix file comparison.



commit c04c2d841d4a1828a61e032fd0290a6a00eae85e
Author: Jehan <jehan girinstud io>
Date:   Thu Oct 8 03:20:05 2020 +0200

    app: fix file comparison.
    
    g_list_find_custom() uses a GCompareFunc which has a return value
    similar to strcmp(), i.e. with 0 for equality (and not a boolean, which
    is basically the opposite).

 app/core/gimpextension.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
---
diff --git a/app/core/gimpextension.c b/app/core/gimpextension.c
index 68b19542f1..dfc1674f55 100644
--- a/app/core/gimpextension.c
+++ b/app/core/gimpextension.c
@@ -89,6 +89,8 @@ static void         gimp_extension_get_property    (GObject        *object,
                                                     GParamSpec     *pspec);
 
 static void         gimp_extension_clean           (GimpExtension  *extension);
+static gint         gimp_extension_file_cmp        (GFile          *a,
+                                                    GFile          *b);
 static GList      * gimp_extension_validate_paths  (GimpExtension  *extension,
                                                     const gchar    *paths,
                                                     gboolean        as_directories,
@@ -722,6 +724,20 @@ gimp_extension_clean (GimpExtension  *extension)
   extension->p->theme_paths = NULL;
 }
 
+/**
+ * gimp_extension_file_cmp:
+ * @a:
+ * @b:
+ *
+ * A small g_file_equal() wrapper using GCompareFunc signature.
+ */
+static gint
+gimp_extension_file_cmp (GFile *a,
+                         GFile *b)
+{
+  return g_file_equal (a, b) ? 0 : 1;
+}
+
 /**
  * gimp_extension_validate_paths:
  * @extension: the #GimpExtension
@@ -840,7 +856,7 @@ gimp_extension_validate_paths (GimpExtension  *extension,
         }
 
       g_return_val_if_fail (path != NULL, NULL);
-      if (g_list_find_custom (list, file, (GCompareFunc) g_file_equal))
+      if (g_list_find_custom (list, file, (GCompareFunc) gimp_extension_file_cmp))
         {
           /* Silently ignore duplicate paths. */
           g_object_unref (file);


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