fix [#35984] no way to know if a datablock is in editmode

the report explains the issue in detail, but basically you couldn't know if a mesh was in editmode without checking all the objects that use it.
add `is_editmode` readonly property for all datatypes which support editmode.

also make rna fail to build on implicit function declarations.
This commit is contained in:
2013-07-03 22:57:00 +00:00
parent 374383997c
commit a0cfa3e420
6 changed files with 67 additions and 0 deletions

View File

@@ -26,6 +26,11 @@
# Generated code has some unused vars we can ignore.
remove_strict_flags()
if(CMAKE_COMPILER_IS_GNUCC)
# add here so we fail early.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=implicit-function-declaration")
endif()
# message(STATUS "Configuring makesrna")
# files rna_access.c rna_define.c makesrna.c intentionally excluded.

View File

@@ -472,6 +472,12 @@ static void rna_Armature_bones_next(CollectionPropertyIterator *iter)
iter->valid = (internal->link != NULL);
}
static int rna_Armature_is_editmode_get(PointerRNA *ptr)
{
bArmature *arm = (bArmature *)ptr->id.data;
return (arm->edbo != NULL);
}
#else
static int rna_matrix_dimsize_4x4[] = {4, 4};
@@ -1071,6 +1077,12 @@ static void rna_def_armature(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
/* XXX deprecated ....... old animviz for armatures only */
prop = RNA_def_property(srna, "is_editmode", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_Armature_is_editmode_get", NULL);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Is Editmode", "True when used in editmode");
}
void RNA_def_armature(BlenderRNA *brna)

View File

@@ -683,6 +683,18 @@ static void rna_Curve_splines_begin(CollectionPropertyIterator *iter, PointerRNA
rna_iterator_listbase_begin(iter, BKE_curve_nurbs_get(cu), NULL);
}
static int rna_Curve_is_editmode_get(PointerRNA *ptr)
{
Curve *cu = (Curve *)ptr->id.data;
const short type = BKE_curve_type_get(cu);
if (type == OB_FONT) {
return (cu->editfont != NULL);
}
else {
return (cu->editnurb != NULL);
}
}
#else
static void rna_def_bpoint(BlenderRNA *brna)
@@ -1485,6 +1497,11 @@ static void rna_def_curve(BlenderRNA *brna)
RNA_def_property_range(prop, 0, 1.0);
RNA_def_property_ui_text(prop, "End Bevel Factor", "Factor that defines to where beveling of spline happens (0=to the very beginning, 1=to the very end)");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
prop = RNA_def_property(srna, "is_editmode", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_Curve_is_editmode_get", NULL);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Is Editmode", "True when used in editmode");
}
static void rna_def_curve_nurb(BlenderRNA *brna)

View File

@@ -234,6 +234,11 @@ static char *rna_LatticePoint_path(PointerRNA *ptr)
return BLI_strdup("");
}
static int rna_Lattice_is_editmode_get(PointerRNA *ptr)
{
Lattice *lt = (Lattice *)ptr->id.data;
return (lt->editlatt != NULL);
}
#else
@@ -350,6 +355,11 @@ static void rna_def_lattice(BlenderRNA *brna)
"rna_iterator_array_end", "rna_iterator_array_get", NULL, NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Points", "Points of the lattice");
prop = RNA_def_property(srna, "is_editmode", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_Lattice_is_editmode_get", NULL);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Is Editmode", "True when used in editmode");
/* pointers */
rna_def_animdata_common(srna);
}

View File

@@ -1556,6 +1556,13 @@ static PointerRNA rna_Mesh_tessface_uv_texture_new(struct Mesh *me, ReportList *
return ptr;
}
static int rna_Mesh_is_editmode_get(PointerRNA *ptr)
{
Mesh *me = rna_mesh(ptr);
return (me->edit_btmesh != NULL);
}
/* only to quiet warnings */
static void UNUSED_FUNCTION(rna_mesh_unused)(void)
{
@@ -3211,6 +3218,11 @@ static void rna_def_mesh(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Selected Face Total", "Selected face count in editmode");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
prop = RNA_def_property(srna, "is_editmode", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_Mesh_is_editmode_get", NULL);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Is Editmode", "True when used in editmode");
/* pointers */
rna_def_animdata_common(srna);
rna_def_texmat_common(srna, "rna_Mesh_texspace_editable");

View File

@@ -158,6 +158,12 @@ static void rna_MetaBall_elements_clear(MetaBall *mb)
}
}
static int rna_Meta_is_editmode_get(PointerRNA *ptr)
{
MetaBall *mb = ptr->id.data;
return (mb->editelems != NULL);
}
#else
static void rna_def_metaelement(BlenderRNA *brna)
@@ -350,6 +356,11 @@ static void rna_def_metaball(BlenderRNA *brna)
RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */
RNA_def_property_collection_funcs(prop, 0, NULL, NULL, NULL, NULL, NULL, NULL, "rna_IDMaterials_assign_int");
prop = RNA_def_property(srna, "is_editmode", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_Meta_is_editmode_get", NULL);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Is Editmode", "True when used in editmode");
/* anim */
rna_def_animdata_common(srna);