[Bf-blender-cvs] [d9ac4653e70] blender2.8: Fix T59574: Prop_search fails to set objects from scene.

Bastien Montagne noreply at git.blender.org
Wed Dec 19 17:03:11 CET 2018


Commit: d9ac4653e70cace968d5a2d3acca894e4168b056
Author: Bastien Montagne
Date:   Wed Dec 19 16:59:24 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBd9ac4653e70cace968d5a2d3acca894e4168b056

Fix T59574: Prop_search fails to set objects from scene.

Another case where editstr from search button would be used, when we
actually have desired pointer itself already available in button.

Am growing tired of doing bandaids fixes on that search menu stuff,
whole thing would require some real re-coding imho, to get rid of that
tantacular dependency over string 'identifier' only (when we should also
have access to at the very least, the active index, and also probably
active data pointer itself...).
And/or clearly separate string identifier from 'UI' string shown to user.

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

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

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

diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 6dcee242f1e..d90135001c4 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -2594,8 +2594,19 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
 					PointerRNA ptr = but->rnasearchpoin;
 					PropertyRNA *prop = but->rnasearchprop;
 
-					if (prop && RNA_property_collection_lookup_string(&ptr, prop, str, &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 (prop && RNA_property_collection_lookup_string(&ptr, prop, str, &rptr)) {
 						RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr);
+					}
+					else if (but->func_arg2 != NULL) {
+						RNA_pointer_create(NULL, RNA_property_pointer_type(&but->rnapoin, but->rnaprop), but->func_arg2, &rptr);
+						RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr);
+					}
 
 					return true;
 				}



More information about the Bf-blender-cvs mailing list