[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48524] trunk/blender: fix ( actually nasty workaround), for groups incorrectly drawing in the object panel when the blend file has naming collisions with library data .

Campbell Barton ideasman42 at gmail.com
Tue Jul 3 12:32:15 CEST 2012


Revision: 48524
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48524
Author:   campbellbarton
Date:     2012-07-03 10:32:10 +0000 (Tue, 03 Jul 2012)
Log Message:
-----------
fix (actually nasty workaround), for groups incorrectly drawing in the object panel when the blend file has naming collisions with library data.

also minor style cleanup in bpy_rna.c

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/properties_object.py
    trunk/blender/source/blender/python/intern/bpy_rna.c

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_object.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_object.py	2012-07-03 09:05:19 UTC (rev 48523)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_object.py	2012-07-03 10:32:10 UTC (rev 48524)
@@ -159,7 +159,7 @@
     def draw(self, context):
         layout = self.layout
 
-        ob = context.object
+        obj = context.object
 
         row = layout.row(align=True)
         row.operator("object.group_link", text="Add to Group")
@@ -167,8 +167,13 @@
 
         # XXX, this is bad practice, yes, I wrote it :( - campbell
         index = 0
+        obj_name = obj.name
         for group in bpy.data.groups:
-            if ob.name in group.objects:
+            # XXX this is slow and stupid!, we need 2 checks, one thats fast
+            # and another that we can be sure its not a name collission
+            # from linked library data
+            group_objects = group.objects
+            if obj_name in group.objects and obj in group_objects[:]:
                 col = layout.column(align=True)
 
                 col.context_pointer_set("group", group)

Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c	2012-07-03 09:05:19 UTC (rev 48523)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c	2012-07-03 10:32:10 UTC (rev 48524)
@@ -873,7 +873,7 @@
 		if (path) {
 			if (GS(id->name) == ID_NT) { /* nodetree paths are not accurate */
 				ret = PyUnicode_FromFormat("bpy.data...%s",
-										   path);
+				                           path);
 			}
 			else {
 				ret = PyUnicode_FromFormat("bpy.data.%s[%R].%s",
@@ -980,7 +980,7 @@
 	if (path) {
 		if (GS(id->name) == ID_NT) { /* nodetree paths are not accurate */
 			ret = PyUnicode_FromFormat("bpy.data...%s",
-									   path);
+			                           path);
 		}
 		else {
 			ret = PyUnicode_FromFormat("bpy.data.%s[%R].%s",
@@ -2040,12 +2040,12 @@
  * This is done for faster lookups. */
 #define PYRNA_PROP_COLLECTION_ABS_INDEX(ret_err)                              \
 	if (keynum < 0) {                                                         \
-		keynum_abs += RNA_property_collection_length(&self->ptr, self->prop); \
-		if (keynum_abs < 0) {                                                 \
-			PyErr_Format(PyExc_IndexError,                                    \
-			             "bpy_prop_collection[%d]: out of range.", keynum);   \
-			return ret_err;                                                   \
-		}                                                                     \
+	    keynum_abs += RNA_property_collection_length(&self->ptr, self->prop); \
+	    if (keynum_abs < 0) {                                                 \
+	        PyErr_Format(PyExc_IndexError,                                    \
+	                     "bpy_prop_collection[%d]: out of range.", keynum);   \
+	        return ret_err;                                                   \
+	    }                                                                     \
 	} (void)0
 
 
@@ -3508,8 +3508,8 @@
 							PyList_Append(ret, linkptr);
 							Py_DECREF(linkptr);
 						}
+						break;
 					}
-					break;
 					default:
 						/* should never happen */
 						BLI_assert(!"Invalid context type");




More information about the Bf-blender-cvs mailing list