[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23055] branches/blender2.5/blender: 2. 5 - Mode Switching Bugfixes

Joshua Leung aligorith at gmail.com
Tue Sep 8 04:09:18 CEST 2009


Revision: 23055
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23055
Author:   aligorith
Date:     2009-09-08 04:09:14 +0200 (Tue, 08 Sep 2009)

Log Message:
-----------
2.5 - Mode Switching Bugfixes

This commit some of the many bugs here (it's still not perfect now, but much better than it was):
* Moving in/out of Object, Edit, and Pose Modes for Armatures should now work smoothly. Operators should work nicely in the appropriate modes now (select linked might be a bit tempermental still, since it uses mouse-position).

* Fixed the 'mysterious' memory leaks when changing modes. These were only caused when using the mode switching menu in the 3D-View.

* Went through bullet-proofing some of the operator calling functions against NULL operator id-name strings.

Modified Paths:
--------------
    branches/blender2.5/blender/release/ui/space_view3d.py
    branches/blender2.5/blender/source/blender/editors/armature/poseobject.c
    branches/blender2.5/blender/source/blender/editors/object/object_edit.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_header.c
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.c

Modified: branches/blender2.5/blender/release/ui/space_view3d.py
===================================================================
--- branches/blender2.5/blender/release/ui/space_view3d.py	2009-09-08 01:18:06 UTC (rev 23054)
+++ branches/blender2.5/blender/release/ui/space_view3d.py	2009-09-08 02:09:14 UTC (rev 23055)
@@ -186,6 +186,7 @@
 		layout.itemO("pose.select_all_toggle", text="Select/Deselect All")
 		layout.itemO("pose.select_inverse", text="Inverse")
 		layout.itemO("pose.select_constraint_target", text="Constraint Target")
+		layout.itemO("pose.select_linked", text="Linked")
 		
 		layout.itemS()
 		

Modified: branches/blender2.5/blender/source/blender/editors/armature/poseobject.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/poseobject.c	2009-09-08 01:18:06 UTC (rev 23054)
+++ branches/blender2.5/blender/source/blender/editors/armature/poseobject.c	2009-09-08 02:09:14 UTC (rev 23055)
@@ -125,9 +125,8 @@
 	
 	switch (ob->type){
 		case OB_ARMATURE:
-			
+			ob->restore_mode = ob->mode;
 			ob->mode |= OB_MODE_POSE;
-			base->flag= ob->flag;
 			
 			WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_POSE, NULL);
 			
@@ -136,7 +135,7 @@
 			return;
 	}
 
-	ED_object_toggle_modes(C, ob->mode);
+	//ED_object_toggle_modes(C, ob->mode);
 }
 
 void ED_armature_exit_posemode(bContext *C, Base *base)
@@ -144,8 +143,8 @@
 	if(base) {
 		Object *ob= base->object;
 		
+		ob->restore_mode = ob->mode;
 		ob->mode &= ~OB_MODE_POSE;
-		base->flag= ob->flag;
 		
 		WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL);
 	}	

Modified: branches/blender2.5/blender/source/blender/editors/object/object_edit.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/object/object_edit.c	2009-09-08 01:18:06 UTC (rev 23054)
+++ branches/blender2.5/blender/source/blender/editors/object/object_edit.c	2009-09-08 02:09:14 UTC (rev 23055)
@@ -7247,7 +7247,7 @@
 
 static const char *object_mode_op_string(int mode)
 {
-	if(mode == OB_MODE_EDIT)
+	if(mode & OB_MODE_EDIT)
 		return "OBJECT_OT_editmode_toggle";
 	if(mode == OB_MODE_SCULPT)
 		return "SCULPT_OT_sculptmode_toggle";
@@ -7333,6 +7333,8 @@
 		WM_operator_name_call(C, "PAINT_OT_texture_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL);
 	if(mode & OB_MODE_PARTICLE_EDIT)
 		WM_operator_name_call(C, "PARTICLE_OT_particle_edit_toggle", WM_OP_EXEC_REGION_WIN, NULL);
+	if(mode & OB_MODE_POSE)
+		WM_operator_name_call(C, "OBJECT_OT_posemode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
 }
 
 /* game property ops */

Modified: branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_header.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_header.c	2009-09-08 01:18:06 UTC (rev 23054)
+++ branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_header.c	2009-09-08 02:09:14 UTC (rev 23055)
@@ -1551,12 +1551,18 @@
 	if(ob==NULL) return string;
 	
 	/* if active object is editable */
-	if ( ((ob->type == OB_MESH) || (ob->type == OB_ARMATURE)
+	if ( ((ob->type == OB_MESH)
 		|| (ob->type == OB_CURVE) || (ob->type == OB_SURF) || (ob->type == OB_FONT)
 		|| (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) {
 		
 		str += sprintf(str, formatstr, "Edit Mode", OB_MODE_EDIT, ICON_EDITMODE_HLT);
 	}
+	else if (ob->type == OB_ARMATURE) {
+		if (ob->mode & OB_MODE_POSE)
+			str += sprintf(str, formatstr, "Edit Mode", OB_MODE_EDIT|OB_MODE_POSE, ICON_EDITMODE_HLT);
+		else
+			str += sprintf(str, formatstr, "Edit Mode", OB_MODE_EDIT, ICON_EDITMODE_HLT);
+	}
 
 	if (ob->type == OB_MESH) {
 
@@ -1715,6 +1721,7 @@
 		WM_operator_properties_create(&props_ptr, "OBJECT_OT_mode_set");
 		RNA_enum_set(&props_ptr, "mode", v3d->modeselect);
 		WM_operator_name_call(C, "OBJECT_OT_mode_set", WM_OP_EXEC_REGION_WIN, &props_ptr);
+		WM_operator_properties_free(&props_ptr);
 		break;		
 	case B_AROUND:
 // XXX		handle_view3d_around(); /* copies to other 3d windows */
@@ -2179,7 +2186,7 @@
 		uiDefIconBut(block, BUT, B_VIEWRENDER, ICON_SCENE, xco,yco,XIC,YIC, NULL, 0, 1.0, 0, 0, "Render this window (Ctrl Click for anim)");
 		
 		if (ob && (ob->mode & OB_MODE_POSE)) {
-			xco+= XIC;
+			xco+= XIC*2;
 			uiBlockBeginAlign(block);
 			
 			uiDefIconButO(block, BUT, "POSE_OT_copy", WM_OP_INVOKE_REGION_WIN, ICON_COPYDOWN, xco,yco,XIC,YIC, NULL);

Modified: branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.c	2009-09-08 01:18:06 UTC (rev 23054)
+++ branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.c	2009-09-08 02:09:14 UTC (rev 23055)
@@ -91,10 +91,12 @@
 	
 	char idname_bl[OP_MAX_TYPENAME]; // XXX, needed to support python style names without the _OT_ syntax
 	WM_operator_bl_idname(idname_bl, idname);
-
-	for(ot= global_ops.first; ot; ot= ot->next) {
-		if(strncmp(ot->idname, idname_bl, OP_MAX_TYPENAME)==0)
-		   return ot;
+	
+	if (idname_bl[0]) {
+		for(ot= global_ops.first; ot; ot= ot->next) {
+			if(strncmp(ot->idname, idname_bl, OP_MAX_TYPENAME)==0)
+			   return ot;
+		}
 	}
 	
 	if(!quiet)
@@ -109,10 +111,12 @@
 	
 	char idname_bl[OP_MAX_TYPENAME]; // XXX, needed to support python style names without the _OT_ syntax
 	WM_operator_bl_idname(idname_bl, idname);
-
-	for(ot= global_ops.first; ot; ot= ot->next) {
-		if(strncmp(ot->idname, idname_bl, OP_MAX_TYPENAME)==0)
-		   return ot;
+	
+	if(idname_bl[0]) {
+		for(ot= global_ops.first; ot; ot= ot->next) {
+			if(strncmp(ot->idname, idname_bl, OP_MAX_TYPENAME)==0)
+			   return ot;
+		}
 	}
 	return NULL;
 }
@@ -322,21 +326,25 @@
 /* some.op -> SOME_OT_op */
 void WM_operator_bl_idname(char *to, const char *from)
 {
-	char *sep= strchr(from, '.');
+	if (from) {
+		char *sep= strchr(from, '.');
 
-	if(sep) {
-		int i, ofs= (sep-from);
+		if(sep) {
+			int i, ofs= (sep-from);
 
-		for(i=0; i<ofs; i++)
-			to[i]= toupper(from[i]);
+			for(i=0; i<ofs; i++)
+				to[i]= toupper(from[i]);
 
-		BLI_strncpy(to+ofs, "_OT_", OP_MAX_TYPENAME);
-		BLI_strncpy(to+(ofs+4), sep+1, OP_MAX_TYPENAME);
+			BLI_strncpy(to+ofs, "_OT_", OP_MAX_TYPENAME);
+			BLI_strncpy(to+(ofs+4), sep+1, OP_MAX_TYPENAME);
+		}
+		else {
+			/* should not happen but support just incase */
+			BLI_strncpy(to, from, OP_MAX_TYPENAME);
+		}
 	}
-	else {
-		/* should not happen but support just incase */
-		BLI_strncpy(to, from, OP_MAX_TYPENAME);
-	}
+	else
+		to[0]= 0;
 }
 
 /* print a string representation of the operator, with the args that it runs 





More information about the Bf-blender-cvs mailing list