Cleanup: interface, reduce indentation of copy_to_selected_button()
Reduce cognitive complexity of `copy_to_selected_button()` by flipping conditions, returning early, and using `continue`. No functional changes.
This commit is contained in:
parent
4e1a1821e0
commit
a25a1f39aa
@ -998,15 +998,27 @@ static bool copy_to_selected_button(bContext *C, bool all, bool poll)
|
||||
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
|
||||
|
||||
/* if there is a valid property that is editable... */
|
||||
if (ptr.data && prop) {
|
||||
if (ptr.data == NULL || prop == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char *path = NULL;
|
||||
bool use_path_from_id;
|
||||
ListBase lb = {NULL};
|
||||
|
||||
if (UI_context_copy_to_selected_list(C, &ptr, prop, &lb, &use_path_from_id, &path) &&
|
||||
!BLI_listbase_is_empty(&lb)) {
|
||||
if (!UI_context_copy_to_selected_list(C, &ptr, prop, &lb, &use_path_from_id, &path)) {
|
||||
return false;
|
||||
}
|
||||
if (BLI_listbase_is_empty(&lb)) {
|
||||
MEM_SAFE_FREE(path);
|
||||
return false;
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (CollectionPointerLink *, link, &lb) {
|
||||
if (link->ptr.data != ptr.data) {
|
||||
if (link->ptr.data == ptr.data) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (use_path_from_id) {
|
||||
/* Path relative to ID. */
|
||||
lprop = NULL;
|
||||
@ -1028,8 +1040,14 @@ static bool copy_to_selected_button(bContext *C, bool all, bool poll)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lprop == prop) {
|
||||
if (RNA_property_editable(&lptr, lprop)) {
|
||||
if (lprop != prop) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!RNA_property_editable(&lptr, lprop)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (poll) {
|
||||
success = true;
|
||||
break;
|
||||
@ -1039,13 +1057,9 @@ static bool copy_to_selected_button(bContext *C, bool all, bool poll)
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MEM_SAFE_FREE(path);
|
||||
BLI_freelistN(&lb);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user