Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / interface / interface_ops.c
index 95ea2b87cba64c65ae34fc634a3a556a1d4ed951..40ca2d41372a375d2d1b45ff4fe66f6a477b3d3f 100644 (file)
@@ -621,51 +621,51 @@ static bool copy_to_selected_button(bContext *C, bool all, bool poll)
                char *path = NULL;
                bool use_path_from_id;
                CollectionPointerLink *link;
-               ListBase lb;
-
-               if (!UI_context_copy_to_selected_list(C, &ptr, prop, &lb, &use_path_from_id, &path))
-                       return success;
+               ListBase lb = {NULL};
 
-               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;
+                                                               }
                                                        }
                                                }
                                        }
                                }
                        }
                }
-
                MEM_SAFE_FREE(path);
                BLI_freelistN(&lb);
        }