[gegl] gegl-processor: More handling of sink operations without an input



commit 3acec72ea5abc81cb29da12ac5c94c297f78b5ac
Author: Barak Itkin <lightningismyname gmail com>
Date:   Wed Aug 17 00:50:19 2011 +0300

    gegl-processor: More handling of sink operations without an input
    
    In case of a sink operation which has no input, upon the creation of
    the processor a critical error will be logged to assist debugging. Also
    functions that depend on the input being not NULL, will now exit with
    the apropriate value (and will log an error).

 gegl/process/gegl-processor.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/gegl/process/gegl-processor.c b/gegl/process/gegl-processor.c
index 08c42a8..6f377ef 100644
--- a/gegl/process/gegl-processor.c
+++ b/gegl/process/gegl-processor.c
@@ -264,6 +264,14 @@ gegl_processor_set_node (GeglProcessor *processor,
                    GEGL_TYPE_OPERATION_SINK))
     {
       processor->input = gegl_node_get_producer (processor->node, "input", NULL);
+
+      if (processor->input == NULL)
+        {
+          g_critical ("Prepared to process a sink operation, but it "
+                      "had no \"input\" pad connected!");
+          return;
+        }
+
       if (!gegl_operation_sink_needs_full (processor->node->operation))
         {
           processor->valid_region = gegl_region_new ();
@@ -281,7 +289,7 @@ gegl_processor_set_node (GeglProcessor *processor,
       processor->valid_region = NULL;
     }
 
-  g_return_if_fail (processor->input);
+  g_return_if_fail (processor->input != NULL);
 
   g_object_ref (processor->input);
 
@@ -303,6 +311,8 @@ gegl_processor_set_rectangle (GeglProcessor       *processor,
   GSList        *iter;
   GeglRectangle  input_bounding_box;
 
+  g_return_if_fail (processor->input != NULL);
+
   if (! rectangle)
     {
       input_bounding_box = gegl_node_get_bounding_box (processor->input);
@@ -461,7 +471,7 @@ render_rectangle (GeglProcessor *processor)
 
           return TRUE;
         }
-	
+
       if (buffered)
         {
           /* only do work if the rectangle is not completely inside the valid
@@ -565,6 +575,8 @@ gegl_processor_progress (GeglProcessor *processor)
   gint        wanted;
   gdouble     ret;
 
+  g_return_val_if_fail (processor->input != NULL, 1);
+
   if (processor->valid_region)
     {
       valid_region = processor->valid_region;



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