[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35741] trunk/blender/source/blender: RNA & interface functions for checking if RNA in a button uses valid rna property (not currently used).
Campbell Barton
ideasman42 at gmail.com
Thu Mar 24 10:27:42 CET 2011
Revision: 35741
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35741
Author: campbellbarton
Date: 2011-03-24 09:27:41 +0000 (Thu, 24 Mar 2011)
Log Message:
-----------
RNA & interface functions for checking if RNA in a button uses valid rna property (not currently used).
Modified Paths:
--------------
trunk/blender/source/blender/editors/interface/interface.c
trunk/blender/source/blender/editors/interface/interface_intern.h
trunk/blender/source/blender/makesrna/RNA_access.h
trunk/blender/source/blender/makesrna/intern/rna_access.c
Modified: trunk/blender/source/blender/editors/interface/interface.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface.c 2011-03-24 08:33:42 UTC (rev 35740)
+++ trunk/blender/source/blender/editors/interface/interface.c 2011-03-24 09:27:41 UTC (rev 35741)
@@ -1211,6 +1211,17 @@
return 1;
}
+int ui_is_but_rna_valid(uiBut *but)
+{
+ if (but->rnaprop==NULL || RNA_struct_contains_property(&but->rnapoin, but->rnaprop)) {
+ return TRUE;
+ }
+ else {
+ printf("property removed %s: %p :: %d\n", but->drawstr, but->rnaprop, (but->flag & UI_INVALID) ? 1 : 0);
+ return FALSE;
+ }
+}
+
double ui_get_but_val(uiBut *but)
{
PropertyRNA *prop;
Modified: trunk/blender/source/blender/editors/interface/interface_intern.h
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_intern.h 2011-03-24 08:33:42 UTC (rev 35740)
+++ trunk/blender/source/blender/editors/interface/interface_intern.h 2011-03-24 09:27:41 UTC (rev 35741)
@@ -376,6 +376,7 @@
extern void ui_check_but(uiBut *but);
extern int ui_is_but_float(uiBut *but);
extern int ui_is_but_unit(uiBut *but);
+extern int ui_is_but_rna_valid(uiBut *but);
extern void ui_bounds_block(uiBlock *block);
extern void ui_block_translate(uiBlock *block, int x, int y);
Modified: trunk/blender/source/blender/makesrna/RNA_access.h
===================================================================
--- trunk/blender/source/blender/makesrna/RNA_access.h 2011-03-24 08:33:42 UTC (rev 35740)
+++ trunk/blender/source/blender/makesrna/RNA_access.h 2011-03-24 09:27:41 UTC (rev 35741)
@@ -621,6 +621,7 @@
PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier);
+int RNA_struct_contains_property(PointerRNA *ptr, PropertyRNA *prop_test);
/* lower level functions for access to type properties */
const struct ListBase *RNA_struct_type_properties(StructRNA *srna);
Modified: trunk/blender/source/blender/makesrna/intern/rna_access.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_access.c 2011-03-24 08:33:42 UTC (rev 35740)
+++ trunk/blender/source/blender/makesrna/intern/rna_access.c 2011-03-24 09:27:41 UTC (rev 35741)
@@ -574,6 +574,28 @@
return prop;
}
+int RNA_struct_contains_property(PointerRNA *ptr, PropertyRNA *prop_test)
+{
+ /* note, prop_test could be freed memory, only use for comparison */
+
+ /* validate the RNA is ok */
+ PropertyRNA *iterprop;
+ int found= FALSE;
+
+ iterprop= RNA_struct_iterator_property(ptr->type);
+
+ RNA_PROP_BEGIN(ptr, itemptr, iterprop) {
+ /* PropertyRNA *prop= itemptr.data; */
+ if(prop_test == (PropertyRNA *)itemptr.data) {
+ found= TRUE;
+ break;
+ }
+ }
+ RNA_PROP_END;
+
+ return found;
+}
+
/* low level direct access to type->properties, note this ignores parent classes so should be used with care */
const struct ListBase *RNA_struct_type_properties(StructRNA *srna)
{
More information about the Bf-blender-cvs
mailing list