[Bf-blender-cvs] [accc94dd73a] master: Cleanup: remove goto's

Campbell Barton noreply at git.blender.org
Thu Sep 7 14:47:18 CEST 2017


Commit: accc94dd73a793a681245bf9eaa0b6f474075995
Author: Campbell Barton
Date:   Thu Sep 7 22:53:46 2017 +1000
Branches: master
https://developer.blender.org/rBaccc94dd73a793a681245bf9eaa0b6f474075995

Cleanup: remove goto's

===================================================================

M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/interface/interface_ops.c

===================================================================

diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 5834477cc59..031011ddaee 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -1440,87 +1440,82 @@ static bool ui_selectcontext_begin(
 		const bool is_array = RNA_property_array_check(prop);
 		const int rna_type = RNA_property_type(prop);
 
-		if (!UI_context_copy_to_selected_list(C, &ptr, prop, &lb, &use_path_from_id, &path)) {
-			goto finally;
-		}
-
-		selctx_data->elems_len = BLI_listbase_count(&lb);
-		if (selctx_data->elems_len == 0) {
-			goto finally;
-		}
-
-		selctx_data->elems = MEM_mallocN(sizeof(uiSelectContextElem) * selctx_data->elems_len, __func__);
+		if (UI_context_copy_to_selected_list(C, &ptr, prop, &lb, &use_path_from_id, &path) &&
+		    !BLI_listbase_is_empty(&lb))
+		{
+			selctx_data->elems_len = BLI_listbase_count(&lb);
+			selctx_data->elems = MEM_mallocN(sizeof(uiSelectContextElem) * selctx_data->elems_len, __func__);
 
-		for (i = 0, link = lb.first; i < selctx_data->elems_len; i++, link = link->next) {
-			uiSelectContextElem *other = &selctx_data->elems[i];
-			/* TODO,. de-duplicate copy_to_selected_button */
-			if (link->ptr.data != ptr.data) {
-				if (use_path_from_id) {
-					/* Path relative to ID. */
-					lprop = NULL;
-					RNA_id_pointer_create(link->ptr.id.data, &idptr);
-					RNA_path_resolve_property(&idptr, path, &lptr, &lprop);
-				}
-				else if (path) {
-					/* Path relative to elements from list. */
-					lprop = NULL;
-					RNA_path_resolve_property(&link->ptr, path, &lptr, &lprop);
-				}
-				else {
-					lptr = link->ptr;
-					lprop = prop;
-				}
+			for (i = 0, link = lb.first; i < selctx_data->elems_len; i++, link = link->next) {
+				uiSelectContextElem *other = &selctx_data->elems[i];
+				/* TODO,. de-duplicate copy_to_selected_button */
+				if (link->ptr.data != ptr.data) {
+					if (use_path_from_id) {
+						/* Path relative to ID. */
+						lprop = NULL;
+						RNA_id_pointer_create(link->ptr.id.data, &idptr);
+						RNA_path_resolve_property(&idptr, path, &lptr, &lprop);
+					}
+					else if (path) {
+						/* Path relative to elements from list. */
+						lprop = NULL;
+						RNA_path_resolve_property(&link->ptr, path, &lptr, &lprop);
+					}
+					else {
+						lptr = link->ptr;
+						lprop = prop;
+					}
 
-				/* lptr might not be the same as link->ptr! */
-				if ((lptr.data != ptr.data) &&
-				    (lprop == prop) &&
-				    RNA_property_editable(&lptr, lprop))
-				{
-					other->ptr = lptr;
-					if (is_array) {
-						if (rna_type == PROP_FLOAT) {
-							other->val_f = RNA_property_float_get_index(&lptr, lprop, index);
-						}
-						else if (rna_type == PROP_INT) {
-							other->val_i = RNA_property_int_get_index(&lptr, lprop, index);
-						}
-						/* ignored for now */
+					/* lptr might not be the same as link->ptr! */
+					if ((lptr.data != ptr.data) &&
+					    (lprop == prop) &&
+					    RNA_property_editable(&lptr, lprop))
+					{
+						other->ptr = lptr;
+						if (is_array) {
+							if (rna_type == PROP_FLOAT) {
+								other->val_f = RNA_property_float_get_index(&lptr, lprop, index);
+							}
+							else if (rna_type == PROP_INT) {
+								other->val_i = RNA_property_int_get_index(&lptr, lprop, index);
+							}
+							/* ignored for now */
 #if 0
-						else if (rna_type == PROP_BOOLEAN) {
-							other->val_b = RNA_property_boolean_get_index(&lptr, lprop, index);
-						}
+							else if (rna_type == PROP_BOOLEAN) {
+								other->val_b = RNA_property_boolean_get_index(&lptr, lprop, index);
+							}
 #endif
-					}
-					else {
-						if (rna_type == PROP_FLOAT) {
-							other->val_f = RNA_property_float_get(&lptr, lprop);
-						}
-						else if (rna_type == PROP_INT) {
-							other->val_i = RNA_property_int_get(&lptr, lprop);
 						}
-						/* ignored for now */
+						else {
+							if (rna_type == PROP_FLOAT) {
+								other->val_f = RNA_property_float_get(&lptr, lprop);
+							}
+							else if (rna_type == PROP_INT) {
+								other->val_i = RNA_property_int_get(&lptr, lprop);
+							}
+							/* ignored for now */
 #if 0
-						else if (rna_type == PROP_BOOLEAN) {
-							other->val_b = RNA_property_boolean_get(&lptr, lprop);
-						}
-						else if (rna_type == PROP_ENUM) {
-							other->val_i = RNA_property_enum_get(&lptr, lprop);
-						}
+							else if (rna_type == PROP_BOOLEAN) {
+								other->val_b = RNA_property_boolean_get(&lptr, lprop);
+							}
+							else if (rna_type == PROP_ENUM) {
+								other->val_i = RNA_property_enum_get(&lptr, lprop);
+							}
 #endif
-					}
+						}
 
-					continue;
+						continue;
+					}
 				}
+
+				selctx_data->elems_len -= 1;
+				i -= 1;
 			}
 
-			selctx_data->elems_len -= 1;
-			i -= 1;
+			success = (selctx_data->elems_len != 0);
 		}
 	}
 
-	success = (selctx_data->elems_len != 0);
-
-finally:
 	if (selctx_data->elems_len == 0) {
 		MEM_SAFE_FREE(selctx_data->elems);
 	}
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index ce3cf24f292..d0c110d1db5 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -499,51 +499,49 @@ static bool copy_to_selected_button(bContext *C, bool all, bool poll)
 		CollectionPointerLink *link;
 		ListBase lb = {NULL};
 
-		if (!UI_context_copy_to_selected_list(C, &ptr, prop, &lb, &use_path_from_id, &path)) {
-			goto finally;
-		}
-
-		for (link = lb.first; link; link = link->next) {
-			if (link->ptr.data != ptr.data) {
-				if (use_path_from_id) {
-					/* Path relative to ID. */
-					lprop = NULL;
-					RNA_id_pointer_create(link->ptr.id.data, &idptr);
-					RNA_path_resolve_property(&idptr, path, &lptr, &lprop);
-				}
-				else if (path) {
-					/* Path relative to elements from list. */
-					lprop = NULL;
-					RNA_path_resolve_property(&link->ptr, path, &lptr, &lprop);
-				}
-				else {
-					lptr = link->ptr;
-					lprop = prop;
-				}
+		if (UI_context_copy_to_selected_list(C, &ptr, prop, &lb, &use_path_from_id, &path) &&
+		    !BLI_listbase_is_empty(&lb))
+		{
+			for (link = lb.first; link; link = link->next) {
+				if (link->ptr.data != ptr.data) {
+					if (use_path_from_id) {
+						/* Path relative to ID. */
+						lprop = NULL;
+						RNA_id_pointer_create(link->ptr.id.data, &idptr);
+						RNA_path_resolve_property(&idptr, path, &lptr, &lprop);
+					}
+					else if (path) {
+						/* Path relative to elements from list. */
+						lprop = NULL;
+						RNA_path_resolve_property(&link->ptr, path, &lptr, &lprop);
+					}
+					else {
+						lptr = link->ptr;
+						lprop = prop;
+					}
 
-				if (lptr.data == ptr.data) {
-					/* lptr might not be the same as link->ptr! */
-					continue;
-				}
+					if (lptr.data == ptr.data) {
+						/* lptr might not be the same as link->ptr! */
+						continue;
+					}
 
-				if (lprop == prop) {
-					if (RNA_property_editable(&lptr, lprop)) {
-						if (poll) {
-							success = true;
-							break;
-						}
-						else {
-							if (RNA_property_copy(&lptr, &ptr, prop, (all) ? -1 : index)) {
-								RNA_property_update(C, &lptr, prop);
+					if (lprop == prop) {
+						if (RNA_property_editable(&lptr, lprop)) {
+							if (poll) {
 								success = true;
+								break;
+							}
+							else {
+								if (RNA_property_copy(&lptr, &ptr, prop, (all) ? -1 : index)) {
+									RNA_property_update(C, &lptr, prop);
+									success = true;
+								}
 							}
 						}
 					}
 				}
 			}
 		}
-
-finally:
 		MEM_SAFE_FREE(path);
 		BLI_freelistN(&lb);
 	}



More information about the Bf-blender-cvs mailing list