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.
This commit is contained in:
Bastien Montagne 2018-12-19 16:59:24 +01:00
parent 42bf7e440c
commit d9ac4653e7
Notes: blender-bot 2023-02-14 08:59:10 +01:00
Referenced by issue #73156, ID search menu issue with linked data-blocks
Referenced by issue #59574, Prop_search fails to set objects from scene
1 changed files with 12 additions and 1 deletions

View File

@ -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;
}