diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-06-05 18:02:50 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-06-05 18:02:50 +0300 |
commit | f0d9dbae0dae4deae84824833096c38e625073cb (patch) | |
tree | a9fa826eb5860e9b62d16c3498703bde1bb5d4aa /source/blender/blenkernel | |
parent | ce6db959c7d96792edad3a6d606e3662a4ef0798 (diff) | |
parent | 481cdb08ed6f33a09d0e6843d1024db93c301178 (diff) |
Merge branch 'master' into blender2.8
Conflicts:
source/blender/blenkernel/intern/blendfile.c
source/blender/blenloader/intern/readfile.h
source/blender/blenloader/intern/versioning_250.c
source/blender/blenloader/intern/versioning_260.c
source/blender/blenloader/intern/versioning_270.c
source/blender/blenloader/intern/versioning_legacy.c
source/blender/editors/render/render_shading.c
source/blender/makesrna/intern/rna_movieclip.c
source/blender/render/intern/source/pipeline.c
source/blender/render/intern/source/voxeldata.c
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_library.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_movieclip.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/blender_undo.c | 7 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/blendfile.c | 44 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/bpath.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/dynamicpaint.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/font.c | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 9 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 22 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/movieclip.c | 18 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/packedFile.c | 14 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pointcache.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sequencer.c | 21 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sound.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/text.c | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/writeavi.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/writeffmpeg.c | 2 |
18 files changed, 98 insertions, 72 deletions
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index 0f05170b47c..28bc254f25a 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -182,6 +182,9 @@ struct BlendThumbnail *BKE_main_thumbnail_from_imbuf(struct Main *bmain, struct struct ImBuf *BKE_main_thumbnail_to_imbuf(struct Main *bmain, struct BlendThumbnail *data); void BKE_main_thumbnail_create(struct Main *bmain); +const char *BKE_main_blendfile_path(const struct Main *bmain) ATTR_NONNULL(); +const char *BKE_main_blendfile_path_from_global(void); + void BKE_main_id_tag_idcode(struct Main *mainvar, const short type, const int tag, const bool value); void BKE_main_id_tag_listbase(struct ListBase *lb, const int tag, const bool value); void BKE_main_id_tag_all(struct Main *mainvar, const int tag, const bool value); diff --git a/source/blender/blenkernel/BKE_movieclip.h b/source/blender/blenkernel/BKE_movieclip.h index 5b5ebbf035c..014ea2b9159 100644 --- a/source/blender/blenkernel/BKE_movieclip.h +++ b/source/blender/blenkernel/BKE_movieclip.h @@ -49,7 +49,7 @@ void BKE_movieclip_make_local(struct Main *bmain, struct MovieClip *clip, const struct MovieClip *BKE_movieclip_file_add(struct Main *bmain, const char *name); struct MovieClip *BKE_movieclip_file_add_exists_ex(struct Main *bmain, const char *name, bool *r_exists); struct MovieClip *BKE_movieclip_file_add_exists(struct Main *bmain, const char *name); -void BKE_movieclip_reload(struct MovieClip *clip); +void BKE_movieclip_reload(struct Main *bmain, struct MovieClip *clip); void BKE_movieclip_clear_cache(struct MovieClip *clip); void BKE_movieclip_clear_proxy_cache(struct MovieClip *clip); diff --git a/source/blender/blenkernel/intern/blender_undo.c b/source/blender/blenkernel/intern/blender_undo.c index 98482bcc8b1..371d9dff8d5 100644 --- a/source/blender/blenkernel/intern/blender_undo.c +++ b/source/blender/blenkernel/intern/blender_undo.c @@ -67,10 +67,11 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu, bContext *C) { - char mainstr[sizeof(G.main->name)]; + Main *bmain = CTX_data_main(C); + char mainstr[sizeof(bmain->name)]; int success = 0, fileflags; - BLI_strncpy(mainstr, G.main->name, sizeof(mainstr)); /* temporal store */ + BLI_strncpy(mainstr, BKE_main_blendfile_path(bmain), sizeof(mainstr)); /* temporal store */ fileflags = G.fileflags; G.fileflags |= G_FILE_NO_UI; @@ -83,7 +84,7 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu, bContext *C) } /* restore */ - BLI_strncpy(G.main->name, mainstr, sizeof(G.main->name)); /* restore */ + BLI_strncpy(bmain->name, mainstr, sizeof(bmain->name)); /* restore */ G.fileflags = fileflags; if (success) { diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index 34079d778f7..597c69408b5 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -116,6 +116,7 @@ static void setup_app_data( bContext *C, BlendFileData *bfd, const char *filepath, ReportList *reports) { + Main *bmain = G.main; /* Valid usage */ Scene *curscene = NULL; const bool is_startup = (bfd->filename[0] == '\0'); const bool recover = (G.fileflags & G_FILE_RECOVER) != 0; @@ -172,9 +173,9 @@ static void setup_app_data( bool track_undo_scene; /* comes from readfile.c */ - SWAP(ListBase, G.main->wm, bfd->main->wm); - SWAP(ListBase, G.main->workspaces, bfd->main->workspaces); - SWAP(ListBase, G.main->screen, bfd->main->screen); + SWAP(ListBase, bmain->wm, bfd->main->wm); + SWAP(ListBase, bmain->workspaces, bfd->main->workspaces); + SWAP(ListBase, bmain->screen, bfd->main->screen); /* we re-use current window and screen */ win = CTX_wm_window(C); @@ -236,9 +237,9 @@ static void setup_app_data( /* clear old property update cache, in case some old references are left dangling */ RNA_property_update_cache_free(); - G.main = bfd->main; + bmain = G.main = bfd->main; - CTX_data_main_set(C, G.main); + CTX_data_main_set(C, bmain); if (bfd->user) { @@ -266,7 +267,7 @@ static void setup_app_data( /* Keep state from preferences. */ const int fileflags_skip = G_FILE_FLAGS_RUNTIME; G.fileflags = (G.fileflags & fileflags_skip) | (bfd->fileflags & ~fileflags_skip); - CTX_wm_manager_set(C, G.main->wm.first); + CTX_wm_manager_set(C, bmain->wm.first); CTX_wm_screen_set(C, bfd->curscreen); CTX_data_scene_set(C, bfd->curscene); CTX_wm_area_set(C, NULL); @@ -280,10 +281,10 @@ static void setup_app_data( wmWindow *win = CTX_wm_window(C); /* in case we don't even have a local scene, add one */ - if (!G.main->scene.first) - BKE_scene_add(G.main, "Empty"); + if (!bmain->scene.first) + BKE_scene_add(bmain, "Empty"); - CTX_data_scene_set(C, G.main->scene.first); + CTX_data_scene_set(C, bmain->scene.first); win->scene = CTX_data_scene(C); curscene = CTX_data_scene(C); } @@ -307,35 +308,35 @@ static void setup_app_data( /* FIXME: this version patching should really be part of the file-reading code, * but we still get too many unrelated data-corruption crashes otherwise... */ - if (G.main->versionfile < 250) - do_versions_ipos_to_animato(G.main); + if (bmain->versionfile < 250) + do_versions_ipos_to_animato(bmain); - G.main->recovered = 0; + bmain->recovered = 0; /* startup.blend or recovered startup */ if (bfd->filename[0] == 0) { - G.main->name[0] = 0; + bmain->name[0] = '\0'; } else if (recover && G.relbase_valid) { /* in case of autosave or quit.blend, use original filename instead * use relbase_valid to make sure the file is saved, else we get <memory2> in the filename */ filepath = bfd->filename; - G.main->recovered = 1; + bmain->recovered = 1; /* these are the same at times, should never copy to the same location */ - if (G.main->name != filepath) - BLI_strncpy(G.main->name, filepath, FILE_MAX); + if (bmain->name != filepath) + BLI_strncpy(bmain->name, filepath, FILE_MAX); } /* baseflags, groups, make depsgraph, etc */ /* first handle case if other windows have different scenes visible */ if (mode == LOAD_UI) { - wmWindowManager *wm = G.main->wm.first; + wmWindowManager *wm = bmain->wm.first; if (wm) { for (wmWindow *win = wm->windows.first; win; win = win->next) { if (win->scene && win->scene != curscene) { - BKE_scene_set_background(G.main, win->scene); + BKE_scene_set_background(bmain, win->scene); } } } @@ -346,10 +347,10 @@ static void setup_app_data( * constructing dependency graph. */ if (mode != LOAD_UNDO) { - IMB_colormanagement_check_file_config(G.main); + IMB_colormanagement_check_file_config(bmain); } - BKE_scene_set_background(G.main, curscene); + BKE_scene_set_background(bmain, curscene); if (mode != LOAD_UNDO) { /* TODO(sergey): Can this be also move above? */ @@ -431,9 +432,10 @@ bool BKE_blendfile_read_from_memfile( bContext *C, struct MemFile *memfile, ReportList *reports, int skip_flags) { + Main *bmain = CTX_data_main(C); BlendFileData *bfd; - bfd = BLO_read_from_memfile(CTX_data_main(C), G.main->name, memfile, reports, skip_flags); + bfd = BLO_read_from_memfile(bmain, BKE_main_blendfile_path(bmain), memfile, reports, skip_flags); if (bfd) { /* remove the unused screens and wm */ while (bfd->main->wm.first) diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c index 1fd2797d2f8..82d9f9f8f69 100644 --- a/source/blender/blenkernel/intern/bpath.c +++ b/source/blender/blenkernel/intern/bpath.c @@ -325,7 +325,7 @@ void BKE_bpath_missing_files_find(Main *bmain, const char *searchpath, ReportLis struct BPathFind_Data data = {NULL}; const int flag = BKE_BPATH_TRAVERSE_ABS | BKE_BPATH_TRAVERSE_RELOAD_EDITED; - data.basedir = bmain->name; + data.basedir = BKE_main_blendfile_path(bmain); data.reports = reports; data.searchdir = searchpath; data.find_all = find_all; diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 89f5f8facda..36452e1d2cf 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -3216,7 +3216,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char *filenam BKE_image_path_ensure_ext_from_imtype(output_file, format); /* Validate output file path */ - BLI_path_abs(output_file, G.main->name); + BLI_path_abs(output_file, BKE_main_blendfile_path_from_global()); BLI_make_existing_file(output_file); /* Init image buffer */ diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 34b185417e3..f7ab5415d1c 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -255,8 +255,8 @@ VFont *BKE_vfont_load(Main *bmain, const char *filepath) } else { BLI_split_file_part(filepath, filename, sizeof(filename)); - pf = newPackedFile(NULL, filepath, bmain->name); - temp_pf = newPackedFile(NULL, filepath, bmain->name); + pf = newPackedFile(NULL, filepath, BKE_main_blendfile_path(bmain)); + temp_pf = newPackedFile(NULL, filepath, BKE_main_blendfile_path(bmain)); is_builtin = false; } @@ -301,7 +301,7 @@ VFont *BKE_vfont_load_exists_ex(struct Main *bmain, const char *filepath, bool * char str[FILE_MAX], strtest[FILE_MAX]; BLI_strncpy(str, filepath, sizeof(str)); - BLI_path_abs(str, bmain->name); + BLI_path_abs(str, BKE_main_blendfile_path(bmain)); /* first search an identical filepath */ for (vfont = bmain->vfont.first; vfont; vfont = vfont->id.next) { diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index e5c192b3e1e..9a29a8a898b 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -592,7 +592,7 @@ Image *BKE_image_load(Main *bmain, const char *filepath) char str[FILE_MAX]; STRNCPY(str, filepath); - BLI_path_abs(str, bmain->name); + BLI_path_abs(str, BKE_main_blendfile_path(bmain)); /* exists? */ file = BLI_open(str, O_BINARY | O_RDONLY, 0); @@ -621,7 +621,7 @@ Image *BKE_image_load_exists_ex(const char *filepath, bool *r_exists) char str[FILE_MAX], strtest[FILE_MAX]; STRNCPY(str, filepath); - BLI_path_abs(str, G.main->name); + BLI_path_abs(str, BKE_main_blendfile_path_from_global()); /* first search an identical filepath */ for (ima = G.main->image.first; ima; ima = ima->id.next) { @@ -1648,7 +1648,8 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d time_t t; if (scene->r.stamp & R_STAMP_FILENAME) { - SNPRINTF(stamp_data->file, do_prefix ? "File %s" : "%s", G.relbase_valid ? G.main->name : "<untitled>"); + SNPRINTF(stamp_data->file, do_prefix ? "File %s" : "%s", + G.relbase_valid ? BKE_main_blendfile_path_from_global() : "<untitled>"); } else { stamp_data->file[0] = '\0'; @@ -4698,7 +4699,7 @@ static void image_update_views_format(Image *ima, ImageUser *iuser) char str[FILE_MAX]; STRNCPY(str, iv->filepath); - BLI_path_abs(str, G.main->name); + BLI_path_abs(str, BKE_main_blendfile_path_from_global()); /* exists? */ file = BLI_open(str, O_BINARY | O_RDONLY, 0); diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 917b318899c..8dac716ab02 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -155,7 +155,7 @@ * also note that the id _must_ have a library - campbell */ void BKE_id_lib_local_paths(Main *bmain, Library *lib, ID *id) { - const char *bpath_user_data[2] = {bmain->name, lib->filepath}; + const char *bpath_user_data[2] = {BKE_main_blendfile_path(bmain), lib->filepath}; BKE_bpath_traverse_id(bmain, id, BKE_bpath_relocate_visitor, @@ -1737,6 +1737,24 @@ void BKE_main_thumbnail_create(struct Main *bmain) bmain->blen_thumb->height = BLEN_THUMB_SIZE; } +/** + * Return filepath of given \a main. + */ +const char *BKE_main_blendfile_path(const Main *bmain) +{ + return bmain->name; +} + +/** + * Return filepath of global main (G.main). + * + * \warning Usage is not recommended, you should always try to get a velid Main pointer from context... + */ +const char *BKE_main_blendfile_path_from_global(void) +{ + return BKE_main_blendfile_path(G.main); +} + /* ***************** ID ************************ */ ID *BKE_libblock_find_name(struct Main *bmain, const short type, const char *name) { @@ -2525,7 +2543,7 @@ void BKE_library_filepath_set(Main *bmain, Library *lib, const char *filepath) */ /* Never make paths relative to parent lib - reading code (blenloader) always set *all* lib->name relative to * current main, not to their parent for indirectly linked ones. */ - const char *basepath = bmain->name; + const char *basepath = BKE_main_blendfile_path(bmain); BLI_path_abs(lib->filepath, basepath); } } diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index d742bcea69d..fc236cc2ad0 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -199,7 +199,7 @@ static void get_proxy_fname(const MovieClip *clip, else BLI_snprintf(name, FILE_MAX, "%s/%s/proxy_%d/%08d", dir, clipfile, size, proxynr); - BLI_path_abs(name, G.main->name); + BLI_path_abs(name, BKE_main_blendfile_path_from_global()); BLI_path_frame(name, 1, 0); strcat(name, ".jpg"); @@ -270,7 +270,7 @@ static void movieclip_open_anim_file(MovieClip *clip) if (clip->flag & MCLIP_USE_PROXY_CUSTOM_DIR) { char dir[FILE_MAX]; BLI_strncpy(dir, clip->proxy.dir, sizeof(dir)); - BLI_path_abs(dir, G.main->name); + BLI_path_abs(dir, BKE_main_blendfile_path_from_global()); IMB_anim_set_index_dir(clip->anim, dir); } } @@ -627,13 +627,13 @@ static void movieclip_load_get_size(MovieClip *clip) } } -static void detect_clip_source(MovieClip *clip) +static void detect_clip_source(Main *bmain, MovieClip *clip) { ImBuf *ibuf; char name[FILE_MAX]; BLI_strncpy(name, clip->name, sizeof(name)); - BLI_path_abs(name, G.main->name); + BLI_path_abs(name, BKE_main_blendfile_path(bmain)); ibuf = IMB_testiffname(name, IB_rect | IB_multilayer); if (ibuf) { @@ -656,7 +656,7 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *name) char str[FILE_MAX]; BLI_strncpy(str, name, sizeof(str)); - BLI_path_abs(str, bmain->name); + BLI_path_abs(str, BKE_main_blendfile_path(bmain)); /* exists? */ file = BLI_open(str, O_BINARY | O_RDONLY, 0); @@ -670,7 +670,7 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *name) clip = movieclip_alloc(bmain, BLI_path_basename(name)); BLI_strncpy(clip->name, name, sizeof(clip->name)); - detect_clip_source(clip); + detect_clip_source(bmain, clip); movieclip_load_get_size(clip); if (clip->lastsize[0]) { @@ -690,7 +690,7 @@ MovieClip *BKE_movieclip_file_add_exists_ex(Main *bmain, const char *filepath, b char str[FILE_MAX], strtest[FILE_MAX]; BLI_strncpy(str, filepath, sizeof(str)); - BLI_path_abs(str, bmain->name); + BLI_path_abs(str, BKE_main_blendfile_path(bmain)); /* first search an identical filepath */ for (clip = bmain->movieclip.first; clip; clip = clip->id.next) { @@ -1282,13 +1282,13 @@ void BKE_movieclip_clear_proxy_cache(MovieClip *clip) } } -void BKE_movieclip_reload(MovieClip *clip) +void BKE_movieclip_reload(Main *bmain, MovieClip *clip) { /* clear cache */ free_buffers(clip); /* update clip source */ - detect_clip_source(clip); + detect_clip_source(bmain, clip); clip->lastsize[0] = clip->lastsize[1] = 0; movieclip_load_get_size(clip); diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index afb155f7646..baa88f00985 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -246,14 +246,14 @@ void packAll(Main *bmain, ReportList *reports, bool verbose) for (vfont = bmain->vfont.first; vfont; vfont = vfont->id.next) { if (vfont->packedfile == NULL && !ID_IS_LINKED(vfont) && BKE_vfont_is_builtin(vfont) == false) { - vfont->packedfile = newPackedFile(reports, vfont->name, bmain->name); + vfont->packedfile = newPackedFile(reports, vfont->name, BKE_main_blendfile_path(bmain)); tot ++; } } for (sound = bmain->sound.first; sound; sound = sound->id.next) { if (sound->packedfile == NULL && !ID_IS_LINKED(sound)) { - sound->packedfile = newPackedFile(reports, sound->name, bmain->name); + sound->packedfile = newPackedFile(reports, sound->name, BKE_main_blendfile_path(bmain)); tot++; } } @@ -542,7 +542,7 @@ int unpackVFont(Main *bmain, ReportList *reports, VFont *vfont, int how) if (vfont != NULL) { unpack_generate_paths(vfont->name, (ID *)vfont, absname, localname, sizeof(absname), sizeof(localname)); - newname = unpackFile(reports, bmain->name, absname, localname, vfont->packedfile, how); + newname = unpackFile(reports, BKE_main_blendfile_path(bmain), absname, localname, vfont->packedfile, how); if (newname != NULL) { ret_value = RET_OK; freePackedFile(vfont->packedfile); @@ -563,7 +563,7 @@ int unpackSound(Main *bmain, ReportList *reports, bSound *sound, int how) if (sound != NULL) { unpack_generate_paths(sound->name, (ID *)sound, absname, localname, sizeof(absname), sizeof(localname)); - newname = unpackFile(reports, bmain->name, absname, localname, sound->packedfile, how); + newname = unpackFile(reports, BKE_main_blendfile_path(bmain), absname, localname, sound->packedfile, how); if (newname != NULL) { BLI_strncpy(sound->name, newname, sizeof(sound->name)); MEM_freeN(newname); @@ -591,7 +591,7 @@ int unpackImage(Main *bmain, ReportList *reports, Image *ima, int how) ImagePackedFile *imapf = ima->packedfiles.last; unpack_generate_paths(imapf->filepath, (ID *)ima, absname, localname, sizeof(absname), sizeof(localname)); - newname = unpackFile(reports, bmain->name, absname, localname, imapf->packedfile, how); + newname = unpackFile(reports, BKE_main_blendfile_path(bmain), absname, localname, imapf->packedfile, how); if (newname != NULL) { ImageView *iv; @@ -637,7 +637,7 @@ int unpackLibraries(Main *bmain, ReportList *reports) for (lib = bmain->library.first; lib; lib = lib->id.next) { if (lib->packedfile && lib->name[0]) { - newname = unpackFile(reports, bmain->name, lib->filepath, lib->filepath, lib->packedfile, PF_WRITE_ORIGINAL); + newname = unpackFile(reports, BKE_main_blendfile_path(bmain), lib->filepath, lib->filepath, lib->packedfile, PF_WRITE_ORIGINAL); if (newname != NULL) { ret_value = RET_OK; @@ -670,7 +670,7 @@ void packLibraries(Main *bmain, ReportList *reports) for (lib = bmain->library.first; lib; lib = lib->id.next) if (lib->packedfile == NULL) - lib->packedfile = newPackedFile(reports, lib->name, bmain->name); + lib->packedfile = newPackedFile(reports, lib->name, BKE_main_blendfile_path(bmain)); } void unpackAll(Main *bmain, ReportList *reports, int how) diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index e219e27f851..af13909bf89 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1802,7 +1802,7 @@ static int ptcache_frame_from_filename(const char *filename, const char *ext) static int ptcache_path(PTCacheID *pid, char *filename) { Library *lib = (pid->ob) ? pid->ob->id.lib : NULL; - const char *blendfilename= (lib && (pid->cache->flag & PTCACHE_IGNORE_LIBPATH)==0) ? lib->filepath: G.main->name; + const char *blendfilename= (lib && (pid->cache->flag & PTCACHE_IGNORE_LIBPATH)==0) ? lib->filepath: BKE_main_blendfile_path_from_global(); size_t i; if (pid->cache->flag & PTCACHE_EXTERNAL) { diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index a488386fed8..ebf08b26d31 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -945,11 +945,11 @@ Scene *BKE_scene_set_name(Main *bmain, const char *name) Scene *sce = (Scene *)BKE_libblock_find_name(bmain, ID_SCE, name); if (sce) { BKE_scene_set_background(bmain, sce); - printf("Scene switch for render: '%s' in file: '%s'\n", name, bmain->name); + printf("Scene switch for render: '%s' in file: '%s'\n", name, BKE_main_blendfile_path(bmain)); return sce; } - printf("Can't find scene: '%s' in file: '%s'\n", name, bmain->name); + printf("Can't find scene: '%s' in file: '%s'\n", name, BKE_main_blendfile_path(bmain)); return NULL; } diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index f5d99e2615a..ecd0335fc4e 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -898,7 +898,7 @@ void BKE_sequence_reload_new_file(Scene *scene, Sequence *seq, const bool lock_r BLI_join_dirfile(path, sizeof(path), seq->strip->dir, seq->strip->stripdata->name); - BLI_path_abs(path, G.main->name); + BLI_path_abs(path, BKE_main_blendfile_path_from_global()); BKE_sequence_free_anim(seq); @@ -1546,7 +1546,7 @@ static void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile) BLI_join_dirfile(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name); - BLI_path_abs(name, G.main->name); + BLI_path_abs(name, BKE_main_blendfile_path_from_global()); proxy = seq->strip->proxy; @@ -1563,7 +1563,7 @@ static void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile) else { BLI_strncpy(dir, seq->strip->proxy->dir, sizeof(dir)); } - BLI_path_abs(dir, G.main->name); + BLI_path_abs(dir, BKE_main_blendfile_path_from_global()); } if (is_multiview && seq->views_format == R_IMF_VIEWS_INDIVIDUAL) { @@ -1691,7 +1691,7 @@ static bool seq_proxy_get_fname(Editing *ed, Sequence *seq, int cfra, int render return false; } BLI_path_append(dir, sizeof(dir), fname); - BLI_path_abs(name, G.main->name); + BLI_path_abs(name, BKE_main_blendfile_path_from_global()); } else if ((proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_DIR) && (proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_FILE)) { BLI_strncpy(dir, seq->strip->proxy->dir, sizeof(dir)); @@ -1723,7 +1723,7 @@ static bool seq_proxy_get_fname(Editing *ed, Sequence *seq, int cfra, int render { char fname[FILE_MAXFILE]; BLI_join_dirfile(fname, PROXY_MAXFILE, dir, proxy->file); - BLI_path_abs(fname, G.main->name); + BLI_path_abs(fname, BKE_main_blendfile_path_from_global()); if (suffix[0] != '\0') { /* TODO(sergey): This will actually append suffix after extension * which is weird but how was originally coded in multiview branch. @@ -1749,7 +1749,7 @@ static bool seq_proxy_get_fname(Editing *ed, Sequence *seq, int cfra, int render BLI_snprintf(name, PROXY_MAXFILE, "%s/proxy_misc/%d/####%s", dir, render_size, suffix); } - BLI_path_abs(name, G.main->name); + BLI_path_abs(name, BKE_main_blendfile_path_from_global()); BLI_path_frame(name, frameno, 0); strcat(name, ".jpg"); @@ -1894,7 +1894,7 @@ static bool seq_proxy_multiview_context_invalid(Sequence *seq, Scene *scene, con char path[FILE_MAX]; BLI_join_dirfile(path, sizeof(path), seq->strip->dir, seq->strip->stripdata->name); - BLI_path_abs(path, G.main->name); + BLI_path_abs(path, BKE_main_blendfile_path_from_global()); BKE_scene_multiview_view_prefix_get(scene, path, prefix, &ext); } else { @@ -2846,7 +2846,7 @@ static ImBuf *seq_render_image_strip(const SeqRenderData *context, Sequence *seq if (s_elem) { BLI_join_dirfile(name, sizeof(name), seq->strip->dir, s_elem->name); - BLI_path_abs(name, G.main->name); + BLI_path_abs(name, BKE_main_blendfile_path_from_global()); } flag = IB_rect | IB_metadata; @@ -5151,7 +5151,7 @@ void BKE_sequence_init_colorspace(Sequence *seq) ImBuf *ibuf; BLI_join_dirfile(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name); - BLI_path_abs(name, G.main->name); + BLI_path_abs(name, BKE_main_blendfile_path_from_global()); /* initialize input color space */ if (seq->type == SEQ_TYPE_IMAGE) { @@ -5319,6 +5319,7 @@ static void seq_anim_add_suffix(Scene *scene, struct anim *anim, const int view_ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); /* only for sound */ char path[sizeof(seq_load->path)]; @@ -5333,7 +5334,7 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad int i; BLI_strncpy(path, seq_load->path, sizeof(path)); - BLI_path_abs(path, G.main->name); + BLI_path_abs(path, BKE_main_blendfile_path(bmain)); anim_arr = MEM_callocN(sizeof(struct anim *) * totfiles, "Video files"); diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 747ffdafe8b..a7f3fc1df9e 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -77,7 +77,7 @@ bSound *BKE_sound_new_file(struct Main *bmain, const char *filepath) BLI_strncpy(str, filepath, sizeof(str)); - path = /*bmain ? bmain->name :*/ G.main->name; + path = BKE_main_blendfile_path(bmain); BLI_path_abs(str, path); @@ -96,7 +96,7 @@ bSound *BKE_sound_new_file_exists_ex(struct Main *bmain, const char *filepath, b char str[FILE_MAX], strtest[FILE_MAX]; BLI_strncpy(str, filepath, sizeof(str)); - BLI_path_abs(str, bmain->name); + BLI_path_abs(str, BKE_main_blendfile_path(bmain)); /* first search an identical filepath */ for (sound = bmain->sound.first; sound; sound = sound->id.next) { diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 3892b2f0546..a24020d7764 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -388,7 +388,7 @@ bool BKE_text_reload(Text *text) } BLI_strncpy(filepath_abs, text->name, FILE_MAX); - BLI_path_abs(filepath_abs, G.main->name); + BLI_path_abs(filepath_abs, BKE_main_blendfile_path_from_global()); buffer = BLI_file_read_text_as_mem(filepath_abs, 0, &buffer_len); if (buffer == NULL) { @@ -557,7 +557,7 @@ int BKE_text_file_modified_check(Text *text) return 0; BLI_strncpy(file, text->name, FILE_MAX); - BLI_path_abs(file, G.main->name); + BLI_path_abs(file, BKE_main_blendfile_path_from_global()); if (!BLI_exists(file)) return 2; @@ -585,7 +585,7 @@ void BKE_text_file_modified_ignore(Text *text) if (!text->name) return; BLI_strncpy(file, text->name, FILE_MAX); - BLI_path_abs(file, G.main->name); + BLI_path_abs(file, BKE_main_blendfile_path_from_global()); if (!BLI_exists(file)) return; diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index e357f13530d..33ac312425b 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -145,7 +145,7 @@ static void filepath_avi(char *string, RenderData *rd, bool preview, const char } strcpy(string, rd->pic); - BLI_path_abs(string, G.main->name); + BLI_path_abs(string, BKE_main_blendfile_path_from_global()); BLI_make_existing_file(string); diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 4a0f697c9ce..17c665f3bcd 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -1127,7 +1127,7 @@ static void ffmpeg_filepath_get(FFMpegContext *context, char *string, RenderData } strcpy(string, rd->pic); - BLI_path_abs(string, G.main->name); + BLI_path_abs(string, BKE_main_blendfile_path_from_global()); BLI_make_existing_file(string); |