[gegl] operations/workshop/insta-curve: Fix crash while building



commit 7080e5aa86d0c885a9ee307813bddc4e320b0cc5
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Feb 23 02:27:25 2016 +0100

    operations/workshop/insta-curve: Fix crash while building
    
    Even though there is no reason for an application to call
    gegl:insta-curve with the NONE preset, the build does do that which
    triggers the assertion.
    
    Therefore, let's make it work.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=743681

 operations/workshop/insta-curve.c |   36 +++++++++++++++++++++++++++++++++++-
 1 files changed, 35 insertions(+), 1 deletions(-)
---
diff --git a/operations/workshop/insta-curve.c b/operations/workshop/insta-curve.c
index 65ba3bf..c3a9dde 100644
--- a/operations/workshop/insta-curve.c
+++ b/operations/workshop/insta-curve.c
@@ -638,6 +638,10 @@ prepare (GeglOperation *operation)
 
   switch (o->preset)
     {
+    case GEGL_INSTA_CURVE_PRESET_NONE:
+      format = input_format;
+      break;
+
     case GEGL_INSTA_CURVE_PRESET_1977:
       if (type == type_u8)
         {
@@ -690,7 +694,6 @@ prepare (GeglOperation *operation)
         }
       break;
 
-    case GEGL_INSTA_CURVE_PRESET_NONE:
     default:
       g_assert_not_reached ();
     }
@@ -714,6 +717,36 @@ process (GeglOperation       *operation,
   return TRUE;
 }
 
+static gboolean
+operation_process (GeglOperation        *operation,
+                   GeglOperationContext *context,
+                   const gchar          *output_prop,
+                   const GeglRectangle  *result,
+                   gint                  level)
+{
+  GeglOperationClass  *operation_class;
+  GeglProperties *o = GEGL_PROPERTIES (operation);
+
+  operation_class = GEGL_OPERATION_CLASS (gegl_op_parent_class);
+
+  if (o->preset == GEGL_INSTA_CURVE_PRESET_NONE)
+    {
+      gpointer input;
+
+      input = gegl_operation_context_get_object (context, "input");
+      if (input == NULL)
+        {
+          g_warning ("insta-curve received NULL input");
+          return FALSE;
+        }
+
+      gegl_operation_context_take_object (context, "output", g_object_ref (input));
+      return TRUE;
+    }
+
+  return operation_class->process (operation, context, output_prop, result, level);
+}
+
 static void
 gegl_op_class_init (GeglOpClass *klass)
 {
@@ -722,6 +755,7 @@ gegl_op_class_init (GeglOpClass *klass)
     GEGL_OPERATION_POINT_FILTER_CLASS (klass);
 
   operation_class->prepare = prepare;
+  operation_class->process = operation_process;
   operation_class->opencl_support = FALSE;
 
   point_filter_class->process = process;


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