[Bf-blender-cvs] [dcf5c52] pie-menus: Change the enum fetching code to be order independent.
Antony Riakiotakis
noreply at git.blender.org
Wed Jul 30 17:20:36 CEST 2014
Commit: dcf5c52e440405d54889a3c4f8c4f94e3b6d0748
Author: Antony Riakiotakis
Date: Wed Jul 30 17:20:26 2014 +0200
Branches: pie-menus
https://developer.blender.org/rBdcf5c52e440405d54889a3c4f8c4f94e3b6d0748
Change the enum fetching code to be order independent.
This is done by checking each item in a dynamic enum for existence.
This can result in n^2 cost in worst case (for 8 items about 64 steps)
but since this is done once on initialization and makes the system more
robust, better prefer it.
===================================================================
M source/blender/makesrna/intern/rna_access.c
===================================================================
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index d29886e..fa9b235 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -1325,7 +1325,7 @@ void RNA_property_enum_items_gettexted_all(bContext *C, PointerRNA *ptr, Propert
if (eprop->itemf && (C != NULL || (prop->flag & PROP_ENUM_NO_CONTEXT))) {
EnumPropertyItem *item;
- int i, i_fixed;
+ int i;
bool free = false;
if (prop->flag & PROP_ENUM_NO_CONTEXT)
@@ -1336,23 +1336,21 @@ void RNA_property_enum_items_gettexted_all(bContext *C, PointerRNA *ptr, Propert
/* any callbacks returning NULL should be fixed */
BLI_assert(item != NULL);
- for (i = 0, i_fixed = 0; i < eprop->totitem; i++, i_fixed++) {
- /* ran out ouf valid entries, NULL out the rest*/
- if (!item[i_fixed].identifier) {
- while (i < eprop->totitem) {
- (*r_item)[i].name = NULL;
- (*r_item)[i].identifier = "";
- i++;
+ for (i = 0; i < eprop->totitem; i++) {
+ bool exists = false;
+ int i_fixed;
+
+ /* items that do not exist on list are returned, but have their names/identifiers NULLed out */
+ for (i_fixed = 0; item[i_fixed].identifier; i_fixed++) {
+ if (strcmp(item[i_fixed].identifier, (*r_item)[i].identifier) == 0) {
+ exists = true;
+ break;
}
- break;
}
- /* items that do not exist on list are returned, but have their names/identifiers NULLed out */
- while ((strcmp(item[i_fixed].identifier, (*r_item)[i].identifier) != 0) && i < eprop->totitem)
- {
+ if (!exists) {
(*r_item)[i].name = NULL;
(*r_item)[i].identifier = "";
- i++;
}
}
More information about the Bf-blender-cvs
mailing list