diff options
author | Julian Eisel <julian@blender.org> | 2022-05-13 18:48:10 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2022-05-13 18:56:18 +0300 |
commit | 8e717ce55aee27cc97b44770026792f65dd106ca (patch) | |
tree | a24065fd74ed18ad78a2401306a13c14fe2cce6d /source/blender | |
parent | 8d43ee1b0823e6e5fae2fdceaee0a94d3d61f9b7 (diff) |
Fix crash when displaying some button tooltips
Steps to reproduce were:
- Factory startup
- Right-click in 3D View
- Move the mouse over "Shade Flat", wait for the tooltip
The changed logic in 4680331749aa to lookup an active button was
incorrect. It didn't respect the priority of active button candidates.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 9d30ad992c9..d2dfa3c2285 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -8709,28 +8709,36 @@ static uiBut *ui_context_button_active(const ARegion *region, bool (*but_check_c uiBut *but_found = NULL; while (region) { - uiBut *activebut = NULL; + /* Follow this exact priority (from highest to lowest priority): + * 1) Active-override button (#UI_BUT_ACTIVE_OVERRIDE). + * 2) The real active button. + * 3) The previously active button (#UI_BUT_LAST_ACTIVE). + */ + uiBut *active_but_override = NULL; + uiBut *active_but_real = NULL; + uiBut *active_but_last = NULL; /* find active button */ LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) { LISTBASE_FOREACH (uiBut *, but, &block->buttons) { if (but->flag & UI_BUT_ACTIVE_OVERRIDE) { - activebut = but; - break; + active_but_override = but; } if (but->active) { - activebut = but; - break; + active_but_real = but; } if (but->flag & UI_BUT_LAST_ACTIVE) { - activebut = but; - break; + active_but_last = but; } } + } - if (activebut) { - break; - } + uiBut *activebut = active_but_override; + if (!activebut) { + activebut = active_but_real; + } + if (!activebut) { + activebut = active_but_last; } if (activebut && (but_check_cb == NULL || but_check_cb(activebut))) { |