[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45514] trunk/blender/source/blender/ editors/interface/interface_ops.c: Fix properties editor, right click menu "Copy to Selected" not working for

Brecht Van Lommel brechtvanlommel at pandora.be
Tue Apr 10 17:49:41 CEST 2012


Revision: 45514
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45514
Author:   blendix
Date:     2012-04-10 15:49:41 +0000 (Tue, 10 Apr 2012)
Log Message:
-----------
Fix properties editor, right click menu "Copy to Selected" not working for
object modifier/constraint/physics properties. Now uses RNA path rather than
only properties on the object itself.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface_ops.c

Modified: trunk/blender/source/blender/editors/interface/interface_ops.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_ops.c	2012-04-10 15:48:28 UTC (rev 45513)
+++ trunk/blender/source/blender/editors/interface/interface_ops.c	2012-04-10 15:49:41 UTC (rev 45514)
@@ -348,39 +348,53 @@
 
 static int copy_to_selected_list(bContext *C, PointerRNA *ptr, ListBase *lb)
 {
-	if (RNA_struct_is_a(ptr->type, &RNA_Object))
-		*lb = CTX_data_collection_get(C, "selected_editable_objects");
-	else if (RNA_struct_is_a(ptr->type, &RNA_EditBone))
+	if (RNA_struct_is_a(ptr->type, &RNA_EditBone))
 		*lb = CTX_data_collection_get(C, "selected_editable_bones");
 	else if (RNA_struct_is_a(ptr->type, &RNA_PoseBone))
 		*lb = CTX_data_collection_get(C, "selected_pose_bones");
 	else if (RNA_struct_is_a(ptr->type, &RNA_Sequence))
 		*lb = CTX_data_collection_get(C, "selected_editable_sequences");
-	else
-		return 0;
+	else {
+		ID *id = ptr->id.data;
+
+		if(id && GS(id->name) == ID_OB)
+			*lb = CTX_data_collection_get(C, "selected_editable_objects");
+		else
+			return 0;
+	}
 	
 	return 1;
 }
 
 static int copy_to_selected_button_poll(bContext *C)
 {
-	PointerRNA ptr;
-	PropertyRNA *prop;
+	PointerRNA ptr, lptr, idptr;
+	PropertyRNA *prop, *lprop;
 	int index, success = 0;
 
 	uiContextActiveProperty(C, &ptr, &prop, &index);
 
 	if (ptr.data && prop) {
+		char *path = RNA_path_from_ID_to_property(&ptr, prop);
 		CollectionPointerLink *link;
 		ListBase lb;
 
-		if (copy_to_selected_list(C, &ptr, &lb)) {
-			for (link = lb.first; link; link = link->next)
-				if (link->ptr.data != ptr.data && RNA_property_editable(&link->ptr, prop))
-					success = 1;
+		if (path && copy_to_selected_list(C, &ptr, &lb)) {
+			for (link = lb.first; link; link = link->next) {
+				if (link->ptr.data != ptr.data) {
+					RNA_id_pointer_create(link->ptr.id.data, &idptr);
 
+					if (RNA_path_resolve(&idptr, path, &lptr, &lprop) && lprop == prop) {
+						if (RNA_property_editable(&lptr, prop))
+							success = 1;
+					}
+				}
+			}
+
 			BLI_freelistN(&lb);
 		}
+
+		MEM_freeN(path);
 	}
 
 	return success;
@@ -388,8 +402,8 @@
 
 static int copy_to_selected_button_exec(bContext *C, wmOperator *op)
 {
-	PointerRNA ptr;
-	PropertyRNA *prop;
+	PointerRNA ptr, lptr, idptr;
+	PropertyRNA *prop, *lprop;
 	int success = 0;
 	int index, all = RNA_boolean_get(op->ptr, "all");
 
@@ -398,21 +412,29 @@
 	
 	/* if there is a valid property that is editable... */
 	if (ptr.data && prop) {
+		char *path = RNA_path_from_ID_to_property(&ptr, prop);
 		CollectionPointerLink *link;
 		ListBase lb;
 
-		if (copy_to_selected_list(C, &ptr, &lb)) {
+		if (path && copy_to_selected_list(C, &ptr, &lb)) {
 			for (link = lb.first; link; link = link->next) {
-				if (link->ptr.data != ptr.data && RNA_property_editable(&link->ptr, prop)) {
-					if (RNA_property_copy(&link->ptr, &ptr, prop, (all) ? -1 : index)) {
-						RNA_property_update(C, &link->ptr, prop);
-						success = 1;
+				if (link->ptr.data != ptr.data) {
+					RNA_id_pointer_create(link->ptr.id.data, &idptr);
+					if (RNA_path_resolve(&idptr, path, &lptr, &lprop) && lprop == prop) {
+						if(RNA_property_editable(&lptr, lprop)) {
+							if (RNA_property_copy(&lptr, &ptr, prop, (all) ? -1 : index)) {
+								RNA_property_update(C, &lptr, prop);
+								success = 1;
+							}
+						}
 					}
 				}
 			}
 
 			BLI_freelistN(&lb);
 		}
+
+		MEM_freeN(path);
 	}
 	
 	return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;




More information about the Bf-blender-cvs mailing list