From 173b998735ee30bdb4335ae2c65cf656d9249504 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Aug 2012 15:03:40 +0000 Subject: fix/edits to vector font handling - don't overwrite the font path with "" when the font file cant be found, it caused bad problems when loading files on someone elses systems when paths couldn't be found blender would silently clobber paths (tsk tsk). - when fonts are freed their temp data is now freed too. - assigning a new filepath to a font now refreshes the object data. --- source/blender/makesrna/intern/rna_vfont.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'source/blender/makesrna') diff --git a/source/blender/makesrna/intern/rna_vfont.c b/source/blender/makesrna/intern/rna_vfont.c index ad9c91b3623..b65db1c809c 100644 --- a/source/blender/makesrna/intern/rna_vfont.c +++ b/source/blender/makesrna/intern/rna_vfont.c @@ -32,19 +32,37 @@ #include "DNA_vfont_types.h" +#include "WM_types.h" + + #ifdef RNA_RUNTIME +#include "BKE_font.h" +#include "BKE_depsgraph.h" +#include "DNA_object_types.h" + +#include "WM_api.h" + /* matching fnction in rna_ID.c */ static int rna_VectorFont_filepath_editable(PointerRNA *ptr) { - VFont *vf = (VFont *)ptr->data; + VFont *vf = ptr->id.data; if (strcmp(vf->name, FO_BUILTIN_NAME) == 0) { return 0; } - return 1; } +static void rna_VectorFont_reload_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +{ + VFont *vf = ptr->id.data; + BKE_vfont_free_data(vf); + + /* update */ + WM_main_add_notifier(NC_GEOM | ND_DATA, NULL); + DAG_id_tag_update(&vf->id, OB_RECALC_OB | OB_RECALC_DATA); +} + #else void RNA_def_vfont(BlenderRNA *brna) @@ -61,6 +79,7 @@ void RNA_def_vfont(BlenderRNA *brna) RNA_def_property_string_sdna(prop, NULL, "name"); RNA_def_property_editable_func(prop, "rna_VectorFont_filepath_editable"); RNA_def_property_ui_text(prop, "File Path", ""); + RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_VectorFont_reload_update"); prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "packedfile"); -- cgit v1.2.3