[Bf-blender-cvs] [530008df1d1] master: Fix incorrect UI_SEP_CHAR checks

Campbell Barton noreply at git.blender.org
Wed Apr 15 09:36:55 CEST 2020


Commit: 530008df1d1cbc0318bbaa9c1a3a3908466d19c6
Author: Campbell Barton
Date:   Wed Apr 15 17:36:34 2020 +1000
Branches: master
https://developer.blender.org/rB530008df1d1cbc0318bbaa9c1a3a3908466d19c6

Fix incorrect UI_SEP_CHAR checks

- Menu drawing function used first instance instead of last.
- Menu hash function checked for the character without first
  checking UI_BUT_HAS_SEP_CHAR was enabled.

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

M	source/blender/editors/interface/interface_region_menu_popup.c
M	source/blender/editors/interface/interface_widgets.c

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

diff --git a/source/blender/editors/interface/interface_region_menu_popup.c b/source/blender/editors/interface/interface_region_menu_popup.c
index a161a449ba0..31ef7261eb3 100644
--- a/source/blender/editors/interface/interface_region_menu_popup.c
+++ b/source/blender/editors/interface/interface_region_menu_popup.c
@@ -88,11 +88,11 @@ int ui_but_menu_step(uiBut *but, int direction)
   return 0;
 }
 
-static uint ui_popup_string_hash(const char *str)
+static uint ui_popup_string_hash(const char *str, const bool use_sep)
 {
   /* sometimes button contains hotkey, sometimes not, strip for proper compare */
   int hash;
-  const char *delimit = strrchr(str, UI_SEP_CHAR);
+  const char *delimit = use_sep ? strrchr(str, UI_SEP_CHAR) : NULL;
 
   if (delimit) {
     hash = BLI_ghashutil_strhash_n(str, delimit - str);
@@ -126,13 +126,13 @@ static uiBut *ui_popup_menu_memory__internal(uiBlock *block, uiBut *but)
 
   if (but) {
     /* set */
-    mem[hash_mod] = ui_popup_string_hash(but->str);
+    mem[hash_mod] = ui_popup_string_hash(but->str, but->flag & UI_BUT_HAS_SEP_CHAR);
     return NULL;
   }
   else {
     /* get */
     for (but = block->buttons.first; but; but = but->next) {
-      if (ui_popup_string_hash(but->str) == mem[hash_mod]) {
+      if (mem[hash_mod] == ui_popup_string_hash(but->str, but->flag & UI_BUT_HAS_SEP_CHAR)) {
         return but;
       }
     }
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 361e5e76acc..ae40b01c77d 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -5279,7 +5279,7 @@ void ui_draw_menu_item(const uiFontStyle *fstyle,
 
   /* cut string in 2 parts? */
   if (use_sep) {
-    cpoin = strchr(name, UI_SEP_CHAR);
+    cpoin = strrchr(name, UI_SEP_CHAR);
     if (cpoin) {
       *cpoin = 0;



More information about the Bf-blender-cvs mailing list