[Bf-committers] [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,

Campbell Barton ideasman42 at gmail.com
Sat Sep 12 02:42:11 CEST 2009


This seems error prone to me, since operators are accessed as a tools
API as well as by the user, someone could add new option to an
operator (or re-arrange options) without realizing it would break the
existing workflow (make docs invalid too).
While the likelihood is lowered because only new enums could override
existing and they'd need to be added before the existing ones, Id
prefer this be explicit so when you look at the operator its obvious
which enum is used for the interface menu.

A flag be used to set an enum as being used by the popup menu similar
to how return values are flagged for functions, can add this unless
you think theres some better way.

On Wed, Sep 9, 2009 at 4:10 AM, Brecht Van Lommel <brecht at blender.org> wrote:
> 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);
>        }
>
>
>
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>



-- 
- Campbell


More information about the Bf-committers mailing list