[gegl] gegl: check that the fallback of operation handlers exist.



commit 5d42b16d5ac5d5479adc589aba417c749be76e48
Author: Jehan <jehan girinstud io>
Date:   Fri Jan 7 22:08:36 2022 +0100

    gegl: check that the fallback of operation handlers exist.
    
    The loader fallback in particular is "gegl:magick-load" which depends on
    a runtime tool (`convert` from Image Magick) so gegl_has_operation()
    would verify that the operation is actually available at runtime (since
    previous commit). If unavailable, let's just raise a warning and not
    call the fallback, which is better than calling it and raising weird
    unavoidable errors.

 gegl/operation/gegl-operation-handlers.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/gegl/operation/gegl-operation-handlers.c b/gegl/operation/gegl-operation-handlers.c
index f347290b9..ea664db65 100644
--- a/gegl/operation/gegl-operation-handlers.c
+++ b/gegl/operation/gegl-operation-handlers.c
@@ -20,6 +20,7 @@
 #include "config.h"
 #include <glib.h>
 
+#include "gegl.h"
 #include "gegl-operation-handlers.h"
 #include "gegl-operation-handlers-private.h"
 
@@ -92,10 +93,27 @@ gegl_operation_handlers_get_util (GHashTable *handlers,
   if (handler != NULL)
     return handler;
 
-  g_warning ("No %s for content type \"%s\", falling back to \"%s\"",
-             handler_type, content_type, fallback);
+  if (fallback)
+    {
+      if (gegl_has_operation (fallback))
+        {
+          g_warning ("No %s for content type \"%s\", falling back to \"%s\"",
+                     handler_type, content_type, fallback);
+          return fallback;
+        }
+      else
+        {
+          g_warning ("No %s for content type \"%s\". Fallback \"%s\" is not available.",
+                     handler_type, content_type, fallback);
+        }
+    }
+  else
+    {
+      g_warning ("No %s for content type \"%s\"",
+                 handler_type, content_type);
+    }
 
-  return fallback;
+  return NULL;
 }
 
 const gchar *


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