Commit 4c2df9b3 authored by Jehan's avatar Jehan

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

... in app/core.
Continuing on my crusade against asserting and crashing GIMP.
parent b4c7dd8f
......@@ -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);
......
......@@ -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);
......
......@@ -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
......
......@@ -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),
......
......@@ -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);
......
......@@ -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);
......
......@@ -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
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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),
......
......@@ -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
......
......@@ -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))
{
......
......@@ -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),
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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.");
......
......@@ -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;
......
......@@ -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));
......
......@@ -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
......
......@@ -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));
......
......@@ -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
......
......@@ -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),
......
......@@ -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
......
......@@ -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);
......
......@@ -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
......
......@@ -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);
......
......@@ -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.
......
......@@ -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
......
......@@ -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);
......
......@@ -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),
......
......@@ -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
......
......@@ -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,
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment