diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-12-06 02:14:48 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-12-06 02:14:48 +0300 |
commit | 9668c29ba00ed830109665ea132b6292cdfe9e2a (patch) | |
tree | 45a9c23c9aaa382b10985b9c640b363f54c3f9c9 | |
parent | b110c7c8f2c5fafa6412e01d21d751a884bfe8b2 (diff) |
bpath iterator updates
- loop over sequencer plugin and texture voxel paths.
- fix leak in python bpy.utils.blend_path() and use PyUnicode_DecodeFSDefault() to ensure correct paths with different encodings.
- operators to make paths absolute & relative now redraw the view.
-rw-r--r-- | source/blender/blenkernel/intern/depsgraph.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_bpath.h | 25 | ||||
-rw-r--r-- | source/blender/blenlib/intern/bpath.c | 368 | ||||
-rw-r--r-- | source/blender/editors/space_info/info_ops.c | 7 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_texture_types.h | 2 | ||||
-rw-r--r-- | source/blender/python/intern/bpy.c | 27 | ||||
-rw-r--r-- | source/blender/render/intern/source/voxeldata.c | 4 |
7 files changed, 295 insertions, 140 deletions
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 97a27405db3..fe6b320d0bd 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2456,6 +2456,7 @@ void DAG_id_tag_update(ID *id, short flag) } } +#if 0 // UNUSED /* recursively descends tree, each node only checked once */ /* node is checked to be of type object */ static int parent_check_node(DagNode *node, int curtime) @@ -2485,6 +2486,7 @@ static int parent_check_node(DagNode *node, int curtime) return DAG_WHITE; } +#endif /* ******************* DAG FOR ARMATURE POSE ***************** */ diff --git a/source/blender/blenlib/BLI_bpath.h b/source/blender/blenlib/BLI_bpath.h index 47dfea8b91a..34ccb0ca1f9 100644 --- a/source/blender/blenlib/BLI_bpath.h +++ b/source/blender/blenlib/BLI_bpath.h @@ -32,36 +32,17 @@ #ifndef BLI_BPATH_H #define BLI_BPATH_H -struct BPathIteratorSeqData { - int totseq; - int seq; - struct Sequence **seqar; /* Sequence */ - struct Scene *scene; /* Current scene */ -}; +struct BPathIterator; -struct BPathIterator { - char* path; - const char* lib; - const char* name; - void* data; - int len; - int type; - - void (*setpath_callback)(struct BPathIterator *, const char *); - void (*getpath_callback)(struct BPathIterator *, char *); - - const char* base_path; /* base path, the directry the blend file is in - normally G.main->name */ - - /* only for seq data */ - struct BPathIteratorSeqData seqdata; -}; void BLI_bpathIterator_init (struct BPathIterator *bpi, const char *base_path); +void BLI_bpathIterator_alloc (struct BPathIterator **bpi); void BLI_bpathIterator_free (struct BPathIterator *bpi); const char* BLI_bpathIterator_getLib (struct BPathIterator *bpi); const char* BLI_bpathIterator_getName (struct BPathIterator *bpi); int BLI_bpathIterator_getType (struct BPathIterator *bpi); int BLI_bpathIterator_getPathMaxLen (struct BPathIterator *bpi); +const char* BLI_bpathIterator_getBasePath (struct BPathIterator *bpi); void BLI_bpathIterator_step (struct BPathIterator *bpi); int BLI_bpathIterator_isDone (struct BPathIterator *bpi); void BLI_bpathIterator_getPath (struct BPathIterator *bpi, char *path); diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c index a21db4751f1..ab25f9f8982 100644 --- a/source/blender/blenlib/intern/bpath.c +++ b/source/blender/blenlib/intern/bpath.c @@ -29,6 +29,7 @@ #include <sys/stat.h> #include <string.h> +#include <assert.h> /* path/file handeling stuff */ #ifndef WIN32 @@ -44,6 +45,8 @@ #include "DNA_mesh_types.h" #include "DNA_scene_types.h" /* to get the current frame */ #include "DNA_image_types.h" +#include "DNA_texture_types.h" +#include "DNA_text_types.h" #include "DNA_sound_types.h" #include "DNA_sequence_types.h" #include "DNA_vfont_types.h" @@ -65,11 +68,39 @@ //XXX #include "BSE_sequence.h" //XXX define below from BSE_sequence.h - otherwise potentially odd behaviour + +typedef struct BPathIteratorSeqData { + int totseq; + int seq; + struct Sequence **seqar; /* Sequence */ + struct Scene *scene; /* Current scene */ +} BPathIteratorSeqData; + +typedef struct BPathIterator { + char* _path; /* never access directly, use BLI_bpathIterator_getPath */ + const char* _lib; + const char* _name; + void* data; + int len; + int type; + + void (*setpath_callback)(struct BPathIterator *, const char *); + void (*getpath_callback)(struct BPathIterator *, char *); + + const char* base_path; /* base path, the directry the blend file is in - normally G.main->name */ + + /* only for seq data */ + struct BPathIteratorSeqData seqdata; +} BPathIterator; + #define FILE_MAX 240 + /* TODO - BPATH_PLUGIN, BPATH_SEQ */ enum BPathTypes { - BPATH_IMAGE = 0, + BPATH_IMAGE= 0, + BPATH_TEXTURE, + BPATH_TEXT, BPATH_SOUND, BPATH_FONT, BPATH_LIB, @@ -80,35 +111,39 @@ enum BPathTypes { }; void BLI_bpathIterator_init( struct BPathIterator *bpi, const char *base_path ) { - bpi->type = BPATH_IMAGE; - bpi->data = NULL; + bpi->type= BPATH_IMAGE; + bpi->data= NULL; - bpi->getpath_callback = NULL; - bpi->setpath_callback = NULL; + bpi->getpath_callback= NULL; + bpi->setpath_callback= NULL; /* Sequencer specific */ - bpi->seqdata.totseq = 0; - bpi->seqdata.seq = 0; - bpi->seqdata.seqar = NULL; - bpi->seqdata.scene = NULL; + bpi->seqdata.totseq= 0; + bpi->seqdata.seq= 0; + bpi->seqdata.seqar= NULL; + bpi->seqdata.scene= NULL; bpi->base_path= base_path ? base_path : G.main->name; BLI_bpathIterator_step(bpi); } +void BLI_bpathIterator_alloc(struct BPathIterator **bpi) { + *bpi= MEM_mallocN(sizeof(BPathIterator), "BLI_bpathIterator_alloc"); +} + void BLI_bpathIterator_free( struct BPathIterator *bpi ) { if (bpi->seqdata.seqar) MEM_freeN((void *)bpi->seqdata.seqar); - bpi->seqdata.seqar = NULL; - bpi->seqdata.scene = NULL; + bpi->seqdata.seqar= NULL; + bpi->seqdata.scene= NULL; } void BLI_bpathIterator_getPath( struct BPathIterator *bpi, char *path) { if (bpi->getpath_callback) { bpi->getpath_callback( bpi, path ); } else { - strcpy(path, bpi->path); /* warning, we assume 'path' are long enough */ + strcpy(path, bpi->_path); /* warning, we assume 'path' are long enough */ } } @@ -116,7 +151,7 @@ void BLI_bpathIterator_setPath( struct BPathIterator *bpi, const char *path) { if (bpi->setpath_callback) { bpi->setpath_callback( bpi, path ); } else { - strcpy(bpi->path, path); /* warning, we assume 'path' are long enough */ + strcpy(bpi->_path, path); /* warning, we assume 'path' are long enough */ } } @@ -124,7 +159,7 @@ void BLI_bpathIterator_getPathExpanded( struct BPathIterator *bpi, char *path_ex const char *libpath; BLI_bpathIterator_getPath(bpi, path_expanded); - libpath = BLI_bpathIterator_getLib(bpi); + libpath= BLI_bpathIterator_getLib(bpi); if (libpath) { /* check the files location relative to its library path */ BLI_path_abs(path_expanded, libpath); @@ -134,10 +169,10 @@ void BLI_bpathIterator_getPathExpanded( struct BPathIterator *bpi, char *path_ex BLI_cleanup_file(NULL, path_expanded); } const char* BLI_bpathIterator_getLib( struct BPathIterator *bpi) { - return bpi->lib; + return bpi->_lib; } const char* BLI_bpathIterator_getName( struct BPathIterator *bpi) { - return bpi->name; + return bpi->_name; } int BLI_bpathIterator_getType( struct BPathIterator *bpi) { return bpi->type; @@ -145,6 +180,9 @@ int BLI_bpathIterator_getType( struct BPathIterator *bpi) { int BLI_bpathIterator_getPathMaxLen( struct BPathIterator *bpi) { return bpi->len; } +const char* BLI_bpathIterator_getBasePath( struct BPathIterator *bpi) { + return bpi->base_path; +} /* gets the first or the next image that has a path - not a viewer node or generated image */ static struct Image *ima_stepdata__internal(struct Image *ima, int step_next) { @@ -152,23 +190,55 @@ static struct Image *ima_stepdata__internal(struct Image *ima, int step_next) { return NULL; if (step_next) - ima = ima->id.next; + ima= ima->id.next; while (ima) { if (ima->packedfile==NULL && ELEM3(ima->source, IMA_SRC_FILE, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) break; /* image is not a image with a path, skip it */ - ima = ima->id.next; + ima= ima->id.next; } return ima; } +static struct Tex *tex_stepdata__internal(struct Tex *tex, int step_next) { + if (tex==NULL) + return NULL; + + if (step_next) + tex= tex->id.next; + + while (tex) { + if (tex->type == TEX_VOXELDATA && TEX_VD_IS_SOURCE_PATH(tex->vd->file_format)) + break; + /* image is not a image with a path, skip it */ + tex= tex->id.next; + } + return tex; +} + +static struct Text *text_stepdata__internal(struct Text *text, int step_next) { + if (text==NULL) + return NULL; + + if (step_next) + text= text->id.next; + + while (text) { + if (text->name) + break; + /* image is not a image with a path, skip it */ + text= text->id.next; + } + return text; +} + static struct VFont *vf_stepdata__internal(struct VFont *vf, int step_next) { if (vf==NULL) return NULL; if (step_next) - vf = vf->id.next; + vf= vf->id.next; while (vf) { if (vf->packedfile==NULL && strcmp(vf->name, FO_BUILTIN_NAME)!=0) { @@ -176,7 +246,7 @@ static struct VFont *vf_stepdata__internal(struct VFont *vf, int step_next) { } /* font with no path, skip it */ - vf = vf->id.next; + vf= vf->id.next; } return vf; } @@ -186,7 +256,7 @@ static struct bSound *snd_stepdata__internal(struct bSound *snd, int step_next) return NULL; if (step_next) - snd = snd->id.next; + snd= snd->id.next; while (snd) { if (snd->packedfile==NULL) { @@ -194,7 +264,7 @@ static struct bSound *snd_stepdata__internal(struct bSound *snd, int step_next) } /* font with no path, skip it */ - snd = snd->id.next; + snd= snd->id.next; } return snd; } @@ -219,20 +289,20 @@ static struct Sequence *seq_stepdata__internal(struct BPathIterator *bpi, int st if (bpi->seqdata.seqar == NULL) { /* allocate the sequencer array */ seq_array(ed, &bpi->seqdata.seqar, &bpi->seqdata.totseq, 0); - bpi->seqdata.seq = 0; + bpi->seqdata.seq= 0; } if (bpi->seqdata.seq >= bpi->seqdata.totseq) { - seq = NULL; + seq= NULL; } else { - seq = bpi->seqdata.seqar[bpi->seqdata.seq]; - while (!SEQ_HAS_PATH(seq)) { + seq= bpi->seqdata.seqar[bpi->seqdata.seq]; + while (!SEQ_HAS_PATH(seq) && seq->plugin==NULL) { bpi->seqdata.seq++; if (bpi->seqdata.seq >= bpi->seqdata.totseq) { - seq = NULL; + seq= NULL; break; } - seq = bpi->seqdata.seqar[bpi->seqdata.seq]; + seq= bpi->seqdata.seqar[bpi->seqdata.seq]; } } if (seq) { @@ -241,13 +311,13 @@ static struct Sequence *seq_stepdata__internal(struct BPathIterator *bpi, int st /* keep looking through the next scene, reallocate seq array */ if (bpi->seqdata.seqar) { MEM_freeN((void *)bpi->seqdata.seqar); - bpi->seqdata.seqar = NULL; + bpi->seqdata.seqar= NULL; } - bpi->seqdata.scene = bpi->seqdata.scene->id.next; + bpi->seqdata.scene= bpi->seqdata.scene->id.next; } } else { /* no seq data in this scene, next */ - bpi->seqdata.scene = bpi->seqdata.scene->id.next; + bpi->seqdata.scene= bpi->seqdata.scene->id.next; } } @@ -255,10 +325,10 @@ static struct Sequence *seq_stepdata__internal(struct BPathIterator *bpi, int st } static void seq_getpath(struct BPathIterator *bpi, char *path) { - Sequence *seq = (Sequence *)bpi->data; + Sequence *seq= (Sequence *)bpi->data; - path[0] = '\0'; /* incase we cant get the path */ + path[0]= '\0'; /* incase we cant get the path */ if (seq==NULL) return; if (SEQ_HAS_PATH(seq)) { if (ELEM3(seq->type, SEQ_IMAGE, SEQ_MOVIE, SEQ_SOUND)) { @@ -268,25 +338,52 @@ static void seq_getpath(struct BPathIterator *bpi, char *path) { /* Using the first image is weak for image sequences */ strcat(path, seq->strip->stripdata->name); } - } else { + } + else { /* simple case */ BLI_strncpy(seq->strip->dir, path, sizeof(seq->strip->dir)); } } + else if (seq->plugin) { + BLI_strncpy(seq->plugin->name, path, sizeof(seq->plugin->name)); + } } static void seq_setpath(struct BPathIterator *bpi, const char *path) { - Sequence *seq = (Sequence *)bpi->data; + Sequence *seq= (Sequence *)bpi->data; if (seq==NULL) return; if (SEQ_HAS_PATH(seq)) { if (ELEM3(seq->type, SEQ_IMAGE, SEQ_MOVIE, SEQ_SOUND)) { BLI_split_dirfile(path, seq->strip->dir, seq->strip->stripdata->name); - } else { + } + else { /* simple case */ BLI_strncpy(seq->strip->dir, path, sizeof(seq->strip->dir)); } } + else if (seq->plugin) { + BLI_strncpy(seq->plugin->name, path, sizeof(seq->plugin->name)); + } +} + +static void text_getpath(struct BPathIterator *bpi, char *path) { + Text *text= (Text *)bpi->data; + path[0]= '\0'; /* incase we cant get the path */ + if(text->name) { + strcpy(path, text->name); + } +} + +static void text_setpath(struct BPathIterator *bpi, const char *path) { + Text *text= (Text *)bpi->data; + if (text==NULL) return; + + if(text->name) { + MEM_freeN(text->name); + } + + text->name= BLI_strdup(path); } static struct Mesh *cdata_stepdata__internal(struct Mesh *me, int step_next) { @@ -294,30 +391,34 @@ static struct Mesh *cdata_stepdata__internal(struct Mesh *me, int step_next) { return NULL; if (step_next) - me = me->id.next; + me= me->id.next; while (me) { if (me->fdata.external) { break; } - me = me->id.next; + me= me->id.next; } return me; } static void bpi_type_step__internal( struct BPathIterator *bpi) { bpi->type++; /* advance to the next type */ - bpi->data = NULL; + bpi->data= NULL; switch (bpi->type) { case BPATH_SEQ: - bpi->getpath_callback = seq_getpath; - bpi->setpath_callback = seq_setpath; + bpi->getpath_callback= seq_getpath; + bpi->setpath_callback= seq_setpath; + break; + case BPATH_TEXT: /* path is malloc'd */ + bpi->getpath_callback= text_getpath; + bpi->setpath_callback= text_setpath; break; default: - bpi->getpath_callback = NULL; - bpi->setpath_callback = NULL; + bpi->getpath_callback= NULL; + bpi->setpath_callback= NULL; break; } } @@ -326,40 +427,89 @@ void BLI_bpathIterator_step( struct BPathIterator *bpi) { while (bpi->type != BPATH_DONE) { if ((bpi->type) == BPATH_IMAGE) { - /*if (bpi->data) bpi->data = ((ID *)bpi->data)->next;*/ - if (bpi->data) bpi->data = ima_stepdata__internal( (Image *)bpi->data, 1 ); /* must skip images that have no path */ - else bpi->data = ima_stepdata__internal(G.main->image.first, 0); + /*if (bpi->data) bpi->data= ((ID *)bpi->data)->next;*/ + if (bpi->data) bpi->data= ima_stepdata__internal( (Image *)bpi->data, 1 ); /* must skip images that have no path */ + else bpi->data= ima_stepdata__internal(G.main->image.first, 0); if (bpi->data) { /* get the path info from this datatype */ - Image *ima = (Image *)bpi->data; + Image *ima= (Image *)bpi->data; - bpi->lib = ima->id.lib ? ima->id.lib->filepath : NULL; - bpi->path = ima->name; - bpi->name = ima->id.name+2; - bpi->len = sizeof(ima->name); + bpi->_lib= ima->id.lib ? ima->id.lib->filepath : NULL; + bpi->_path= ima->name; + bpi->_name= ima->id.name+2; + bpi->len= sizeof(ima->name); /* we are done, advancing to the next item, this type worked fine */ break; - + } else { bpi_type_step__internal(bpi); } - - - } else if ((bpi->type) == BPATH_SOUND) { - if (bpi->data) bpi->data = snd_stepdata__internal( (bSound *)bpi->data, 1 ); /* must skip images that have no path */ - else bpi->data = snd_stepdata__internal(G.main->sound.first, 0); - + } + + if ((bpi->type) == BPATH_TEXTURE) { + /*if (bpi->data) bpi->data= ((ID *)bpi->data)->next;*/ + if (bpi->data) bpi->data= tex_stepdata__internal( (Tex *)bpi->data, 1 ); /* must skip images that have no path */ + else bpi->data= tex_stepdata__internal(G.main->tex.first, 0); + if (bpi->data) { /* get the path info from this datatype */ - bSound *snd = (bSound *)bpi->data; - - bpi->lib = snd->id.lib ? snd->id.lib->filepath : NULL; - bpi->path = snd->name; - bpi->name = snd->id.name+2; - bpi->len = sizeof(snd->name); - + Tex *tex= (Tex *)bpi->data; + + if(tex->type == TEX_VOXELDATA) { + bpi->_lib= tex->id.lib ? tex->id.lib->filepath : NULL; + bpi->_path= tex->vd->source_path; + bpi->_name= tex->id.name+2; + bpi->len= sizeof(tex->vd->source_path); + } + else { + assert(!"Texture has no path, incorrect step 'tex_stepdata__internal'"); + } + + /* we are done, advancing to the next item, this type worked fine */ + break; + + } else { + bpi_type_step__internal(bpi); + } + } + + if ((bpi->type) == BPATH_TEXT) { + /*if (bpi->data) bpi->data= ((ID *)bpi->data)->next;*/ + if (bpi->data) bpi->data= text_stepdata__internal( (Text *)bpi->data, 1 ); /* must skip images that have no path */ + else bpi->data= text_stepdata__internal(G.main->text.first, 0); + + if (bpi->data) { + /* get the path info from this datatype */ + Text *text= (Text *)bpi->data; + + bpi->_lib= text->id.lib ? text->id.lib->filepath : NULL; + bpi->_path= NULL; /* bpi->path= text->name; */ /* get/set functions override. */ + bpi->_name= text->id.name+2; + bpi->len= FILE_MAX; /* malloc'd but limit anyway since large paths may mess up other areas */ + + /* we are done, advancing to the next item, this type worked fine */ + break; + + } else { + bpi_type_step__internal(bpi); + } + } + + else if ((bpi->type) == BPATH_SOUND) { + if (bpi->data) bpi->data= snd_stepdata__internal( (bSound *)bpi->data, 1 ); /* must skip images that have no path */ + else bpi->data= snd_stepdata__internal(G.main->sound.first, 0); + + if (bpi->data) { + /* get the path info from this datatype */ + bSound *snd= (bSound *)bpi->data; + + bpi->_lib= snd->id.lib ? snd->id.lib->filepath : NULL; + bpi->_path= snd->name; + bpi->_name= snd->id.name+2; + bpi->len= sizeof(snd->name); + /* we are done, advancing to the next item, this type worked fine */ break; } else { @@ -369,36 +519,36 @@ void BLI_bpathIterator_step( struct BPathIterator *bpi) { } else if ((bpi->type) == BPATH_FONT) { - if (bpi->data) bpi->data = vf_stepdata__internal( (VFont *)bpi->data, 1 ); - else bpi->data = vf_stepdata__internal( G.main->vfont.first, 0 ); + if (bpi->data) bpi->data= vf_stepdata__internal( (VFont *)bpi->data, 1 ); + else bpi->data= vf_stepdata__internal( G.main->vfont.first, 0 ); if (bpi->data) { /* get the path info from this datatype */ - VFont *vf = (VFont *)bpi->data; - - bpi->lib = vf->id.lib ? vf->id.lib->filepath : NULL; - bpi->path = vf->name; - bpi->name = vf->id.name+2; - bpi->len = sizeof(vf->name); - + VFont *vf= (VFont *)bpi->data; + + bpi->_lib= vf->id.lib ? vf->id.lib->filepath : NULL; + bpi->_path= vf->name; + bpi->_name= vf->id.name+2; + bpi->len= sizeof(vf->name); + /* we are done, advancing to the next item, this type worked fine */ break; } else { bpi_type_step__internal(bpi); } - + } else if ((bpi->type) == BPATH_LIB) { - if (bpi->data) bpi->data = ((ID *)bpi->data)->next; - else bpi->data = G.main->library.first; + if (bpi->data) bpi->data= ((ID *)bpi->data)->next; + else bpi->data= G.main->library.first; if (bpi->data) { /* get the path info from this datatype */ - Library *lib = (Library *)bpi->data; + Library *lib= (Library *)bpi->data; - bpi->lib = NULL; - bpi->path = lib->name; - bpi->name = NULL; - bpi->len = sizeof(lib->name); + bpi->_lib= NULL; + bpi->_path= lib->name; + bpi->_name= NULL; + bpi->len= sizeof(lib->name); /* we are done, advancing to the next item, this type worked fine */ break; @@ -406,27 +556,27 @@ void BLI_bpathIterator_step( struct BPathIterator *bpi) { bpi_type_step__internal(bpi); } } else if ((bpi->type) == BPATH_SEQ) { - if (bpi->data) bpi->data = seq_stepdata__internal( bpi, 1 ); - else bpi->data = seq_stepdata__internal( bpi, 0 ); + if (bpi->data) bpi->data= seq_stepdata__internal( bpi, 1 ); + else bpi->data= seq_stepdata__internal( bpi, 0 ); if (bpi->data) { - Sequence *seq = (Sequence *)bpi->data; - bpi->lib = NULL; - bpi->name = seq->name+2; - bpi->len = sizeof(seq->strip->stripdata->name); + Sequence *seq= (Sequence *)bpi->data; + bpi->_lib= NULL; + bpi->_name= seq->name+2; + bpi->len= seq->plugin ? sizeof(seq->plugin->name) : sizeof(seq->strip->dir) + sizeof(seq->strip->stripdata->name); break; } else { bpi_type_step__internal(bpi); } } else if ((bpi->type) == BPATH_CDATA) { - if (bpi->data) bpi->data = cdata_stepdata__internal( bpi->data, 1 ); - else bpi->data = cdata_stepdata__internal( G.main->mesh.first, 0 ); + if (bpi->data) bpi->data= cdata_stepdata__internal( bpi->data, 1 ); + else bpi->data= cdata_stepdata__internal( G.main->mesh.first, 0 ); if (bpi->data) { - Mesh *me = (Mesh *)bpi->data; - bpi->lib = me->id.lib ? me->id.lib->filepath : NULL; - bpi->path = me->fdata.external->filename; - bpi->name = me->id.name+2; - bpi->len = sizeof(me->fdata.external->filename); + Mesh *me= (Mesh *)bpi->data; + bpi->_lib= me->id.lib ? me->id.lib->filepath : NULL; + bpi->_path= me->fdata.external->filename; + bpi->_name= me->id.name+2; + bpi->len= sizeof(me->fdata.external->filename); break; } else { bpi_type_step__internal(bpi); @@ -453,6 +603,12 @@ static void bpath_as_report(struct BPathIterator *bpi, const char *message, Repo case BPATH_IMAGE: prefix= "Image"; break; + case BPATH_TEXTURE: + prefix= "Texture"; + break; + case BPATH_TEXT: + prefix= "Text"; + break; case BPATH_SOUND: prefix= "Sound"; break; @@ -473,7 +629,7 @@ static void bpath_as_report(struct BPathIterator *bpi, const char *message, Repo break; } - name = BLI_bpathIterator_getName(bpi); + name= BLI_bpathIterator_getName(bpi); BLI_bpathIterator_getPathExpanded(bpi, path_expanded); if(reports) { @@ -515,7 +671,7 @@ void makeFilesRelative(const char *basepath, ReportList *reports) { BLI_bpathIterator_init(&bpi, basepath); while (!BLI_bpathIterator_isDone(&bpi)) { BLI_bpathIterator_getPath(&bpi, filepath); - libpath = BLI_bpathIterator_getLib(&bpi); + libpath= BLI_bpathIterator_getLib(&bpi); if(strncmp(filepath, "//", 2)) { if (libpath) { /* cant make relative if we are library - TODO, LOG THIS */ @@ -566,7 +722,7 @@ void makeFilesAbsolute(const char *basepath, ReportList *reports) BLI_bpathIterator_init(&bpi, basepath); while (!BLI_bpathIterator_isDone(&bpi)) { BLI_bpathIterator_getPath(&bpi, filepath); - libpath = BLI_bpathIterator_getLib(&bpi); + libpath= BLI_bpathIterator_getLib(&bpi); if(strncmp(filepath, "//", 2)==0) { if (libpath) { /* cant make absolute if we are library - TODO, LOG THIS */ @@ -614,15 +770,15 @@ static int findFileRecursive(char *filename_new, const char *dirname, const char char path[FILE_MAX]; int size; - dir = opendir(dirname); + dir= opendir(dirname); if (dir==0) return 0; if (*filesize == -1) - *filesize = 0; /* dir opened fine */ + *filesize= 0; /* dir opened fine */ - while ((de = readdir(dir)) != NULL) { + while ((de= readdir(dir)) != NULL) { if (strcmp(".", de->d_name)==0 || strcmp("..", de->d_name)==0) continue; @@ -635,9 +791,9 @@ static int findFileRecursive(char *filename_new, const char *dirname, const char if (S_ISREG(status.st_mode)) { /* is file */ if (strncmp(filename, de->d_name, FILE_MAX)==0) { /* name matches */ /* open the file to read its size */ - size = status.st_size; + size= status.st_size; if ((size > 0) && (size > *filesize)) { /* find the biggest file */ - *filesize = size; + *filesize= size; BLI_strncpy(filename_new, path, FILE_MAX); } } @@ -673,7 +829,7 @@ void findMissingFiles(const char *basepath, const char *str) { while (!BLI_bpathIterator_isDone(&bpi)) { BLI_bpathIterator_getPath(&bpi, filepath); - libpath = BLI_bpathIterator_getLib(&bpi); + libpath= BLI_bpathIterator_getLib(&bpi); /* Check if esc was pressed because searching files can be slow */ /*XXX if (blender_test_break()) { @@ -686,8 +842,8 @@ void findMissingFiles(const char *basepath, const char *str) { if (!BLI_exists(filepath_expanded)) { /* can the dir be opened? */ - filesize = -1; - recur_depth = 0; + filesize= -1; + recur_depth= 0; findFileRecursive(filename_new, dirname, BLI_path_basename(filepath), &filesize, &recur_depth); if (filesize == -1) { /* could not open dir */ diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index b4a63d344ec..c45e4d3acf0 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -193,6 +193,9 @@ static int make_paths_relative_exec(bContext *UNUSED(C), wmOperator *op) makeFilesRelative(G.main->name, op->reports); + /* redraw everything so any changed paths register */ + WM_main_add_notifier(NC_WINDOW, NULL); + return OPERATOR_FINISHED; } @@ -219,6 +222,10 @@ static int make_paths_absolute_exec(bContext *UNUSED(C), wmOperator *op) } makeFilesAbsolute(G.main->name, op->reports); + + /* redraw everything so any changed paths register */ + WM_main_add_notifier(NC_WINDOW, NULL); + return OPERATOR_FINISHED; } diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h index 9df596666a7..4d11890f5a5 100644 --- a/source/blender/makesdna/DNA_texture_types.h +++ b/source/blender/makesdna/DNA_texture_types.h @@ -552,6 +552,8 @@ typedef struct TexMapping { #define TEX_VD_RAW_16BIT 2 #define TEX_VD_IMAGE_SEQUENCE 3 #define TEX_VD_SMOKE 4 +/* for voxels which use VoxelData->source_path */ +#define TEX_VD_IS_SOURCE_PATH(_format) (ELEM3(_format, TEX_VD_BLENDERVOXEL, TEX_VD_RAW_8BIT, TEX_VD_RAW_16BIT)) /* smoke data types */ #define TEX_VD_SMOKEDENSITY 0 diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index 1843d0ac93a..2c4ccaa1509 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -38,6 +38,8 @@ #include "BKE_utildefines.h" +#include "MEM_guardedalloc.h" + /* external util modules */ #include "../generic/mathutils.h" #include "../generic/bgl.h" @@ -78,8 +80,8 @@ static char bpy_blend_paths_doc[] = " :rtype: list of strigs\n"; static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObject *kw) { - struct BPathIterator bpi; - PyObject *list = PyList_New(0), *st; /* stupidly big string to be safe */ + struct BPathIterator *bpi; + PyObject *list, *st; /* stupidly big string to be safe */ /* be sure there is low chance of the path being too short */ char filepath_expanded[1024]; const char *lib; @@ -90,27 +92,32 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec if (!PyArg_ParseTupleAndKeywords(args, kw, "|i:blend_paths", (char **)kwlist, &absolute)) return NULL; - for(BLI_bpathIterator_init(&bpi, NULL); !BLI_bpathIterator_isDone(&bpi); BLI_bpathIterator_step(&bpi)) { + BLI_bpathIterator_alloc(&bpi); + + list= PyList_New(0); + + for(BLI_bpathIterator_init(bpi, NULL); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) { /* build the list */ if (absolute) { - BLI_bpathIterator_getPathExpanded(&bpi, filepath_expanded); + BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded); } else { - lib = BLI_bpathIterator_getLib(&bpi); - if (lib && (strcmp(lib, bpi.base_path))) { /* relative path to the library is NOT the same as our blendfile path, return an absolute path */ - BLI_bpathIterator_getPathExpanded(&bpi, filepath_expanded); + lib = BLI_bpathIterator_getLib(bpi); + if (lib && (strcmp(lib, BLI_bpathIterator_getBasePath(bpi)))) { /* relative path to the library is NOT the same as our blendfile path, return an absolute path */ + BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded); } else { - BLI_bpathIterator_getPath(&bpi, filepath_expanded); + BLI_bpathIterator_getPath(bpi, filepath_expanded); } } - st = PyUnicode_FromString(filepath_expanded); + st= PyUnicode_DecodeFSDefault(filepath_expanded); PyList_Append(list, st); Py_DECREF(st); } - BLI_bpathIterator_free(&bpi); + BLI_bpathIterator_free(bpi); + MEM_freeN((void *)bpi); return list; } diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c index ac4aba3e4de..859b6246eca 100644 --- a/source/blender/render/intern/source/voxeldata.c +++ b/source/blender/render/intern/source/voxeldata.c @@ -268,7 +268,7 @@ static void cache_voxeldata(struct Render *re, Tex *tex) VoxelData *vd = tex->vd; FILE *fp; int curframe; - char path[FILE_MAX]; + char path[sizeof(vd->source_path)]; if (!vd) return; @@ -287,7 +287,7 @@ static void cache_voxeldata(struct Render *re, Tex *tex) else curframe = re->r.cfra; - BLI_strncpy(path, vd->source_path, FILE_MAX); + BLI_strncpy(path, vd->source_path, sizeof(path)); switch(vd->file_format) { case TEX_VD_IMAGE_SEQUENCE: |