[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51165] trunk/blender/source/blender/ editors/interface/interface.c: Fix memory leak and reduce code duplication from previous commit
Joshua Leung
aligorith at gmail.com
Mon Oct 8 08:07:37 CEST 2012
Revision: 51165
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51165
Author: aligorith
Date: 2012-10-08 06:07:36 +0000 (Mon, 08 Oct 2012)
Log Message:
-----------
Fix memory leak and reduce code duplication from previous commit
Modified Paths:
--------------
trunk/blender/source/blender/editors/interface/interface.c
Modified: trunk/blender/source/blender/editors/interface/interface.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface.c 2012-10-08 05:57:52 UTC (rev 51164)
+++ trunk/blender/source/blender/editors/interface/interface.c 2012-10-08 06:07:36 UTC (rev 51165)
@@ -3869,12 +3869,41 @@
}
}
else if (ELEM3(type, BUT_GET_RNAENUM_IDENTIFIER, BUT_GET_RNAENUM_LABEL, BUT_GET_RNAENUM_TIP)) {
+ PointerRNA *ptr = NULL;
+ PropertyRNA *prop = NULL;
+ int value = 0;
+
+ /* get the enum property... */
if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM) {
+ /* enum property */
+ ptr = &but->rnapoin;
+ prop = but->rnaprop;
+ value = (but->type == ROW) ? (int)but->hardmax : (int)ui_get_but_val(but);
+ }
+ else if (but->optype) {
+ PointerRNA *opptr = uiButGetOperatorPtrRNA(but);
+ wmOperatorType *ot = but->optype;
+
+ /* if the default property of the operator is enum and it is set,
+ * fetch the tooltip of the selected value so that "Snap" and "Mirror"
+ * operator menus in the Anim Editors will show tooltips for the different
+ * operations instead of the meaningless generic operator tooltip
+ */
+ if (ot->prop && RNA_property_type(ot->prop) == PROP_ENUM) {
+ if (RNA_struct_contains_property(opptr, ot->prop)) {
+ ptr = opptr;
+ prop = ot->prop;
+ value = RNA_property_enum_get(opptr, ot->prop);
+ }
+ }
+ }
+
+ /* get strings from matching enum item */
+ if (ptr && prop) {
if (!item) {
int i;
- int value = (but->type == ROW) ? (int)but->hardmax : (int)ui_get_but_val(but);
- RNA_property_enum_items_gettexted(C, &but->rnapoin, but->rnaprop, &items, &totitems, &free_items);
-
+
+ RNA_property_enum_items_gettexted(C, ptr, prop, &items, &totitems, &free_items);
for (i = 0, item = items; i < totitems; i++, item++) {
if (item->identifier[0] && item->value == value)
break;
@@ -3889,37 +3918,6 @@
tmp = BLI_strdup(item->description);
}
}
- else if (but->optype) {
- PointerRNA *opptr = uiButGetOperatorPtrRNA(but);
- wmOperatorType *ot = but->optype;
-
- /* if the default property of the operator is enum and it is set,
- * fetch the tooltip of the selected value so that "Snap" and "Mirror"
- * operator menus in the Anim Editors will show tooltips for the different
- * operations instead of the meaningless generic operator tooltip
- */
- if (ot->prop && RNA_property_type(ot->prop) == PROP_ENUM) {
- if (RNA_struct_contains_property(opptr, ot->prop)) {
- int value = RNA_property_enum_get(opptr, ot->prop);
- int i;
-
- RNA_property_enum_items_gettexted(C, opptr, ot->prop, &items, &totitems, &free_items);
- for (i = 0, item = items; i < totitems; i++, item++) {
- if (item->identifier[0] && item->value == value)
- break;
- }
-
- if (item && item->identifier) {
- if (type == BUT_GET_RNAENUM_IDENTIFIER)
- tmp = BLI_strdup(item->identifier);
- else if (type == BUT_GET_RNAENUM_LABEL)
- tmp = BLI_strdup(item->name);
- else if (item->description && item->description[0])
- tmp = BLI_strdup(item->description);
- }
- }
- }
- }
}
else if (type == BUT_GET_OP_KEYMAP) {
if (but->optype && !(but->block->flag & UI_BLOCK_LOOP)) {
More information about the Bf-blender-cvs
mailing list