Fix T78907: Renaming file doesn't work while mouse is over file icon

The icons are label buttons. Usually these are not editable and can not
become active. These are draggable ones though (so dragging files can be
dragged by dragging the icon) which creates an exception to this rule.
So hovering the icon would activate its label and when executing the
rename operator via shortcut it wouldn't get exited properly. This broke
the invariant of only allowing a single active button at a time.
Added an assert to check that invariant now.

Letting the code to activate the text button ensure any currently active
button is exited seems sensible.
This commit is contained in:
2020-08-05 19:34:11 +02:00
parent 38e9a349de
commit 1b593edf1d
2 changed files with 9 additions and 0 deletions

View File

@@ -893,6 +893,12 @@ bool UI_but_active_only_ex(
}
}
if ((activate == true) || (found == false)) {
/* There might still be another active button. */
uiBut *old_active = ui_region_find_active_but(region);
if (old_active) {
ui_but_active_free(C, old_active);
}
ui_but_activate_event((bContext *)C, region, but);
}
else if ((found == true) && (isactive == false)) {

View File

@@ -8001,6 +8001,9 @@ static void button_activate_init(bContext *C,
{
uiHandleButtonData *data;
/* Only ever one active button! */
BLI_assert(ui_region_find_active_but(region) == NULL);
/* setup struct */
data = MEM_callocN(sizeof(uiHandleButtonData), "uiHandleButtonData");
data->wm = CTX_wm_manager(C);