fix [#30087] operator_context is different for popup and submenu's *TODO, after 2.62*
authorCampbell Barton <ideasman42@gmail.com>
Fri, 26 Oct 2012 06:22:54 +0000 (06:22 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 26 Oct 2012 06:22:54 +0000 (06:22 +0000)
having context different for menu vs submenu is quite confusing, now they are both: WM_OP_INVOKE_REGION_WIN
this changes WM_menu_invoke behavior.

source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/interface_regions.c
source/blender/editors/screen/screen_ops.c
source/blender/windowmanager/intern/wm_operators.c
source/blender/windowmanager/intern/wm_window.c

index 96e089ee151c89e70bc458f95691d933b95ef7db..df18e9cc6ecc13d4a8bd6ea6514fa67c5f53a247 100644 (file)
@@ -1450,6 +1450,11 @@ static void ui_item_menutype_func(bContext *C, uiLayout *layout, void *arg_mt)
 
        menu.type = mt;
        menu.layout = layout;
+
+       if (G.debug & G_DEBUG_WM) {
+               printf("%s: opening menu \"%s\"\n", __func__, mt->idname);
+       }
+
        mt->draw(C, &menu);
 }
 
index 81327ad10a24768218c1772acbb8f578abb83eed..d7f718c762f6e4da23cec680d0bc2fca74321198 100644 (file)
@@ -46,6 +46,7 @@
 
 #include "BKE_context.h"
 #include "BKE_screen.h"
+#include "BKE_global.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -2510,6 +2511,9 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon)
        pup->block->flag |= UI_BLOCK_POPUP_MEMORY;
        pup->block->puphash = ui_popup_menu_hash(title);
        pup->layout = uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style);
+
+       /* note, this intentionally differs from the menu & submenu default because many operators
+        * use popups like this to select one of their options - where having invoke doesn't make sense */
        uiLayoutSetOperatorContext(pup->layout, WM_OP_EXEC_REGION_WIN);
 
        /* create in advance so we can let buttons point to retval already */
@@ -2721,6 +2725,10 @@ void uiPupMenuInvoke(bContext *C, const char *idname)
        menu.layout = layout;
        menu.type = mt;
 
+       if (G.debug & G_DEBUG_WM) {
+               printf("%s: opening menu \"%s\"\n", __func__, idname);
+       }
+
        mt->draw(C, &menu);
 
        uiPupMenuEnd(C, pup);
index 4a10193d726ecf7be1c4b8c0affd6b16e9004abe..eacf7c7032df80d7c957dbf3010ec264cff8fb15 100644 (file)
@@ -3082,6 +3082,9 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e
                }
                else {
                        if (sync) {
+                               /* note: this is very simplistic,
+                                * its has problem that it may skip too many frames.
+                                * however at least this gives a less jittery playback */
                                const int step = max_ii(1, floor((wt->duration - sad->last_duration) * FPS));
 
                                /* skip frames */
index 9a414f7ce1dcd859e365aa89f1870d2cc3933796..af6ec370fea625a18ae50cfb1c9c412033c3abbb 100644 (file)
@@ -674,6 +674,8 @@ int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
        else {
                pup = uiPupMenuBegin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE);
                layout = uiPupMenuLayout(pup);
+               /* set this so the default execution context is the same as submenus */
+               uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_REGION_WIN);
                uiItemsFullEnumO(layout, op->type->idname, RNA_property_identifier(prop), op->ptr->data, WM_OP_EXEC_REGION_WIN, 0);
                uiPupMenuEnd(C, pup);
        }
index 3b0660f4301f92b991bc3262cfddcf3d586b05a1..7d5dc858b0088f4d080d6f39caacf75d34c284f0 100644 (file)
@@ -1080,7 +1080,7 @@ char *WM_clipboard_text_get(int selection)
                return NULL;
        
        /* always convert from \r\n to \n */
-       newbuf = MEM_callocN(strlen(buf) + 1, "WM_clipboard_text_get");
+       newbuf = MEM_callocN(strlen(buf) + 1, __func__);
 
        for (p = buf, p2 = newbuf; *p; p++) {
                if (*p != '\r')