Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / interface / interface_handlers.c
index 75b947d455e506222b58141be185f14ad8d9af84..cc3faf82db0a00a35d13d7d123ade7892f469127 100644 (file)
@@ -1438,87 +1438,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);
        }