[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43082] trunk/blender/source/blender/ editors: replace:

Campbell Barton ideasman42 at gmail.com
Mon Jan 2 18:15:29 CET 2012


Revision: 43082
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43082
Author:   campbellbarton
Date:     2012-01-02 17:15:24 +0000 (Mon, 02 Jan 2012)
Log Message:
-----------
replace:
  CTX_data_pointer_get_type(C, "object", &RNA_Object).data
with api call:
  ED_object_context(C)

... since getting the context object is such a common operation.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/armature/editarmature.c
    trunk/blender/source/blender/editors/armature/poselib.c
    trunk/blender/source/blender/editors/armature/poseobject.c
    trunk/blender/source/blender/editors/include/ED_object.h
    trunk/blender/source/blender/editors/mesh/mesh_data.c
    trunk/blender/source/blender/editors/object/object_edit.c
    trunk/blender/source/blender/editors/object/object_group.c
    trunk/blender/source/blender/editors/object/object_shapekey.c
    trunk/blender/source/blender/editors/object/object_vgroup.c
    trunk/blender/source/blender/editors/physics/dynamicpaint_ops.c
    trunk/blender/source/blender/editors/physics/particle_object.c
    trunk/blender/source/blender/editors/render/render_shading.c

Modified: trunk/blender/source/blender/editors/armature/editarmature.c
===================================================================
--- trunk/blender/source/blender/editors/armature/editarmature.c	2012-01-02 16:59:46 UTC (rev 43081)
+++ trunk/blender/source/blender/editors/armature/editarmature.c	2012-01-02 17:15:24 UTC (rev 43082)
@@ -5067,7 +5067,6 @@
 {
 	int action = RNA_enum_get(op->ptr, "action");
 	
-	Object *ob = NULL;
 	Scene *scene= CTX_data_scene(C);
 	int multipaint = scene->toolsettings->multipaint;
 
@@ -5100,8 +5099,8 @@
 
 	WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, NULL);
 	
-	if(multipaint) {
-		ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+	if (multipaint) {
+		Object *ob = ED_object_context(C);
 		DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
 	}
 

Modified: trunk/blender/source/blender/editors/armature/poselib.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poselib.c	2012-01-02 16:59:46 UTC (rev 43081)
+++ trunk/blender/source/blender/editors/armature/poselib.c	2012-01-02 17:15:24 UTC (rev 43082)
@@ -77,6 +77,7 @@
 #include "ED_keyframing.h"
 #include "ED_keyframes_edit.h"
 #include "ED_screen.h"
+#include "ED_object.h"
 
 #include "armature_intern.h"
 
@@ -171,7 +172,7 @@
 	sa = CTX_wm_area(C);
 	
 	if (sa && (sa->spacetype == SPACE_BUTS)) 
-		return CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+		return ED_object_context(C);
 	else
 		return object_pose_armature_get(CTX_data_active_object(C));
 }

Modified: trunk/blender/source/blender/editors/armature/poseobject.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poseobject.c	2012-01-02 16:59:46 UTC (rev 43081)
+++ trunk/blender/source/blender/editors/armature/poseobject.c	2012-01-02 17:15:24 UTC (rev 43082)
@@ -73,6 +73,7 @@
 #include "ED_keyframing.h"
 #include "ED_mesh.h"
 #include "ED_screen.h"
+#include "ED_object.h"
 
 #include "UI_interface.h"
 #include "UI_resources.h"
@@ -207,7 +208,7 @@
 	
 	/* since this call may also be used from the buttons window, we need to check for where to get the object */
 	if (sa->spacetype == SPACE_BUTS) 
-		ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+		ob= ED_object_context(C);
 	else
 		ob= object_pose_armature_get(CTX_data_active_object(C));
 		
@@ -283,7 +284,7 @@
 	
 	/* since this call may also be used from the buttons window, we need to check for where to get the object */
 	if (sa->spacetype == SPACE_BUTS) 
-		ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+		ob= ED_object_context(C);
 	else
 		ob= object_pose_armature_get(CTX_data_active_object(C));
 		
@@ -1221,7 +1222,7 @@
 	
 	/* since this call may also be used from the buttons window, we need to check for where to get the object */
 	if (sa->spacetype == SPACE_BUTS) 
-		ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+		ob= ED_object_context(C);
 	else
 		ob= object_pose_armature_get(CTX_data_active_object(C));
 		
@@ -1261,7 +1262,7 @@
 	
 	/* since this call may also be used from the buttons window, we need to check for where to get the object */
 	if (sa->spacetype == SPACE_BUTS) 
-		ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+		ob= ED_object_context(C);
 	else
 		ob= object_pose_armature_get(CTX_data_active_object(C));
 	
@@ -1309,7 +1310,7 @@
 	
 	/* since this call may also be used from the buttons window, we need to check for where to get the object */
 	if (sa->spacetype == SPACE_BUTS) 
-		ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+		ob= ED_object_context(C);
 	else
 		ob= object_pose_armature_get(CTX_data_active_object(C));
 	
@@ -1358,7 +1359,7 @@
 	
 	/* since this call may also be used from the buttons window, we need to check for where to get the object */
 	if (sa->spacetype == SPACE_BUTS) 
-		ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+		ob= ED_object_context(C);
 	else
 		ob= object_pose_armature_get(CTX_data_active_object(C));
 	
@@ -1421,7 +1422,7 @@
 	
 	/* since this call may also be used from the buttons window, we need to check for where to get the object */
 	if (sa->spacetype == SPACE_BUTS) 
-		ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+		ob= ED_object_context(C);
 	else
 		ob= object_pose_armature_get(CTX_data_active_object(C));
 	
@@ -1466,7 +1467,7 @@
 
 static int group_move_exec(bContext *C, wmOperator *op)
 {
-	Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+	Object *ob = ED_object_context(C);
 	bPose *pose= (ob) ? ob->pose : NULL;
 	bPoseChannel *pchan;
 	bActionGroup *grp;
@@ -1564,7 +1565,7 @@
 
 static int group_sort_exec(bContext *C, wmOperator *UNUSED(op))
 {
-	Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+	Object *ob = ED_object_context(C);
 	bPose *pose= (ob) ? ob->pose : NULL;
 	bPoseChannel *pchan;
 	tSortActionGroup *agrp_array;
@@ -1656,7 +1657,7 @@
 	
 	/* since this call may also be used from the buttons window, we need to check for where to get the object */
 	if (sa->spacetype == SPACE_BUTS) 
-		ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+		ob= ED_object_context(C);
 	else
 		ob= object_pose_armature_get(CTX_data_active_object(C));
 	
@@ -1694,7 +1695,7 @@
 	
 	/* since this call may also be used from the buttons window, we need to check for where to get the object */
 	if (sa->spacetype == SPACE_BUTS) 
-		ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+		ob= ED_object_context(C);
 	else
 		ob= object_pose_armature_get(CTX_data_active_object(C));
 	

Modified: trunk/blender/source/blender/editors/include/ED_object.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_object.h	2012-01-02 16:59:46 UTC (rev 43081)
+++ trunk/blender/source/blender/editors/include/ED_object.h	2012-01-02 17:15:24 UTC (rev 43082)
@@ -56,7 +56,8 @@
 struct wmOperatorType;
 
 /* object_edit.c */
-struct Object *ED_object_active_context(struct bContext *C);
+struct Object *ED_object_context(struct bContext *C);               /* context.object */
+struct Object *ED_object_active_context(struct bContext *C); /* context.object or context.active_object */
 
 /* object_ops.c */
 void ED_operatortypes_object(void);

Modified: trunk/blender/source/blender/editors/mesh/mesh_data.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/mesh_data.c	2012-01-02 16:59:46 UTC (rev 43081)
+++ trunk/blender/source/blender/editors/mesh/mesh_data.c	2012-01-02 17:15:24 UTC (rev 43082)
@@ -318,14 +318,14 @@
 
 static int layers_poll(bContext *C)
 {
-	Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+	Object *ob= ED_object_context(C);
 	ID *data= (ob)? ob->data: NULL;
 	return (ob && !ob->id.lib && ob->type==OB_MESH && data && !data->lib);
 }
 
 static int uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op))
 {
-	Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+	Object *ob= ED_object_context(C);
 	Mesh *me= ob->data;
 
 	if(!ED_mesh_uv_texture_add(C, me, NULL, TRUE))
@@ -435,7 +435,7 @@
 
 static int uv_texture_remove_exec(bContext *C, wmOperator *UNUSED(op))
 {
-	Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+	Object *ob= ED_object_context(C);
 	Mesh *me= ob->data;
 
 	if(!ED_mesh_uv_texture_remove(C, ob, me))
@@ -464,7 +464,7 @@
 static int vertex_color_add_exec(bContext *C, wmOperator *UNUSED(op))
 {
 	Scene *scene= CTX_data_scene(C);
-	Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+	Object *ob= ED_object_context(C);
 	Mesh *me= ob->data;
 
 	if(!ED_mesh_color_add(C, scene, ob, me, NULL, TRUE))
@@ -490,7 +490,7 @@
 
 static int vertex_color_remove_exec(bContext *C, wmOperator *UNUSED(op))
 {
-	Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+	Object *ob= ED_object_context(C);
 	Mesh *me= ob->data;
 
 	if(!ED_mesh_color_remove(C, ob, me))
@@ -520,7 +520,7 @@
 {
 	Scene *scene= CTX_data_scene(C);
 	View3D *v3d= CTX_wm_view3d(C);
-	Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+	Object *ob= ED_object_context(C);
 	Mesh *me= ob->data;
 
 	/*if(me->msticky)
@@ -551,7 +551,7 @@
 
 static int sticky_remove_exec(bContext *C, wmOperator *UNUSED(op))
 {
-	Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+	Object *ob= ED_object_context(C);
 	Mesh *me= ob->data;
 
 	if(!me->msticky)

Modified: trunk/blender/source/blender/editors/object/object_edit.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_edit.c	2012-01-02 16:59:46 UTC (rev 43081)
+++ trunk/blender/source/blender/editors/object/object_edit.c	2012-01-02 17:15:24 UTC (rev 43082)
@@ -111,6 +111,10 @@
 static bContext *evil_C;
 static void error_libdata(void) {}
 
+Object *ED_object_context(bContext *C)
+{
+	return CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+}
 
 /* find the correct active object per context
  * note: context can be NULL when called from a enum with PROP_ENUM_NO_CONTEXT */
@@ -118,7 +122,7 @@
 {
 	Object *ob= NULL;
 	if(C) {
-		ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+		ob= ED_object_context(C);
 		if (!ob) ob= CTX_data_active_object(C);
 	}
 	return ob;

Modified: trunk/blender/source/blender/editors/object/object_group.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_group.c	2012-01-02 16:59:46 UTC (rev 43081)
+++ trunk/blender/source/blender/editors/object/object_group.c	2012-01-02 17:15:24 UTC (rev 43082)
@@ -46,6 +46,7 @@
 #include "BKE_report.h"
 
 #include "ED_screen.h"
+#include "ED_object.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -230,7 +231,7 @@
 static int group_add_exec(bContext *C, wmOperator *UNUSED(op))
 {
 	Scene *scene= CTX_data_scene(C);
-	Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+	Object *ob= ED_object_context(C);
 	Group *group;
 
 	if(ob == NULL)
@@ -261,7 +262,7 @@
 static int group_link_exec(bContext *C, wmOperator *op)
 {
 	Scene *scene= CTX_data_scene(C);
-	Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+	Object *ob= ED_object_context(C);
 	Group *group= BLI_findlink(&CTX_data_main(C)->group, RNA_enum_get(op->ptr, "group"));
 
 	if(ELEM(NULL, ob, group))

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-blender-cvs mailing list