From f0ed536672e4ae3e588ffe21a8311cfdc1c70191 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Wed, 17 Jan 2024 16:32:48 +0100 Subject: [PATCH] Fix #117116: Online manual option not working in context menu This was the case when the context menu was spawned from a button in a menu that was in turn spawned via `WM_OT_call_menu`. Then, `UI_context_active_but_get` (or `UI_context_active_but_get_respect_menu` even) are not getting an active button. Reason for this is that the current context region (or the region stored in the popup) is freed from its blocks _somewhere_ along the way when actually executing the operator. The code around nested menus is a bit hard to follow, the underlying issue (not having a valid region in context to work with at all times) should definitely be solved (for another reason, see NOTE / DOWNSIDE below). However, there is another way to solve this, and this is calling `doc_view_manual` directly with its `doc_id` set already (the `doc_id` is already available when building the context menu, used for the `Online Python Reference`). NOTE: the same failure is true for `Copy Python Command` -- and the "workaround fix" is a bit more work there (it does not have a vairiant **not** using the context buttons). DOWNSIDE: we loose the shortcut (F1) shown in the context menu, because that still needs to point to `doc_view_manual_ui_context` --- .../editors/interface/interface_context_menu.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/interface/interface_context_menu.cc b/source/blender/editors/interface/interface_context_menu.cc index 009c8d9ff72..a3b9f031bc1 100644 --- a/source/blender/editors/interface/interface_context_menu.cc +++ b/source/blender/editors/interface/interface_context_menu.cc @@ -1266,10 +1266,15 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev if (UI_but_online_manual_id(but, buf, sizeof(buf))) { PointerRNA ptr_props; - uiItemO(layout, - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Online Manual"), - ICON_URL, - "WM_OT_doc_view_manual_ui_context"); + uiItemFullO(layout, + "WM_OT_doc_view_manual", + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Online Manual"), + ICON_NONE, + nullptr, + WM_OP_EXEC_DEFAULT, + UI_ITEM_NONE, + &ptr_props); + RNA_string_set(&ptr_props, "doc_id", buf); if (U.flag & USER_DEVELOPER_UI) { uiItemFullO(layout, -- 2.30.2