[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33493] trunk/blender/source/blender: - converted path cleaning on file load to use bPath Iterator functions - image & font and sequence paths were being cleaned but not multires , voxel & sound paths.
Campbell Barton
ideasman42 at gmail.com
Mon Dec 6 01:52:30 CET 2010
Revision: 33493
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33493
Author: campbellbarton
Date: 2010-12-06 01:52:30 +0100 (Mon, 06 Dec 2010)
Log Message:
-----------
- converted path cleaning on file load to use bPath Iterator functions - image & font and sequence paths were being cleaned but not multires, voxel & sound paths.
- skip fixing file paths on undo.
- simplify bpath alloc and free functions, also pass Main structure so as not to rely on G.main, (needed for file load).
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/blender.c
trunk/blender/source/blender/blenlib/BLI_bpath.h
trunk/blender/source/blender/blenlib/intern/bpath.c
trunk/blender/source/blender/blenloader/intern/writefile.c
trunk/blender/source/blender/editors/space_info/info_ops.c
trunk/blender/source/blender/python/intern/bpy.c
Modified: trunk/blender/source/blender/blenkernel/intern/blender.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/blender.c 2010-12-05 23:50:55 UTC (rev 33492)
+++ trunk/blender/source/blender/blenkernel/intern/blender.c 2010-12-06 00:52:30 UTC (rev 33493)
@@ -55,6 +55,7 @@
#include "DNA_sound_types.h"
#include "BLI_blenlib.h"
+#include "BLI_bpath.h"
#include "BLI_dynstr.h"
#include "BLI_path_util.h"
@@ -154,49 +155,32 @@
/* make sure path names are correct for OS */
static void clean_paths(Main *main)
{
- Image *image= main->image.first;
- bSound *sound= main->sound.first;
- Scene *scene= main->scene.first;
- Editing *ed;
- Sequence *seq;
- Strip *strip;
-
- while(image) {
- BLI_clean(image->name);
- image= image->id.next;
+ struct BPathIterator *bpi;
+ char filepath_expanded[1024];
+ Scene *scene;
+
+ for(BLI_bpathIterator_init(&bpi, main, main->name); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) {
+ BLI_bpathIterator_getPath(bpi, filepath_expanded);
+
+ BLI_clean(filepath_expanded);
+
+ BLI_bpathIterator_setPath(bpi, filepath_expanded);
}
-
- while(sound) {
- BLI_clean(sound->name);
- sound= sound->id.next;
- }
-
- while(scene) {
- ed= seq_give_editing(scene, 0);
- if(ed) {
- seq= ed->seqbasep->first;
- while(seq) {
- if(seq->plugin) {
- BLI_clean(seq->plugin->name);
- }
- strip= seq->strip;
- while(strip) {
- BLI_clean(strip->dir);
- strip= strip->next;
- }
- seq= seq->next;
- }
- }
+
+ BLI_bpathIterator_free(bpi);
+
+ for(scene= main->scene.first; scene; scene= scene->id.next) {
BLI_clean(scene->r.backbuf);
BLI_clean(scene->r.pic);
-
- scene= scene->id.next;
}
}
/* context matching */
/* handle no-ui case */
+/* note, this is called on Undo so any slow conversion functions here
+ * should be avoided or check (mode!='u') */
+
static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filename)
{
bScreen *curscreen= NULL;
@@ -210,9 +194,12 @@
else mode= 0;
recover= (G.fileflags & G_FILE_RECOVER);
-
- clean_paths(bfd->main);
-
+
+ /* Only make filepaths compatible when loading for real (not undo) */
+ if(mode != 'u') {
+ clean_paths(bfd->main);
+ }
+
/* XXX here the complex windowmanager matching */
/* no load screens? */
Modified: trunk/blender/source/blender/blenlib/BLI_bpath.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_bpath.h 2010-12-05 23:50:55 UTC (rev 33492)
+++ trunk/blender/source/blender/blenlib/BLI_bpath.h 2010-12-06 00:52:30 UTC (rev 33493)
@@ -33,10 +33,10 @@
#define BLI_BPATH_H
struct BPathIterator;
+struct ReportList;
+struct Main;
-
-void BLI_bpathIterator_init (struct BPathIterator *bpi, const char *base_path);
-void BLI_bpathIterator_alloc (struct BPathIterator **bpi);
+void BLI_bpathIterator_init (struct BPathIterator **bpi, struct Main *bmain, const char *basedir);
void BLI_bpathIterator_free (struct BPathIterator *bpi);
const char* BLI_bpathIterator_getLib (struct BPathIterator *bpi);
const char* BLI_bpathIterator_getName (struct BPathIterator *bpi);
@@ -52,9 +52,9 @@
/* high level funcs */
/* creates a text file with missing files if there are any */
-void checkMissingFiles(const char *basepath, ReportList *reports);
-void makeFilesRelative(const char *basepath, ReportList *reports);
-void makeFilesAbsolute(const char *basepath, ReportList *reports);
-void findMissingFiles(const char *basepath, const char *str);
+void checkMissingFiles(struct Main *bmain, struct ReportList *reports);
+void makeFilesRelative(struct Main *bmain, const char *basedir, struct ReportList *reports);
+void makeFilesAbsolute(struct Main *bmain, const char *basedir, struct ReportList *reports);
+void findMissingFiles(struct Main *bmain, const char *str);
#endif // BLI_BPATH_H
Modified: trunk/blender/source/blender/blenlib/intern/bpath.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/bpath.c 2010-12-05 23:50:55 UTC (rev 33492)
+++ trunk/blender/source/blender/blenlib/intern/bpath.c 2010-12-06 00:52:30 UTC (rev 33493)
@@ -57,8 +57,8 @@
#include "BKE_global.h"
#include "BKE_image.h" /* so we can check the image's type */
-#include "BKE_main.h" /* so we can access G.main->*.first */
#include "BKE_sequencer.h"
+#include "BKE_main.h"
#include "BKE_utildefines.h"
#include "BKE_report.h"
@@ -87,8 +87,10 @@
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 */
+ const char* base_path; /* base path, the directry the blend file is in - normally bmain->name */
+ Main *bmain;
+
/* only for seq data */
struct BPathIteratorSeqData seqdata;
} BPathIterator;
@@ -110,7 +112,12 @@
BPATH_DONE
};
-void BLI_bpathIterator_init( struct BPathIterator *bpi, const char *base_path ) {
+void BLI_bpathIterator_init(struct BPathIterator **bpi_pt, Main *bmain, const char *basedir) {
+ BPathIterator *bpi;
+
+ bpi= MEM_mallocN(sizeof(BPathIterator), "BLI_bpathIterator_init");
+ *bpi_pt= bpi;
+
bpi->type= BPATH_IMAGE;
bpi->data= NULL;
@@ -123,7 +130,8 @@
bpi->seqdata.seqar= NULL;
bpi->seqdata.scene= NULL;
- bpi->base_path= base_path ? base_path : G.main->name;
+ bpi->base_path= basedir; /* normally bmain->name */
+ bpi->bmain= bmain;
BLI_bpathIterator_step(bpi);
}
@@ -132,30 +140,32 @@
*bpi= MEM_mallocN(sizeof(BPathIterator), "BLI_bpathIterator_alloc");
}
-void BLI_bpathIterator_free( struct BPathIterator *bpi ) {
+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;
+
+ MEM_freeN(bpi);
}
-void BLI_bpathIterator_getPath( struct BPathIterator *bpi, char *path) {
+void BLI_bpathIterator_getPath(struct BPathIterator *bpi, char *path) {
if (bpi->getpath_callback) {
- bpi->getpath_callback( bpi, path );
+ bpi->getpath_callback(bpi, path);
} else {
strcpy(path, bpi->_path); /* warning, we assume 'path' are long enough */
}
}
-void BLI_bpathIterator_setPath( struct BPathIterator *bpi, const char *path) {
+void BLI_bpathIterator_setPath(struct BPathIterator *bpi, const char *path) {
if (bpi->setpath_callback) {
- bpi->setpath_callback( bpi, path );
+ bpi->setpath_callback(bpi, path);
} else {
strcpy(bpi->_path, path); /* warning, we assume 'path' are long enough */
}
}
-void BLI_bpathIterator_getPathExpanded( struct BPathIterator *bpi, char *path_expanded) {
+void BLI_bpathIterator_getPathExpanded(struct BPathIterator *bpi, char *path_expanded) {
const char *libpath;
BLI_bpathIterator_getPath(bpi, path_expanded);
@@ -168,19 +178,19 @@
}
BLI_cleanup_file(NULL, path_expanded);
}
-const char* BLI_bpathIterator_getLib( struct BPathIterator *bpi) {
+const char* BLI_bpathIterator_getLib(struct BPathIterator *bpi) {
return bpi->_lib;
}
-const char* BLI_bpathIterator_getName( struct BPathIterator *bpi) {
+const char* BLI_bpathIterator_getName(struct BPathIterator *bpi) {
return bpi->_name;
}
-int BLI_bpathIterator_getType( struct BPathIterator *bpi) {
+int BLI_bpathIterator_getType(struct BPathIterator *bpi) {
return bpi->type;
}
-int BLI_bpathIterator_getPathMaxLen( struct BPathIterator *bpi) {
+int BLI_bpathIterator_getPathMaxLen(struct BPathIterator *bpi) {
return bpi->len;
}
-const char* BLI_bpathIterator_getBasePath( struct BPathIterator *bpi) {
+const char* BLI_bpathIterator_getBasePath(struct BPathIterator *bpi) {
return bpi->base_path;
}
@@ -276,7 +286,7 @@
/* Initializing */
if (bpi->seqdata.scene==NULL) {
- bpi->seqdata.scene= G.main->scene.first;
+ bpi->seqdata.scene= bpi->bmain->scene.first;
}
if (step_next) {
@@ -403,7 +413,7 @@
return me;
}
-static void bpi_type_step__internal( struct BPathIterator *bpi) {
+static void bpi_type_step__internal(struct BPathIterator *bpi) {
bpi->type++; /* advance to the next type */
bpi->data= NULL;
@@ -423,13 +433,13 @@
}
}
-void BLI_bpathIterator_step( struct BPathIterator *bpi) {
+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);
+ else bpi->data= ima_stepdata__internal(bpi->bmain->image.first, 0);
if (bpi->data) {
/* get the path info from this datatype */
@@ -451,7 +461,7 @@
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);
+ else bpi->data= tex_stepdata__internal(bpi->bmain->tex.first, 0);
if (bpi->data) {
/* get the path info from this datatype */
@@ -478,7 +488,7 @@
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);
+ else bpi->data= text_stepdata__internal(bpi->bmain->text.first, 0);
if (bpi->data) {
/* get the path info from this datatype */
@@ -499,7 +509,7 @@
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);
+ else bpi->data= snd_stepdata__internal(bpi->bmain->sound.first, 0);
if (bpi->data) {
/* get the path info from this datatype */
@@ -520,7 +530,7 @@
} 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 );
+ else bpi->data= vf_stepdata__internal( bpi->bmain->vfont.first, 0 );
if (bpi->data) {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list