[gimp] app: harden precondition checks in GimpItemTree
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: harden precondition checks in GimpItemTree
- Date: Thu, 8 Jul 2010 13:08:24 +0000 (UTC)
commit 70a3addcb993319b8b7b1f07d0c174657b781ed3
Author: Michael Natterer <mitch gimp org>
Date: Thu Jul 8 15:06:19 2010 +0200
app: harden precondition checks in GimpItemTree
Instead of checking if the item is attached and belon's to the tree's
image (which did miss e.g. passing a channel to the layer tree), we
now check if gimp_item_get_tree(item) returns right tree.
app/core/gimpitemtree.c | 28 +++++++---------------------
1 files changed, 7 insertions(+), 21 deletions(-)
---
diff --git a/app/core/gimpitemtree.c b/app/core/gimpitemtree.c
index 6a1667c..78295e4 100644
--- a/app/core/gimpitemtree.c
+++ b/app/core/gimpitemtree.c
@@ -302,9 +302,7 @@ gimp_item_tree_set_active_item (GimpItemTree *tree,
g_return_if_fail (item == NULL ||
G_TYPE_CHECK_INSTANCE_TYPE (item, private->item_type));
- g_return_if_fail (item == NULL || gimp_item_is_attached (item));
- g_return_if_fail (item == NULL ||
- gimp_item_get_image (item) == private->image);
+ g_return_if_fail (item == NULL || gimp_item_get_tree (item) == tree);
if (item != private->active_item)
{
@@ -349,11 +347,7 @@ gimp_item_tree_get_insert_pos (GimpItemTree *tree,
FALSE);
g_return_val_if_fail (*parent == NULL ||
*parent == GIMP_IMAGE_ACTIVE_PARENT ||
- gimp_item_is_attached (*parent), FALSE);
- g_return_val_if_fail (*parent == NULL ||
- *parent == GIMP_IMAGE_ACTIVE_PARENT ||
- gimp_item_get_image (*parent) == private->image,
- FALSE);
+ gimp_item_get_tree (*parent) == tree, FALSE);
g_return_val_if_fail (*parent == NULL ||
*parent == GIMP_IMAGE_ACTIVE_PARENT ||
gimp_viewable_get_children (GIMP_VIEWABLE (*parent)),
@@ -431,9 +425,7 @@ gimp_item_tree_add_item (GimpItemTree *tree,
g_return_if_fail (gimp_item_get_image (item) == private->image);
g_return_if_fail (parent == NULL ||
G_TYPE_CHECK_INSTANCE_TYPE (parent, private->item_type));
- g_return_if_fail (parent == NULL || gimp_item_is_attached (parent));
- g_return_if_fail (parent == NULL ||
- gimp_item_get_image (parent) == private->image);
+ g_return_if_fail (parent == NULL || gimp_item_get_tree (parent) == tree);
g_return_if_fail (parent == NULL ||
gimp_viewable_get_children (GIMP_VIEWABLE (parent)));
@@ -482,8 +474,7 @@ gimp_item_tree_remove_item (GimpItemTree *tree,
g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (item, private->item_type),
NULL);
- g_return_val_if_fail (gimp_item_is_attached (item), NULL);
- g_return_val_if_fail (gimp_item_get_image (item) == private->image, NULL);
+ g_return_val_if_fail (gimp_item_get_tree (item) == tree, NULL);
parent = gimp_item_get_parent (item);
container = gimp_item_get_container (item);
@@ -557,17 +548,13 @@ gimp_item_tree_reorder_item (GimpItemTree *tree,
g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (item, private->item_type),
FALSE);
- g_return_val_if_fail (gimp_item_is_attached (item), FALSE);
- g_return_val_if_fail (gimp_item_get_image (item) == private->image, FALSE);
+ g_return_val_if_fail (gimp_item_get_tree (item) == tree, FALSE);
g_return_val_if_fail (new_parent == NULL ||
G_TYPE_CHECK_INSTANCE_TYPE (new_parent,
private->item_type),
FALSE);
g_return_val_if_fail (new_parent == NULL ||
- gimp_item_is_attached (new_parent), FALSE);
- g_return_val_if_fail (new_parent == NULL ||
- gimp_item_get_image (new_parent) == private->image,
- FALSE);
+ gimp_item_get_tree (new_parent) == tree, FALSE);
g_return_val_if_fail (new_parent == NULL ||
gimp_viewable_get_children (GIMP_VIEWABLE (new_parent)),
FALSE);
@@ -633,8 +620,7 @@ gimp_item_tree_rename_item (GimpItemTree *tree,
private = GIMP_ITEM_TREE_GET_PRIVATE (tree);
g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (item, private->item_type));
- g_return_if_fail (gimp_item_is_attached (item));
- g_return_if_fail (gimp_item_get_image (item) == private->image);
+ g_return_if_fail (gimp_item_get_tree (item) == tree);
g_return_if_fail (new_name != NULL);
if (strcmp (new_name, gimp_object_get_name (item)))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]