Fix: "Jump To Target" showing up in workspace context menu

Issue introduced on d227c58e3e.

This was affecting WorkSpaces as well as background scene and probably
other places. We use the operator poll to decide whether to show it.

Reviewers: brecht, mont29

Differential Revision: https://developer.blender.org/D4488
This commit is contained in:
Dalai Felinto 2019-03-15 10:49:26 -03:00
parent d5d518b96c
commit 2e043c266b
3 changed files with 13 additions and 5 deletions

View File

@ -678,9 +678,13 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but)
/* Pointer properties and string properties with
* prop_search support jumping to target object/bone. */
if (but->rnapoin.data && but->rnaprop) {
const PropertyType type = RNA_property_type(but->rnaprop);
if ((type == PROP_POINTER) || (type == PROP_STRING && but->type == UI_BTYPE_SEARCH_MENU && but->search_func == ui_rna_collection_search_cb)) {
const PropertyType prop_type = RNA_property_type(but->rnaprop);
if (((prop_type == PROP_POINTER) ||
(prop_type == PROP_STRING &&
but->type == UI_BTYPE_SEARCH_MENU &&
but->search_func == ui_rna_collection_search_cb)) &&
ui_jump_to_target_button_poll(C))
{
uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Jump To Target"),
ICON_NONE, "UI_OT_jump_to_target_button");
uiItemS(layout);

View File

@ -900,4 +900,8 @@ typedef struct uiRNACollectionSearch {
} uiRNACollectionSearch;
void ui_rna_collection_search_cb(const struct bContext *C, void *arg, const char *str, uiSearchItems *items);
/* interface_ops.c */
bool ui_jump_to_target_button_poll(struct bContext *C);
#endif /* __INTERFACE_INTERN_H__ */

View File

@ -949,7 +949,7 @@ static bool jump_to_target_button(bContext *C, bool poll)
return false;
}
static bool jump_to_target_button_poll(bContext *C)
bool ui_jump_to_target_button_poll(bContext *C)
{
return jump_to_target_button(C, true);
}
@ -969,7 +969,7 @@ static void UI_OT_jump_to_target_button(wmOperatorType *ot)
ot->description = "Switch to the target object or bone";
/* callbacks */
ot->poll = jump_to_target_button_poll;
ot->poll = ui_jump_to_target_button_poll;
ot->exec = jump_to_target_button_exec;
/* flags */