[gimp] app: all remaining g_assert() replaced by critical warning and return...



commit 4c2df9b36542fbb8cc04c6ae2bee59aec2ab8ad5
Author: Jehan <jehan girinstud io>
Date:   Mon Jan 22 15:55:47 2018 +0100

    app: all remaining g_assert() replaced by critical warning and return...
    
    ... in app/core.
    Continuing on my crusade against asserting and crashing GIMP.

 app/core/gimp-internal-data.c        |    4 ++--
 app/core/gimp-utils.c                |    2 +-
 app/core/gimpbrushcache.c            |    2 +-
 app/core/gimpbrushclipboard.c        |    2 +-
 app/core/gimpbrushpipe-load.c        |    2 +-
 app/core/gimpchannelpropundo.c       |    2 +-
 app/core/gimpchannelundo.c           |    2 +-
 app/core/gimpcontext.c               |    2 +-
 app/core/gimpdrawable-transform.c    |   18 +++++++++++++++---
 app/core/gimpdrawablemodundo.c       |    2 +-
 app/core/gimpdrawablestack.c         |    4 ++--
 app/core/gimpdrawableundo.c          |    4 ++--
 app/core/gimpfilteredcontainer.c     |    2 +-
 app/core/gimpfilterstack.c           |    4 ++--
 app/core/gimpfloatingselectionundo.c |    2 +-
 app/core/gimpgrouplayerundo.c        |    2 +-
 app/core/gimpguideundo.c             |    2 +-
 app/core/gimpimage-convert-indexed.c |   12 ++++++------
 app/core/gimpimage.c                 |    2 +-
 app/core/gimpimageundo.c             |    4 ++--
 app/core/gimpitem.c                  |    4 ++--
 app/core/gimpitempropundo.c          |    2 +-
 app/core/gimpitemstack.c             |    4 ++--
 app/core/gimpitemtree.c              |    8 ++++----
 app/core/gimpitemundo.c              |    2 +-
 app/core/gimplayermaskpropundo.c     |    2 +-
 app/core/gimplayermaskundo.c         |    4 ++--
 app/core/gimplayerpropundo.c         |    2 +-
 app/core/gimplayerstack.c            |    6 +++---
 app/core/gimplayerundo.c             |    2 +-
 app/core/gimpmaskundo.c              |    2 +-
 app/core/gimppatternclipboard.c      |    2 +-
 app/core/gimppdbprogress.c           |    4 ++--
 app/core/gimpsamplepointundo.c       |    2 +-
 app/core/gimptoolpreset.c            |    2 +-
 app/core/gimpundo.c                  |    2 +-
 36 files changed, 69 insertions(+), 57 deletions(-)
---
diff --git a/app/core/gimp-internal-data.c b/app/core/gimp-internal-data.c
index 0a27588..7417c00 100644
--- a/app/core/gimp-internal-data.c
+++ b/app/core/gimp-internal-data.c
@@ -270,10 +270,10 @@ gimp_internal_data_save_data_file (Gimp                        *gimp,
    *
    * FIXME:  we save the data whether it's dirty or not, since it might not
    * exist on disk.  currently, we only use this for cheap data, such as
-   * gradients, so this is not a big concern, but if we save more expensive 
+   * gradients, so this is not a big concern, but if we save more expensive
    * data in the future, we should fix this.
    */
-  g_assert (GIMP_DATA_GET_CLASS (data)->save);
+  g_return_val_if_fail (GIMP_DATA_GET_CLASS (data)->save, FALSE);
   success = GIMP_DATA_GET_CLASS (data)->save (data, output, error);
 
   g_object_unref (output);
diff --git a/app/core/gimp-utils.c b/app/core/gimp-utils.c
index 836db20..99b8c7a 100644
--- a/app/core/gimp-utils.c
+++ b/app/core/gimp-utils.c
@@ -461,7 +461,7 @@ unescape_gstring (GString *string)
         }
     }
 
-  g_assert (to - string->str <= string->len);
+  g_return_val_if_fail (to - string->str <= string->len, FALSE);
   if (to - string->str != string->len)
     g_string_truncate (string, to - string->str);
 
diff --git a/app/core/gimpbrushcache.c b/app/core/gimpbrushcache.c
index ab7677a..9badcc9 100644
--- a/app/core/gimpbrushcache.c
+++ b/app/core/gimpbrushcache.c
@@ -103,7 +103,7 @@ gimp_brush_cache_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (cache->data_destroy != NULL);
+  g_return_if_fail (cache->data_destroy != NULL);
 }
 
 static void
diff --git a/app/core/gimpbrushclipboard.c b/app/core/gimpbrushclipboard.c
index 13574f7..cda04c9 100644
--- a/app/core/gimpbrushclipboard.c
+++ b/app/core/gimpbrushclipboard.c
@@ -111,7 +111,7 @@ gimp_brush_clipboard_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (GIMP_IS_GIMP (brush->gimp));
+  g_return_if_fail (GIMP_IS_GIMP (brush->gimp));
 
   g_signal_connect_object (brush->gimp, "clipboard-changed",
                            G_CALLBACK (gimp_brush_clipboard_changed),
diff --git a/app/core/gimpbrushpipe-load.c b/app/core/gimpbrushpipe-load.c
index 6b85496..cecabe0 100644
--- a/app/core/gimpbrushpipe-load.c
+++ b/app/core/gimpbrushpipe-load.c
@@ -185,7 +185,7 @@ gimp_brush_pipe_load (GimpContext   *context,
       else
         pipe->stride[i] = pipe->stride[i-1] / pipe->rank[i];
     }
-  g_assert (pipe->stride[pipe->dimension-1] == 1);
+  g_return_val_if_fail (pipe->stride[pipe->dimension-1] == 1, NULL);
 
   pipe->brushes = g_new0 (GimpBrush *, num_of_brushes);
 
diff --git a/app/core/gimpchannelpropundo.c b/app/core/gimpchannelpropundo.c
index 0de3809..5e846a9 100644
--- a/app/core/gimpchannelpropundo.c
+++ b/app/core/gimpchannelpropundo.c
@@ -65,7 +65,7 @@ gimp_channel_prop_undo_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (GIMP_IS_CHANNEL (GIMP_ITEM_UNDO (object)->item));
+  g_return_if_fail (GIMP_IS_CHANNEL (GIMP_ITEM_UNDO (object)->item));
 
   channel = GIMP_CHANNEL (GIMP_ITEM_UNDO (object)->item);
 
diff --git a/app/core/gimpchannelundo.c b/app/core/gimpchannelundo.c
index b9fc165..ecdc521 100644
--- a/app/core/gimpchannelundo.c
+++ b/app/core/gimpchannelundo.c
@@ -106,7 +106,7 @@ gimp_channel_undo_constructed (GObject *object)
 {
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (GIMP_IS_CHANNEL (GIMP_ITEM_UNDO (object)->item));
+  g_return_if_fail (GIMP_IS_CHANNEL (GIMP_ITEM_UNDO (object)->item));
 }
 
 static void
diff --git a/app/core/gimpcontext.c b/app/core/gimpcontext.c
index 89b5f81..27c9081 100644
--- a/app/core/gimpcontext.c
+++ b/app/core/gimpcontext.c
@@ -846,7 +846,7 @@ gimp_context_constructed (GObject *object)
 
   gimp = GIMP_CONTEXT (object)->gimp;
 
-  g_assert (GIMP_IS_GIMP (gimp));
+  g_return_if_fail (GIMP_IS_GIMP (gimp));
 
   gimp->context_list = g_list_prepend (gimp->context_list, object);
 
diff --git a/app/core/gimpdrawable-transform.c b/app/core/gimpdrawable-transform.c
index 00fe4cd..fb2e654 100644
--- a/app/core/gimpdrawable-transform.c
+++ b/app/core/gimpdrawable-transform.c
@@ -555,7 +555,11 @@ gimp_drawable_transform_buffer_rotate (GimpDrawable      *drawable,
         guchar *buf = g_new (guchar, new_height * orig_bpp);
         gint    i;
 
-        g_assert (new_height == orig_width);
+        /* Not cool, we leak memory if we return, but anyway that is
+         * never supposed to happen. If we see this warning, a bug has
+         * to be fixed!
+         */
+        g_return_val_if_fail (new_height == orig_width, NULL);
 
         src_rect.y      = orig_y + orig_height - 1;
         src_rect.height = 1;
@@ -583,7 +587,11 @@ gimp_drawable_transform_buffer_rotate (GimpDrawable      *drawable,
         guchar *buf = g_new (guchar, new_width * orig_bpp);
         gint    i, j, k;
 
-        g_assert (new_width == orig_width);
+        /* Not cool, we leak memory if we return, but anyway that is
+         * never supposed to happen. If we see this warning, a bug has
+         * to be fixed!
+         */
+        g_return_val_if_fail (new_width == orig_width, NULL);
 
         src_rect.y      = orig_y + orig_height - 1;
         src_rect.height = 1;
@@ -625,7 +633,11 @@ gimp_drawable_transform_buffer_rotate (GimpDrawable      *drawable,
         guchar *buf = g_new (guchar, new_width * orig_bpp);
         gint    i;
 
-        g_assert (new_width == orig_height);
+        /* Not cool, we leak memory if we return, but anyway that is
+         * never supposed to happen. If we see this warning, a bug has
+         * to be fixed!
+         */
+        g_return_val_if_fail (new_width == orig_height, NULL);
 
         src_rect.x     = orig_x + orig_width - 1;
         src_rect.width = 1;
diff --git a/app/core/gimpdrawablemodundo.c b/app/core/gimpdrawablemodundo.c
index 393e310..349835d 100644
--- a/app/core/gimpdrawablemodundo.c
+++ b/app/core/gimpdrawablemodundo.c
@@ -100,7 +100,7 @@ gimp_drawable_mod_undo_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (GIMP_IS_DRAWABLE (GIMP_ITEM_UNDO (object)->item));
+  g_return_if_fail (GIMP_IS_DRAWABLE (GIMP_ITEM_UNDO (object)->item));
 
   item     = GIMP_ITEM_UNDO (object)->item;
   drawable = GIMP_DRAWABLE (item);
diff --git a/app/core/gimpdrawablestack.c b/app/core/gimpdrawablestack.c
index 03b271b..b2083e9 100644
--- a/app/core/gimpdrawablestack.c
+++ b/app/core/gimpdrawablestack.c
@@ -104,8 +104,8 @@ gimp_drawable_stack_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (g_type_is_a (gimp_container_get_children_type (container),
-                         GIMP_TYPE_DRAWABLE));
+  g_return_if_fail (g_type_is_a (gimp_container_get_children_type (container),
+                                 GIMP_TYPE_DRAWABLE));
 
   gimp_container_add_handler (container, "update",
                               G_CALLBACK (gimp_drawable_stack_drawable_update),
diff --git a/app/core/gimpdrawableundo.c b/app/core/gimpdrawableundo.c
index a2ac359..23b1724 100644
--- a/app/core/gimpdrawableundo.c
+++ b/app/core/gimpdrawableundo.c
@@ -111,8 +111,8 @@ gimp_drawable_undo_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (GIMP_IS_DRAWABLE (GIMP_ITEM_UNDO (object)->item));
-  g_assert (GEGL_IS_BUFFER (drawable_undo->buffer));
+  g_return_if_fail (GIMP_IS_DRAWABLE (GIMP_ITEM_UNDO (object)->item));
+  g_return_if_fail (GEGL_IS_BUFFER (drawable_undo->buffer));
 }
 
 static void
diff --git a/app/core/gimpfilteredcontainer.c b/app/core/gimpfilteredcontainer.c
index 78e5c71..6135c7a 100644
--- a/app/core/gimpfilteredcontainer.c
+++ b/app/core/gimpfilteredcontainer.c
@@ -124,7 +124,7 @@ gimp_filtered_container_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (GIMP_IS_CONTAINER (filtered_container->src_container));
+  g_return_if_fail (GIMP_IS_CONTAINER (filtered_container->src_container));
 
   if (! gimp_container_frozen (filtered_container->src_container))
     {
diff --git a/app/core/gimpfilterstack.c b/app/core/gimpfilterstack.c
index b3e5835..cb4a1c7 100644
--- a/app/core/gimpfilterstack.c
+++ b/app/core/gimpfilterstack.c
@@ -83,8 +83,8 @@ gimp_filter_stack_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (g_type_is_a (gimp_container_get_children_type (container),
-                         GIMP_TYPE_FILTER));
+  g_return_if_fail (g_type_is_a (gimp_container_get_children_type (container),
+                                 GIMP_TYPE_FILTER));
 
   gimp_container_add_handler (container, "active-changed",
                               G_CALLBACK (gimp_filter_stack_filter_active),
diff --git a/app/core/gimpfloatingselectionundo.c b/app/core/gimpfloatingselectionundo.c
index 34fff94..9c552c7 100644
--- a/app/core/gimpfloatingselectionundo.c
+++ b/app/core/gimpfloatingselectionundo.c
@@ -68,7 +68,7 @@ gimp_floating_selection_undo_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (GIMP_IS_LAYER (GIMP_ITEM_UNDO (object)->item));
+  g_return_if_fail (GIMP_IS_LAYER (GIMP_ITEM_UNDO (object)->item));
 
   layer = GIMP_LAYER (GIMP_ITEM_UNDO (object)->item);
 
diff --git a/app/core/gimpgrouplayerundo.c b/app/core/gimpgrouplayerundo.c
index 8287dca..6c30c04 100644
--- a/app/core/gimpgrouplayerundo.c
+++ b/app/core/gimpgrouplayerundo.c
@@ -63,7 +63,7 @@ gimp_group_layer_undo_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (GIMP_IS_GROUP_LAYER (GIMP_ITEM_UNDO (object)->item));
+  g_return_if_fail (GIMP_IS_GROUP_LAYER (GIMP_ITEM_UNDO (object)->item));
 
   group = GIMP_GROUP_LAYER (GIMP_ITEM_UNDO (object)->item);
 
diff --git a/app/core/gimpguideundo.c b/app/core/gimpguideundo.c
index 8d2f077..ee17498 100644
--- a/app/core/gimpguideundo.c
+++ b/app/core/gimpguideundo.c
@@ -89,7 +89,7 @@ gimp_guide_undo_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (GIMP_IS_GUIDE (guide_undo->guide));
+  g_return_if_fail (GIMP_IS_GUIDE (guide_undo->guide));
 
   guide_undo->orientation = gimp_guide_get_orientation (guide_undo->guide);
   guide_undo->position    = gimp_guide_get_position (guide_undo->guide);
diff --git a/app/core/gimpimage-convert-indexed.c b/app/core/gimpimage-convert-indexed.c
index abe75c1..e3ba739 100644
--- a/app/core/gimpimage-convert-indexed.c
+++ b/app/core/gimpimage-convert-indexed.c
@@ -2015,22 +2015,22 @@ median_cut_rgb (CFHistogram   histogram,
           lb = b1->Rhalferror;/* *0 + (b1->Rmax + b1->Rmin) / 2; */
           b1->Rmax = lb;
           b2->Rmin = lb+1;
-          g_assert (b1->Rmax >= b1->Rmin);
-          g_assert (b2->Rmax >= b2->Rmin);
+          g_return_val_if_fail (b1->Rmax >= b1->Rmin, numboxes);
+          g_return_val_if_fail (b2->Rmax >= b2->Rmin, numboxes);
           break;
         case AXIS_GREEN:
           lb = b1->Ghalferror;/* *0 + (b1->Gmax + b1->Gmin) / 2; */
           b1->Gmax = lb;
           b2->Gmin = lb+1;
-          g_assert (b1->Gmax >= b1->Gmin);
-          g_assert (b2->Gmax >= b2->Gmin);
+          g_return_val_if_fail (b1->Gmax >= b1->Gmin, numboxes);
+          g_return_val_if_fail (b2->Gmax >= b2->Gmin, numboxes);
           break;
         case AXIS_BLUE:
           lb = b1->Bhalferror;/* *0 + (b1->Bmax + b1->Bmin) / 2; */
           b1->Bmax = lb;
           b2->Bmin = lb+1;
-          g_assert (b1->Bmax >= b1->Bmin);
-          g_assert (b2->Bmax >= b2->Bmin);
+          g_return_val_if_fail (b1->Bmax >= b1->Bmin, numboxes);
+          g_return_val_if_fail (b2->Bmax >= b2->Bmin, numboxes);
           break;
         default:
           g_error ("Uh-oh.");
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 1818ca1..77245f9 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -818,7 +818,7 @@ gimp_image_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (GIMP_IS_GIMP (image->gimp));
+  g_return_if_fail (GIMP_IS_GIMP (image->gimp));
 
   config = image->gimp->config;
 
diff --git a/app/core/gimpimageundo.c b/app/core/gimpimageundo.c
index a5656a9..bfbc825 100644
--- a/app/core/gimpimageundo.c
+++ b/app/core/gimpimageundo.c
@@ -179,7 +179,7 @@ gimp_image_undo_constructed (GObject *object)
       break;
 
     case GIMP_UNDO_IMAGE_GRID:
-      g_assert (GIMP_IS_GRID (image_undo->grid));
+      g_return_if_fail (GIMP_IS_GRID (image_undo->grid));
       break;
 
     case GIMP_UNDO_IMAGE_COLORMAP:
@@ -199,7 +199,7 @@ gimp_image_undo_constructed (GObject *object)
 
     case GIMP_UNDO_PARASITE_ATTACH:
     case GIMP_UNDO_PARASITE_REMOVE:
-      g_assert (image_undo->parasite_name != NULL);
+      g_return_if_fail (image_undo->parasite_name != NULL);
 
       image_undo->parasite = gimp_parasite_copy
         (gimp_image_parasite_find (image, image_undo->parasite_name));
diff --git a/app/core/gimpitem.c b/app/core/gimpitem.c
index 57a7487..b9b5ee7 100644
--- a/app/core/gimpitem.c
+++ b/app/core/gimpitem.c
@@ -362,8 +362,8 @@ gimp_item_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (GIMP_IS_IMAGE (private->image));
-  g_assert (private->ID != 0);
+  g_return_if_fail (GIMP_IS_IMAGE (private->image));
+  g_return_if_fail (private->ID != 0);
 }
 
 static void
diff --git a/app/core/gimpitempropundo.c b/app/core/gimpitempropundo.c
index 434ca08..93a3e11 100644
--- a/app/core/gimpitempropundo.c
+++ b/app/core/gimpitempropundo.c
@@ -141,7 +141,7 @@ gimp_item_prop_undo_constructed (GObject *object)
 
     case GIMP_UNDO_PARASITE_ATTACH:
     case GIMP_UNDO_PARASITE_REMOVE:
-      g_assert (item_prop_undo->parasite_name != NULL);
+      g_return_if_fail (item_prop_undo->parasite_name != NULL);
 
       item_prop_undo->parasite = gimp_parasite_copy
         (gimp_item_parasite_find (item, item_prop_undo->parasite_name));
diff --git a/app/core/gimpitemstack.c b/app/core/gimpitemstack.c
index e913139..1eed35d 100644
--- a/app/core/gimpitemstack.c
+++ b/app/core/gimpitemstack.c
@@ -73,8 +73,8 @@ gimp_item_stack_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (g_type_is_a (gimp_container_get_children_type (container),
-                         GIMP_TYPE_ITEM));
+  g_return_if_fail (g_type_is_a (gimp_container_get_children_type (container),
+                                 GIMP_TYPE_ITEM));
 }
 
 static void
diff --git a/app/core/gimpitemtree.c b/app/core/gimpitemtree.c
index 187168b..656898d 100644
--- a/app/core/gimpitemtree.c
+++ b/app/core/gimpitemtree.c
@@ -150,10 +150,10 @@ gimp_item_tree_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (GIMP_IS_IMAGE (private->image));
-  g_assert (g_type_is_a (private->container_type, GIMP_TYPE_ITEM_STACK));
-  g_assert (g_type_is_a (private->item_type,      GIMP_TYPE_ITEM));
-  g_assert (private->item_type != GIMP_TYPE_ITEM);
+  g_return_if_fail (GIMP_IS_IMAGE (private->image));
+  g_return_if_fail (g_type_is_a (private->container_type, GIMP_TYPE_ITEM_STACK));
+  g_return_if_fail (g_type_is_a (private->item_type,      GIMP_TYPE_ITEM));
+  g_return_if_fail (private->item_type != GIMP_TYPE_ITEM);
 
   tree->container = g_object_new (private->container_type,
                                   "name",          g_type_name (private->item_type),
diff --git a/app/core/gimpitemundo.c b/app/core/gimpitemundo.c
index 6e1b155..fcb5852 100644
--- a/app/core/gimpitemundo.c
+++ b/app/core/gimpitemundo.c
@@ -84,7 +84,7 @@ gimp_item_undo_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (GIMP_IS_ITEM (item_undo->item));
+  g_return_if_fail (GIMP_IS_ITEM (item_undo->item));
 }
 
 static void
diff --git a/app/core/gimplayermaskpropundo.c b/app/core/gimplayermaskpropundo.c
index f9e5056..0de9982 100644
--- a/app/core/gimplayermaskpropundo.c
+++ b/app/core/gimplayermaskpropundo.c
@@ -65,7 +65,7 @@ gimp_layer_mask_prop_undo_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (GIMP_IS_LAYER (GIMP_ITEM_UNDO (object)->item));
+  g_return_if_fail (GIMP_IS_LAYER (GIMP_ITEM_UNDO (object)->item));
 
   layer = GIMP_LAYER (GIMP_ITEM_UNDO (object)->item);
 
diff --git a/app/core/gimplayermaskundo.c b/app/core/gimplayermaskundo.c
index 93b3bf5..823fb5f 100644
--- a/app/core/gimplayermaskundo.c
+++ b/app/core/gimplayermaskundo.c
@@ -95,8 +95,8 @@ gimp_layer_mask_undo_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (GIMP_IS_LAYER (GIMP_ITEM_UNDO (object)->item));
-  g_assert (GIMP_IS_LAYER_MASK (layer_mask_undo->layer_mask));
+  g_return_if_fail (GIMP_IS_LAYER (GIMP_ITEM_UNDO (object)->item));
+  g_return_if_fail (GIMP_IS_LAYER_MASK (layer_mask_undo->layer_mask));
 }
 
 static void
diff --git a/app/core/gimplayerpropundo.c b/app/core/gimplayerpropundo.c
index c2a50c2..ff2c1ba 100644
--- a/app/core/gimplayerpropundo.c
+++ b/app/core/gimplayerpropundo.c
@@ -65,7 +65,7 @@ gimp_layer_prop_undo_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (GIMP_IS_LAYER (GIMP_ITEM_UNDO (object)->item));
+  g_return_if_fail (GIMP_IS_LAYER (GIMP_ITEM_UNDO (object)->item));
 
   layer = GIMP_LAYER (GIMP_ITEM_UNDO (object)->item);
 
diff --git a/app/core/gimplayerstack.c b/app/core/gimplayerstack.c
index a4b2314..7c0862b 100644
--- a/app/core/gimplayerstack.c
+++ b/app/core/gimplayerstack.c
@@ -85,8 +85,8 @@ gimp_layer_stack_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (g_type_is_a (gimp_container_get_children_type (container),
-                         GIMP_TYPE_LAYER));
+  g_return_if_fail (g_type_is_a (gimp_container_get_children_type (container),
+                                 GIMP_TYPE_LAYER));
 
   gimp_container_add_handler (container, "active-changed",
                               G_CALLBACK (gimp_layer_stack_layer_active),
@@ -205,7 +205,7 @@ gimp_layer_stack_update_range (GimpLayerStack *stack,
 {
   GList *iter;
 
-  g_assert (first >= 0 && last >= -1);
+  g_return_if_fail (first >= 0 && last >= -1);
 
   /* if the range is reversed, flip first and last; note that last == -1 is
    * used to update all layers from first onward.
diff --git a/app/core/gimplayerundo.c b/app/core/gimplayerundo.c
index 6ab6fd2..0f15b89 100644
--- a/app/core/gimplayerundo.c
+++ b/app/core/gimplayerundo.c
@@ -104,7 +104,7 @@ gimp_layer_undo_constructed (GObject *object)
 {
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (GIMP_IS_LAYER (GIMP_ITEM_UNDO (object)->item));
+  g_return_if_fail (GIMP_IS_LAYER (GIMP_ITEM_UNDO (object)->item));
 }
 
 static void
diff --git a/app/core/gimpmaskundo.c b/app/core/gimpmaskundo.c
index d1477bd..4a0c4ae 100644
--- a/app/core/gimpmaskundo.c
+++ b/app/core/gimpmaskundo.c
@@ -100,7 +100,7 @@ gimp_mask_undo_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (GIMP_IS_CHANNEL (GIMP_ITEM_UNDO (object)->item));
+  g_return_if_fail (GIMP_IS_CHANNEL (GIMP_ITEM_UNDO (object)->item));
 
   item     = GIMP_ITEM_UNDO (object)->item;
   drawable = GIMP_DRAWABLE (item);
diff --git a/app/core/gimppatternclipboard.c b/app/core/gimppatternclipboard.c
index 2aca138..1ffe614 100644
--- a/app/core/gimppatternclipboard.c
+++ b/app/core/gimppatternclipboard.c
@@ -103,7 +103,7 @@ gimp_pattern_clipboard_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (GIMP_IS_GIMP (pattern->gimp));
+  g_return_if_fail (GIMP_IS_GIMP (pattern->gimp));
 
   g_signal_connect_object (pattern->gimp, "clipboard-changed",
                            G_CALLBACK (gimp_pattern_clipboard_changed),
diff --git a/app/core/gimppdbprogress.c b/app/core/gimppdbprogress.c
index 2b64251..a560c3b 100644
--- a/app/core/gimppdbprogress.c
+++ b/app/core/gimppdbprogress.c
@@ -177,8 +177,8 @@ gimp_pdb_progress_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (GIMP_IS_PDB (progress->pdb));
-  g_assert (GIMP_IS_CONTEXT (progress->context));
+  g_return_if_fail (GIMP_IS_PDB (progress->pdb));
+  g_return_if_fail (GIMP_IS_CONTEXT (progress->context));
 }
 
 static void
diff --git a/app/core/gimpsamplepointundo.c b/app/core/gimpsamplepointundo.c
index 4032a47..32cb850 100644
--- a/app/core/gimpsamplepointundo.c
+++ b/app/core/gimpsamplepointundo.c
@@ -89,7 +89,7 @@ gimp_sample_point_undo_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (sample_point_undo->sample_point != NULL);
+  g_return_if_fail (sample_point_undo->sample_point != NULL);
 
   gimp_sample_point_get_position (sample_point_undo->sample_point,
                                   &sample_point_undo->x,
diff --git a/app/core/gimptoolpreset.c b/app/core/gimptoolpreset.c
index 81eebc7..b99c7a2 100644
--- a/app/core/gimptoolpreset.c
+++ b/app/core/gimptoolpreset.c
@@ -218,7 +218,7 @@ gimp_tool_preset_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (GIMP_IS_GIMP (preset->gimp));
+  g_return_if_fail (GIMP_IS_GIMP (preset->gimp));
 }
 
 static void
diff --git a/app/core/gimpundo.c b/app/core/gimpundo.c
index 875899a..433e2ec 100644
--- a/app/core/gimpundo.c
+++ b/app/core/gimpundo.c
@@ -184,7 +184,7 @@ gimp_undo_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  g_assert (GIMP_IS_IMAGE (undo->image));
+  g_return_if_fail (GIMP_IS_IMAGE (undo->image));
 }
 
 static void


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