[Bf-blender-cvs] [4de632b48b3] temp-ui-button-type-refactor: Merge branch 'master' into temp-ui-button-type-refactor

Julian Eisel noreply at git.blender.org
Fri Jul 3 16:03:06 CEST 2020


Commit: 4de632b48b3ca2bbfcd1a649c6512f7bdc741074
Author: Julian Eisel
Date:   Fri Jul 3 15:37:04 2020 +0200
Branches: temp-ui-button-type-refactor
https://developer.blender.org/rB4de632b48b3ca2bbfcd1a649c6512f7bdc741074

Merge branch 'master' into temp-ui-button-type-refactor

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



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

diff --cc source/blender/editors/interface/interface.c
index 04477eb883f,6c1f9d4f017..5964aece875
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@@ -2945,37 -2922,30 +2928,34 @@@ bool ui_but_string_set(bContext *C, uiB
            RNA_property_pointer_set(&but->rnapoin, but->rnaprop, PointerRNA_NULL, NULL);
            return true;
          }
-         else {
-           uiButSearch *search_but = (but->type == UI_BTYPE_SEARCH_MENU) ? (uiButSearch *)but :
-                                                                           NULL;
-           /* RNA pointer */
-           PointerRNA rptr;
- 
-           /* This is kind of hackish, in theory think we could only ever use the second member of
-            * this if/else, since ui_searchbox_apply() is supposed to always set that pointer when
-            * we are storing pointers... But keeping str search first for now,
-            * to try to break as little as possible existing code. All this is band-aids anyway.
-            * Fact remains, using editstr as main 'reference' over whole search button thingy
-            * is utterly weak and should be redesigned imho, but that's not a simple task. */
-           if (search_but && search_but->rnasearchprop &&
-               RNA_property_collection_lookup_string(
-                   &search_but->rnasearchpoin, search_but->rnasearchprop, str, &rptr)) {
-             RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr, NULL);
-           }
-           else if (search_but->item_active != NULL) {
-             RNA_pointer_create(NULL,
-                                RNA_property_pointer_type(&but->rnapoin, but->rnaprop),
-                                search_but->item_active,
-                                &rptr);
-             RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr, NULL);
-           }
 +
-           return true;
++        uiButSearch *search_but = (but->type == UI_BTYPE_SEARCH_MENU) ? (uiButSearch *)but : NULL;
+         /* RNA pointer */
+         PointerRNA rptr;
 -        PointerRNA ptr = but->rnasearchpoin;
 -        PropertyRNA *prop = but->rnasearchprop;
+ 
+         /* This is kind of hackish, in theory think we could only ever use the second member of
+          * this if/else, since ui_searchbox_apply() is supposed to always set that pointer when
+          * we are storing pointers... But keeping str search first for now,
+          * to try to break as little as possible existing code. All this is band-aids anyway.
+          * Fact remains, using editstr as main 'reference' over whole search button thingy
+          * is utterly weak and should be redesigned imho, but that's not a simple task. */
 -        if (prop && RNA_property_collection_lookup_string(&ptr, prop, str, &rptr)) {
++        if (search_but && search_but->rnasearchprop &&
++            RNA_property_collection_lookup_string(
++                &search_but->rnasearchpoin, search_but->rnasearchprop, str, &rptr)) {
+           RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr, NULL);
+         }
 -        else if (but->func_arg2 != NULL) {
 -          RNA_pointer_create(
 -              NULL, RNA_property_pointer_type(&but->rnapoin, but->rnaprop), but->func_arg2, &rptr);
++        else if (search_but->item_active != NULL) {
++          RNA_pointer_create(NULL,
++                             RNA_property_pointer_type(&but->rnapoin, but->rnaprop),
++                             search_but->item_active,
++                             &rptr);
+           RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr, NULL);
          }
  
-         return false;
+         return true;
        }
-       else if (type == PROP_ENUM) {
+ 
+       if (type == PROP_ENUM) {
          int value;
          if (RNA_property_enum_value(
                  but->block->evil_C, &but->rnapoin, but->rnaprop, str, &value)) {
diff --cc source/blender/editors/interface/interface_ops.c
index 1f1be494586,5237e2ea3f7..83506fd5d5e
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@@ -1132,13 -1144,12 +1144,13 @@@ static bool jump_to_target_button(bCont
        return jump_to_target_ptr(C, target_ptr, poll);
      }
      /* For string properties with prop_search, look up the search collection item. */
-     else if (type == PROP_STRING) {
+     if (type == PROP_STRING) {
        const uiBut *but = UI_context_active_but_get(C);
 +      const uiButSearch *search_but = (but->type == UI_BTYPE_SEARCH_MENU) ? (uiButSearch *)but :
 +                                                                            NULL;
  
 -      if (but->type == UI_BTYPE_SEARCH_MENU && but->search &&
 -          but->search->update_fn == ui_rna_collection_search_update_fn) {
 -        uiRNACollectionSearch *coll_search = but->search->arg;
 +      if (search_but && search_but->items_update_fn == ui_rna_collection_search_update_fn) {
 +        uiRNACollectionSearch *coll_search = search_but->arg;
  
          char str_buf[MAXBONENAME];
          char *str_ptr = RNA_property_string_get_alloc(&ptr, prop, str_buf, sizeof(str_buf), NULL);
diff --cc source/blender/editors/interface/interface_region_search.c
index b447aef78f3,307bab5ad79..5c519368cca
--- a/source/blender/editors/interface/interface_region_search.c
+++ b/source/blender/editors/interface/interface_region_search.c
@@@ -282,9 -286,9 +289,9 @@@ bool ui_searchbox_apply(uiBut *but, ARe
      const char *name = data->items.names[data->active];
      const char *name_sep = data->use_sep ? strrchr(name, UI_SEP_CHAR) : NULL;
  
-     BLI_strncpy(but->editstr, name, name_sep ? (name_sep - name) : data->items.maxstrlen);
+     BLI_strncpy(but->editstr, name, name_sep ? (name_sep - name) + 1 : data->items.maxstrlen);
  
 -    but->func_arg2 = data->items.pointers[data->active];
 +    search_but->item_active = data->items.pointers[data->active];
  
      return true;
    }



More information about the Bf-blender-cvs mailing list