[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23079] branches/blender2.5/blender/source /blender/windowmanager/intern/wm_operators.c: 2.5: WM_menu_invoke now uses the first enum property it can find,

Brecht Van Lommel brecht at blender.org
Wed Sep 9 13:10:28 CEST 2009


Revision: 23079
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23079
Author:   blendix
Date:     2009-09-09 13:10:28 +0200 (Wed, 09 Sep 2009)

Log Message:
-----------
2.5: WM_menu_invoke now uses the first enum property it can find,
if no enum property named "type" is available.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.c

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-09 11:05:10 UTC (rev 23078)
+++ branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.c	2009-09-09 11:10:28 UTC (rev 23079)
@@ -448,13 +448,24 @@
 /* ************ default op callbacks, exported *********** */
 
 /* invoke callback, uses enum property named "type" */
-/* only weak thing is the fixed property name... */
 int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-	PropertyRNA *prop= RNA_struct_find_property(op->ptr, "type");
+	PropertyRNA *prop;
 	uiPopupMenu *pup;
 	uiLayout *layout;
 
+	prop= RNA_struct_find_property(op->ptr, "type");
+
+	if(!prop) {
+		RNA_STRUCT_BEGIN(op->ptr, findprop) {
+			if(RNA_property_type(findprop) == PROP_ENUM) {
+				prop= findprop;
+				break;
+			}
+		}
+		RNA_STRUCT_END;
+	}
+
 	if(prop==NULL) {
 		printf("WM_menu_invoke: %s has no \"type\" enum property\n", op->type->idname);
 	}
@@ -464,7 +475,7 @@
 	else {
 		pup= uiPupMenuBegin(C, op->type->name, 0);
 		layout= uiPupMenuLayout(pup);
-		uiItemsEnumO(layout, op->type->idname, "type");
+		uiItemsEnumO(layout, op->type->idname, (char*)RNA_property_identifier(prop));
 		uiPupMenuEnd(C, pup);
 	}
 





More information about the Bf-blender-cvs mailing list