use newly added ID_BLEND_PATH() in more places.
authorCampbell Barton <ideasman42@gmail.com>
Sat, 8 Oct 2011 11:11:54 +0000 (11:11 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 8 Oct 2011 11:11:54 +0000 (11:11 +0000)
source/blender/blenkernel/intern/customdata.c
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/sound.c
source/blender/python/generic/bpy_internal_import.c

index 30da2e0..d407bbe 100644 (file)
@@ -2383,10 +2383,8 @@ int CustomData_verify_versions(struct CustomData *data, int index)
 
 static void customdata_external_filename(char filename[FILE_MAX], ID *id, CustomDataExternal *external)
 {
-       char *path = (id->lib)? id->lib->filepath: G.main->name;
-
        BLI_strncpy(filename, external->filename, FILE_MAX);
-       BLI_path_abs(filename, path);
+       BLI_path_abs(filename, ID_BLEND_PATH(G.main, id));
 }
 
 void CustomData_external_reload(CustomData *data, ID *UNUSED(id), CustomDataMask mask, int totelem)
index 834961b..f6210d3 100644 (file)
@@ -1653,10 +1653,7 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame)
        BLI_stringdec(name, head, tail, &numlen);
        BLI_stringenc(name, head, tail, numlen, frame);
 
-       if(ima->id.lib)
-               BLI_path_abs(name, ima->id.lib->filepath);
-       else
-               BLI_path_abs(name, G.main->name);
+       BLI_path_abs(name, ID_BLEND_PATH(G.main, &ima->id));
        
        flag= IB_rect|IB_multilayer;
        if(ima->flag & IMA_DO_PREMUL)
@@ -1768,11 +1765,8 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame)
                char str[FILE_MAX];
                
                BLI_strncpy(str, ima->name, FILE_MAX);
-               if(ima->id.lib)
-                       BLI_path_abs(str, ima->id.lib->filepath);
-               else
-                       BLI_path_abs(str, G.main->name);
-               
+               BLI_path_abs(str, ID_BLEND_PATH(G.main, &ima->id));
+
                /* FIXME: make several stream accessible in image editor, too*/
                ima->anim = openanim(str, IB_rect, 0);
                
@@ -1834,10 +1828,7 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra)
                        
                /* get the right string */
                BLI_strncpy(str, ima->name, sizeof(str));
-               if(ima->id.lib)
-                       BLI_path_abs(str, ima->id.lib->filepath);
-               else
-                       BLI_path_abs(str, G.main->name);
+               BLI_path_abs(str, ID_BLEND_PATH(G.main, &ima->id));
                
                /* read ibuf */
                ibuf = IMB_loadiffname(str, flag);
index 73d0d70..f2d9215 100644 (file)
@@ -340,20 +340,13 @@ void sound_load(struct Main *bmain, struct bSound* sound)
 #endif
                {
                        char fullpath[FILE_MAX];
-                       char *path;
 
                        /* load sound */
                        PackedFile* pf = sound->packedfile;
 
                        /* dont modify soundact->sound->name, only change a copy */
                        BLI_strncpy(fullpath, sound->name, sizeof(fullpath));
-
-                       if(sound->id.lib)
-                               path = sound->id.lib->filepath;
-                       else
-                               path = bmain->name;
-
-                       BLI_path_abs(fullpath, path);
+                       BLI_path_abs(fullpath, ID_BLEND_PATH(bmain, &sound->id));
 
                        /* but we need a packed file then */
                        if (pf)
index 9026010..d29bc79 100644 (file)
@@ -93,7 +93,7 @@ void bpy_import_main_set(struct Main *maggie)
 /* returns a dummy filename for a textblock so we can tell what file a text block comes from */
 void bpy_text_filename_get(char *fn, size_t fn_len, Text *text)
 {
-       BLI_snprintf(fn, fn_len, "%s%c%s", text->id.lib ? text->id.lib->filepath : bpy_import_main->name, SEP, text->id.name+2);
+       BLI_snprintf(fn, fn_len, "%s%c%s", ID_BLEND_PATH(bpy_import_main, &text->id), SEP, text->id.name+2);
 }
 
 PyObject *bpy_text_import(Text *text)