tweak to WM_operatortype_find to perform better when called with empty strings (as...
authorCampbell Barton <ideasman42@gmail.com>
Fri, 2 Sep 2011 08:01:01 +0000 (08:01 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 2 Sep 2011 08:01:01 +0000 (08:01 +0000)
source/blender/windowmanager/intern/wm_operators.c

index c053022681b70473f787e5bbd1f3ec0ad5de2ed3..0e0203543a4c3258bc3106a915234f4c9554ed10 100644 (file)
@@ -108,21 +108,28 @@ static GHash *global_ops_hash= NULL;
 
 wmOperatorType *WM_operatortype_find(const char *idname, int quiet)
 {
-       wmOperatorType *ot;
-       
-       char idname_bl[OP_MAX_TYPENAME]; // XXX, needed to support python style names without the _OT_ syntax
-       WM_operator_bl_idname(idname_bl, idname);
+       if(idname[0]) {
+               wmOperatorType *ot;
+
+               /* needed to support python style names without the _OT_ syntax */
+               char idname_bl[OP_MAX_TYPENAME];
+               WM_operator_bl_idname(idname_bl, idname);
 
-       if (idname_bl[0]) {
                ot= BLI_ghash_lookup(global_ops_hash, idname_bl);
                if(ot) {
                        return ot;
                }
+
+               if(!quiet) {
+                       printf("search for unknown operator '%s', '%s'\n", idname_bl, idname);
+               }
        }
-       
-       if(!quiet)
-               printf("search for unknown operator %s, %s\n", idname_bl, idname);
-       
+       else {
+               if(!quiet) {
+                       printf("search for empty operator\n");
+               }
+       }
+
        return NULL;
 }