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/windowmanager/intern/wm_operators.c | 46 +++++++++++++--------- 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'source/blender/windowmanager') 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