From 6808e15c8d20819deddd6b175668d11a6c6f454d Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 8 Sep 2009 02:09:14 +0000 Subject: 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. --- source/blender/editors/armature/poseobject.c | 7 ++-- source/blender/editors/object/object_edit.c | 4 +- .../blender/editors/space_view3d/view3d_header.c | 11 +++++- source/blender/windowmanager/intern/wm_operators.c | 46 +++++++++++++--------- 4 files changed, 42 insertions(+), 26 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 2673640b213..a4a518bc003 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -125,9 +125,8 @@ void ED_armature_enter_posemode(bContext *C, Base *base) 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 @@ void ED_armature_enter_posemode(bContext *C, Base *base) 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 @@ void ED_armature_exit_posemode(bContext *C, Base *base) 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); } diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 9ef250d7963..9e61bbd3fb5 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -7247,7 +7247,7 @@ static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *ptr, in 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 @@ void ED_object_toggle_modes(bContext *C, int mode) 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 */ diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 45b0ea41215..a633969d557 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -1551,12 +1551,18 @@ static char *view3d_modeselect_pup(Scene *scene) 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 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event) 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 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) 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); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index b51fcfddc47..c7011777dbf 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -91,10 +91,12 @@ wmOperatorType *WM_operatortype_find(const char *idname, int quiet) 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 @@ wmOperatorType *WM_operatortype_exists(const char *idname) 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 @@ void WM_operator_py_idname(char *to, const char *from) /* 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