[Bf-blender-cvs] [716a8241d38] master: Cleanup: rename 'name' to 'filepath' for DNA types
Campbell Barton
noreply at git.blender.org
Tue Jun 23 03:30:55 CEST 2020
Commit: 716a8241d387180fd8ad69cdec33633bc7a0f963
Author: Campbell Barton
Date: Tue Jun 23 09:54:14 2020 +1000
Branches: master
https://developer.blender.org/rB716a8241d387180fd8ad69cdec33633bc7a0f963
Cleanup: rename 'name' to 'filepath' for DNA types
Using 'name' for the full path of a file reads badly,
especially when id.name is used in related code.
===================================================================
M source/blender/blenkernel/intern/bpath.c
M source/blender/blenkernel/intern/font.c
M source/blender/blenkernel/intern/image.c
M source/blender/blenkernel/intern/image_save.c
M source/blender/blenkernel/intern/library.c
M source/blender/blenkernel/intern/movieclip.c
M source/blender/blenkernel/intern/packedFile.c
M source/blender/blenkernel/intern/scene.c
M source/blender/blenkernel/intern/seqeffects.c
M source/blender/blenkernel/intern/sequencer.c
M source/blender/blenkernel/intern/sound.c
M source/blender/blenkernel/intern/text.c
M source/blender/blenloader/intern/blend_validate.c
M source/blender/blenloader/intern/readfile.c
M source/blender/blenloader/intern/versioning_270.c
M source/blender/blenloader/intern/versioning_legacy.c
M source/blender/blenloader/intern/writefile.c
M source/blender/draw/engines/workbench/workbench_materials.c
M source/blender/editors/curve/editfont.c
M source/blender/editors/interface/interface_ops.c
M source/blender/editors/interface/interface_region_tooltip.c
M source/blender/editors/sound/sound_ops.c
M source/blender/editors/space_clip/clip_ops.c
M source/blender/editors/space_file/filelist.c
M source/blender/editors/space_image/image_ops.c
M source/blender/editors/space_outliner/outliner_draw.c
M source/blender/editors/space_outliner/outliner_edit.c
M source/blender/editors/space_outliner/outliner_tree.c
M source/blender/editors/space_sequencer/sequencer_draw.c
M source/blender/editors/space_sequencer/sequencer_edit.c
M source/blender/editors/space_text/text_ops.c
M source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
M source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
M source/blender/makesdna/DNA_ID.h
M source/blender/makesdna/DNA_image_types.h
M source/blender/makesdna/DNA_movieclip_types.h
M source/blender/makesdna/DNA_sound_types.h
M source/blender/makesdna/DNA_text_types.h
M source/blender/makesdna/DNA_vfont_types.h
M source/blender/makesdna/intern/dna_rename_defs.h
M source/blender/makesrna/intern/rna_ID.c
M source/blender/makesrna/intern/rna_image.c
M source/blender/makesrna/intern/rna_image_api.c
M source/blender/makesrna/intern/rna_movieclip.c
M source/blender/makesrna/intern/rna_nodetree.c
M source/blender/makesrna/intern/rna_sequencer_api.c
M source/blender/makesrna/intern/rna_sound.c
M source/blender/makesrna/intern/rna_sound_api.c
M source/blender/makesrna/intern/rna_text.c
M source/blender/makesrna/intern/rna_vfont.c
M source/blender/makesrna/intern/rna_vfont_api.c
M source/blender/python/intern/bpy_rna.c
M source/blender/windowmanager/intern/wm_operators.c
===================================================================
diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c
index f0e23ddad41..10783c741b6 100644
--- a/source/blender/blenkernel/intern/bpath.c
+++ b/source/blender/blenkernel/intern/bpath.c
@@ -564,8 +564,8 @@ void BKE_bpath_traverse_id(
* don't make sense to add directories to until the image has been saved
* once to give it a meaningful value. */
if (ELEM(ima->source, IMA_SRC_FILE, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE, IMA_SRC_TILED) &&
- ima->name[0]) {
- if (rewrite_path_fixed(ima->name, visit_cb, absbase, bpath_user_data)) {
+ ima->filepath[0]) {
+ if (rewrite_path_fixed(ima->filepath, visit_cb, absbase, bpath_user_data)) {
if (flag & BKE_BPATH_TRAVERSE_RELOAD_EDITED) {
if (!BKE_image_has_packedfile(ima) &&
/* image may have been painted onto (and not saved, T44543) */
@@ -643,7 +643,7 @@ void BKE_bpath_traverse_id(
case ID_SO: {
bSound *sound = (bSound *)id;
if (sound->packedfile == NULL || (flag & BKE_BPATH_TRAVERSE_SKIP_PACKED) == 0) {
- rewrite_path_fixed(sound->name, visit_cb, absbase, bpath_user_data);
+ rewrite_path_fixed(sound->filepath, visit_cb, absbase, bpath_user_data);
}
break;
}
@@ -655,15 +655,15 @@ void BKE_bpath_traverse_id(
break;
}
case ID_TXT:
- if (((Text *)id)->name) {
- rewrite_path_alloc(&((Text *)id)->name, visit_cb, absbase, bpath_user_data);
+ if (((Text *)id)->filepath) {
+ rewrite_path_alloc(&((Text *)id)->filepath, visit_cb, absbase, bpath_user_data);
}
break;
case ID_VF: {
VFont *vfont = (VFont *)id;
if (vfont->packedfile == NULL || (flag & BKE_BPATH_TRAVERSE_SKIP_PACKED) == 0) {
if (BKE_vfont_is_builtin(vfont) == false) {
- rewrite_path_fixed(((VFont *)id)->name, visit_cb, absbase, bpath_user_data);
+ rewrite_path_fixed(((VFont *)id)->filepath, visit_cb, absbase, bpath_user_data);
}
}
break;
@@ -756,15 +756,15 @@ void BKE_bpath_traverse_id(
Library *lib = (Library *)id;
/* keep packedfile paths always relative to the blend */
if (lib->packedfile == NULL) {
- if (rewrite_path_fixed(lib->name, visit_cb, absbase, bpath_user_data)) {
- BKE_library_filepath_set(bmain, lib, lib->name);
+ if (rewrite_path_fixed(lib->filepath, visit_cb, absbase, bpath_user_data)) {
+ BKE_library_filepath_set(bmain, lib, lib->filepath);
}
}
break;
}
case ID_MC: {
MovieClip *clip = (MovieClip *)id;
- rewrite_path_fixed(clip->name, visit_cb, absbase, bpath_user_data);
+ rewrite_path_fixed(clip->filepath, visit_cb, absbase, bpath_user_data);
break;
}
case ID_CF: {
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 5771eb053f7..dfa5ff6975f 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -78,7 +78,7 @@ static void vfont_init_data(ID *id)
if (vfd) {
vfont->data = vfd;
- BLI_strncpy(vfont->name, FO_BUILTIN_NAME, sizeof(vfont->name));
+ BLI_strncpy(vfont->filepath, FO_BUILTIN_NAME, sizeof(vfont->filepath));
}
/* Free the packed file */
@@ -177,7 +177,7 @@ static int builtin_font_size = 0;
bool BKE_vfont_is_builtin(struct VFont *vfont)
{
- return STREQ(vfont->name, FO_BUILTIN_NAME);
+ return STREQ(vfont->filepath, FO_BUILTIN_NAME);
}
void BKE_vfont_builtin_register(void *mem, int size)
@@ -237,20 +237,20 @@ static VFontData *vfont_get_data(VFont *vfont)
}
}
else {
- pf = BKE_packedfile_new(NULL, vfont->name, ID_BLEND_PATH_FROM_GLOBAL(&vfont->id));
+ pf = BKE_packedfile_new(NULL, vfont->filepath, ID_BLEND_PATH_FROM_GLOBAL(&vfont->id));
if (vfont->temp_pf == NULL) {
vfont->temp_pf = BKE_packedfile_new(
- NULL, vfont->name, ID_BLEND_PATH_FROM_GLOBAL(&vfont->id));
+ NULL, vfont->filepath, ID_BLEND_PATH_FROM_GLOBAL(&vfont->id));
}
}
if (!pf) {
- CLOG_WARN(&LOG, "Font file doesn't exist: %s", vfont->name);
+ CLOG_WARN(&LOG, "Font file doesn't exist: %s", vfont->filepath);
/* DON'T DO THIS
* missing file shouldn't modify path! - campbell */
#if 0
- strcpy(vfont->name, FO_BUILTIN_NAME);
+ strcpy(vfont->filepath, FO_BUILTIN_NAME);
#endif
pf = get_builtin_packedfile();
}
@@ -301,7 +301,7 @@ VFont *BKE_vfont_load(Main *bmain, const char *filepath)
if (vfd->name[0] != '\0') {
BLI_strncpy(vfont->id.name + 2, vfd->name, sizeof(vfont->id.name) - 2);
}
- BLI_strncpy(vfont->name, filepath, sizeof(vfont->name));
+ BLI_strncpy(vfont->filepath, filepath, sizeof(vfont->filepath));
/* if autopack is on store the packedfile in de font structure */
if (!is_builtin && (G.fileflags & G_FILE_AUTOPACK)) {
@@ -333,7 +333,7 @@ VFont *BKE_vfont_load_exists_ex(struct Main *bmain, const char *filepath, bool *
/* first search an identical filepath */
for (vfont = bmain->fonts.first; vfont; vfont = vfont->id.next) {
- BLI_strncpy(strtest, vfont->name, sizeof(vfont->name));
+ BLI_strncpy(strtest, vfont->filepath, sizeof(vfont->filepath));
BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &vfont->id));
if (BLI_path_cmp(strtest, str) == 0) {
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index b4a3f249c63..24d175511c7 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -648,7 +648,7 @@ char BKE_image_alpha_mode_from_extension_ex(const char *filepath)
void BKE_image_alpha_mode_from_extension(Image *image)
{
- image->alpha_mode = BKE_image_alpha_mode_from_extension_ex(image->name);
+ image->alpha_mode = BKE_image_alpha_mode_from_extension_ex(image->filepath);
}
Image *BKE_image_load(Main *bmain, const char *filepath)
@@ -668,7 +668,7 @@ Image *BKE_image_load(Main *bmain, const char *filepath)
close(file);
ima = image_alloc(bmain, BLI_path_basename(filepath), IMA_SRC_FILE, IMA_TYPE_IMAGE);
- STRNCPY(ima->name, filepath);
+ STRNCPY(ima->filepath, filepath);
if (BLI_path_extension_check_array(filepath, imb_ext_movie)) {
ima->source = IMA_SRC_MOVIE;
@@ -694,7 +694,7 @@ Image *BKE_image_load_exists_ex(Main *bmain, const char *filepath, bool *r_exist
/* first search an identical filepath */
for (ima = bmain->images.first; ima; ima = ima->id.next) {
if (ima->source != IMA_SRC_VIEWER && ima->source != IMA_SRC_GENERATED) {
- STRNCPY(strtest, ima->name);
+ STRNCPY(strtest, ima->filepath);
BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &ima->id));
if (BLI_path_cmp(strtest, str) == 0) {
@@ -830,7 +830,7 @@ Image *BKE_image_add_generated(Main *bmain,
int view_id;
const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
- /* STRNCPY(ima->name, name); */ /* don't do this, this writes in ain invalid filepath! */
+ /* STRNCPY(ima->filepath, name); */ /* don't do this, this writes in ain invalid filepath! */
ima->gen_x = width;
ima->gen_y = height;
ima->gen_type = gen_type;
@@ -846,7 +846,7 @@ Image *BKE_image_add_generated(Main *bmain,
for (view_id = 0; view_id < 2; view_id++) {
ImBuf *ibuf;
ibuf = add_ibuf_size(
- width, height, ima->name, depth, floatbuf, gen_type, color, &ima->colorspace_settings);
+ width, height, ima->filepath, depth, floatbuf, gen_type, color, &ima->colorspace_settings);
int index = tiled ? 0 : IMA_NO_INDEX;
int entry = tiled ? 1001 : 0;
image_assign_ibuf(ima, ibuf, stereo3d ? view_id : index, entry);
@@ -881,7 +881,7 @@ Image *BKE_image_add_from_imbuf(Main *bmain, ImBuf *ibuf, const char *name)
ima = image_alloc(bmain, name, IMA_SRC_FILE, IMA_TYPE_IMAGE);
if (ima) {
- STRNCPY(ima->name, ibuf->name);
+ STRNCPY(ima->filepath, ibuf->name);
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
ImageTile *tile = BKE_image_get_tile(ima, 0);
tile->ok = IMA_OK_LOADED;
@@ -981,9 +981,9 @@ void BKE_image_packfiles(ReportList *reports, Image *ima, const char *basepath)
if (totfiles == 1) {
ImagePackedFile *imapf = MEM_mallocN(sizeof(ImagePackedFile), "Image packed file");
BLI_addtail(&ima->packedfiles, imapf);
- imapf->packedfile = BKE_packedfile_new(reports, ima->name, basepath);
+ imapf->packedfile = BKE_packedfile_new(reports, ima->filepath, basepath);
if (imapf->packedfile) {
- STRNCPY(imapf->filepath, ima->name);
+ STRNCPY(imapf->filepath, ima->filepath);
}
else {
BLI_freelinkN(&ima->packedfiles, imapf);
@@ -1020,7 +1020,7 @@ void BKE_image_packfiles_from_mem(ReportList *reports,
ImagePackedFile *imapf = MEM_mallocN(sizeof(ImagePackedFile), __func__);
BLI_addtail(&ima->packedfiles, imapf);
imapf->packedfile = BKE_packedfile_new_from_memory(data, data_len);
- STRNCPY(imapf->filepath, ima->name);
+ STRNCPY(imapf->filepath, ima->filepath);
}
}
@@ -3385,7 +3385,7 @@ void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal)
* Here we ensure original image path wouldn't be used when saving
* generated image.
*/
- ima->name[0] = '\0';
+ ima->filepath[0] = '\0';
}
if (ima->source != IMA_SRC_TILED) {
@@ -3643,7 +3643,7 @@ bool BKE_image_fill_tile(struct Image *ima,
image_free_tile(ima, tile);
ImBuf *tile_ibuf = add_ibuf_size(
- width, height, ima->name, planes, is_float, gen_type, color, &ima->colorspace_settings);
+ width, height, ima->filepath, planes, is_float, gen_type, color, &ima->colorspace_settings);
if (tile_ibuf != NULL) {
image_assign_ibuf(ima, tile_ibuf, 0, tile->tile_number);
@@ -3807,7 +3807,7 @@ bool BKE_image_is_openexr(struct Image *ima)
{
#ifdef WITH_OPENEXR
if (ELEM(ima->source, IMA_SRC_FILE, IMA_SRC_SEQUENCE, IMA_SRC_TILED)) {
- return BLI_path_extension_check(ima->name, ".exr");
+ return BLI_path_extension
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list