[Bf-blender-cvs] [908e6c7c4d6] master: Fix crash when displaying some button tooltips

Julian Eisel noreply at git.blender.org
Fri May 13 17:54:17 CEST 2022


Commit: 908e6c7c4d658615bd0d384d28e9f1b8c001c7a5
Author: Julian Eisel
Date:   Fri May 13 17:48:10 2022 +0200
Branches: master
https://developer.blender.org/rB908e6c7c4d658615bd0d384d28e9f1b8c001c7a5

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.

===================================================================

M	source/blender/editors/interface/interface_handlers.c

===================================================================

diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 3b5d8ce89f2..d98717206ea 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -8712,28 +8712,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, &region->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))) {



More information about the Bf-blender-cvs mailing list