Commit f87bc3fe authored by Jehan's avatar Jehan

app: we should not have any g_assert*() code if possible.

Replace all g_assert_not_reached() in app/core/ by g_return_if_reached()
or g_return_val_if_reached(). GIMP may handle a lot of creative work,
sometimes unsaved for hours. We should not just crash on purpose.
g_assert*() could theoretically be turned off on a glib build, but this
is nearly never done, and is not a solution either (actually it is
probably even worse because the broken code would just continue on a
forbidden path). It is much better to return with a warning on such
forbidden code paths, allowing someone to report a bug without
experiencing a crash and data loss.

For now, I only took care of g_assert_not_reached() inside app/core.
More g_assert*() code should be replaced.
Note: assert are acceptable in plug-ins though, but not in the main
executable, unless absolutely necessary (something happening so bad that
crash is better than continuing).
parent 54a1e8f2
......@@ -76,7 +76,7 @@ gimp_channel_prop_undo_constructed (GObject *object)
break;
default:
g_assert_not_reached ();
g_return_if_reached ();
}
}
......@@ -103,6 +103,6 @@ gimp_channel_prop_undo_pop (GimpUndo *undo,
break;
default:
g_assert_not_reached ();
g_return_if_reached ();
}
}
......@@ -347,7 +347,7 @@ gimp_drawable_transform_rotate_point (gint x,
break;
default:
g_assert_not_reached ();
g_return_if_reached ();
}
}
......
......@@ -79,7 +79,7 @@ gimp_floating_selection_undo_constructed (GObject *object)
break;
default:
g_assert_not_reached ();
g_return_if_reached ();
}
}
......@@ -130,6 +130,6 @@ gimp_floating_selection_undo_pop (GimpUndo *undo,
break;
default:
g_assert_not_reached ();
g_return_if_reached ();
}
}
......@@ -895,7 +895,7 @@ get_projection_format (GimpProjectable *projectable,
return gimp_image_get_format (image, GIMP_GRAY, precision, TRUE);
}
g_assert_not_reached ();
g_return_val_if_reached (NULL);
return NULL;
}
......
......@@ -80,7 +80,7 @@ gimp_group_layer_undo_constructed (GObject *object)
break;
default:
g_assert_not_reached ();
g_return_if_reached ();
}
}
......@@ -143,6 +143,6 @@ gimp_group_layer_undo_pop (GimpUndo *undo,
break;
default:
g_assert_not_reached ();
g_return_if_reached ();
}
}
......@@ -121,6 +121,9 @@ gimp_image_arrange_objects (GimpImage *image,
do_y = TRUE;
compute_offsets (list, alignment);
break;
default:
g_return_if_reached ();
}
object_list = sort_by_offset (list);
......@@ -365,7 +368,7 @@ compute_offset (GObject *object,
break;
default:
g_assert_not_reached ();
g_return_if_reached ();
}
g_object_set_data (object, "align-offset",
......
......@@ -109,7 +109,7 @@ gimp_image_rotate (GimpImage *image,
break;
default:
g_assert_not_reached ();
g_return_if_reached ();
return;
}
......@@ -266,6 +266,9 @@ gimp_image_rotate_item_offset (GimpImage *image,
case GIMP_ROTATE_180:
return;
default:
g_return_if_reached ();
}
gimp_item_get_offset (item, &off_x, &off_y);
......
......@@ -1448,7 +1448,7 @@ gimp_image_get_proj_format (GimpProjectable *projectable)
gimp_image_get_precision (image), TRUE);
}
g_assert_not_reached ();
g_return_val_if_reached (NULL);
return NULL;
}
......
......@@ -206,7 +206,7 @@ gimp_image_undo_constructed (GObject *object)
break;
default:
g_assert_not_reached ();
g_return_if_reached ();
}
}
......@@ -523,7 +523,7 @@ gimp_image_undo_pop (GimpUndo *undo,
break;
default:
g_assert_not_reached ();
g_return_if_reached ();
}
}
......
......@@ -148,7 +148,7 @@ gimp_item_prop_undo_constructed (GObject *object)
break;
default:
g_assert_not_reached ();
g_return_if_reached ();
}
}
......@@ -340,7 +340,7 @@ gimp_item_prop_undo_pop (GimpUndo *undo,
break;
default:
g_assert_not_reached ();
g_return_if_reached ();
}
}
......
......@@ -80,7 +80,7 @@ gimp_layer_mask_prop_undo_constructed (GObject *object)
break;
default:
g_assert_not_reached ();
g_return_if_reached ();
}
}
......@@ -117,6 +117,6 @@ gimp_layer_mask_prop_undo_pop (GimpUndo *undo,
break;
default:
g_assert_not_reached ();
g_return_if_reached ();
}
}
......@@ -87,7 +87,7 @@ gimp_layer_prop_undo_constructed (GObject *object)
break;
default:
g_assert_not_reached ();
g_return_if_reached ();
}
}
......@@ -152,6 +152,6 @@ gimp_layer_prop_undo_pop (GimpUndo *undo,
break;
default:
g_assert_not_reached ();
g_return_if_reached ();
}
}
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