[Bf-blender-cvs] [481cdb08ed6] master: Cleanup: use new accessors to blendfile path (Main.name).
Bastien Montagne
noreply at git.blender.org
Tue Jun 5 16:33:53 CEST 2018
Commit: 481cdb08ed6f33a09d0e6843d1024db93c301178
Author: Bastien Montagne
Date: Tue Jun 5 15:10:33 2018 +0200
Branches: master
https://developer.blender.org/rB481cdb08ed6f33a09d0e6843d1024db93c301178
Cleanup: use new accessors to blendfile path (Main.name).
===================================================================
M source/blender/blenkernel/BKE_library.h
M source/blender/blenkernel/BKE_movieclip.h
M source/blender/blenkernel/intern/blender_undo.c
M source/blender/blenkernel/intern/blendfile.c
M source/blender/blenkernel/intern/bpath.c
M source/blender/blenkernel/intern/dynamicpaint.c
M source/blender/blenkernel/intern/font.c
M source/blender/blenkernel/intern/image.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/pointcache.c
M source/blender/blenkernel/intern/scene.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/blenkernel/intern/writeavi.c
M source/blender/blenkernel/intern/writeffmpeg.c
M source/blender/blenloader/intern/readfile.c
M source/blender/blenloader/intern/readfile.h
M source/blender/blenloader/intern/undofile.c
M source/blender/blenloader/intern/versioning_250.c
M source/blender/blenloader/intern/versioning_260.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/collada/ImageExporter.cpp
M source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp
M source/blender/compositor/operations/COM_OutputFileOperation.cpp
M source/blender/editors/interface/interface_ops.c
M source/blender/editors/io/io_alembic.c
M source/blender/editors/io/io_cache.c
M source/blender/editors/io/io_collada.c
M source/blender/editors/object/object_bake_api.c
M source/blender/editors/object/object_modifier.c
M source/blender/editors/render/render_opengl.c
M source/blender/editors/render/render_preview.c
M source/blender/editors/render/render_shading.c
M source/blender/editors/screen/screendump.c
M source/blender/editors/sound/sound_ops.c
M source/blender/editors/space_buttons/buttons_ops.c
M source/blender/editors/space_clip/clip_ops.c
M source/blender/editors/space_file/file_draw.c
M source/blender/editors/space_file/file_intern.h
M source/blender/editors/space_file/file_ops.c
M source/blender/editors/space_file/filelist.c
M source/blender/editors/space_file/filesel.c
M source/blender/editors/space_image/image_ops.c
M source/blender/editors/space_info/info_ops.c
M source/blender/editors/space_outliner/outliner_draw.c
M source/blender/editors/space_sequencer/sequencer_add.c
M source/blender/editors/space_sequencer/sequencer_edit.c
M source/blender/editors/space_text/text_ops.c
M source/blender/editors/util/ed_util.c
M source/blender/makesdna/DNA_ID.h
M source/blender/makesrna/intern/rna_color.c
M source/blender/makesrna/intern/rna_image_api.c
M source/blender/makesrna/intern/rna_main_api.c
M source/blender/makesrna/intern/rna_movieclip.c
M source/blender/makesrna/intern/rna_nodetree.c
M source/blender/makesrna/intern/rna_scene_api.c
M source/blender/python/intern/bpy_interface.c
M source/blender/python/intern/bpy_library_load.c
M source/blender/python/intern/bpy_library_write.c
M source/blender/render/intern/source/pipeline.c
M source/blender/render/intern/source/render_result.c
M source/blender/render/intern/source/voxeldata.c
M source/blender/windowmanager/intern/wm_files.c
M source/blender/windowmanager/intern/wm_files_link.c
M source/blender/windowmanager/intern/wm_init_exit.c
M source/blender/windowmanager/intern/wm_operators.c
M source/blender/windowmanager/intern/wm_window.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 1c64aa63917..935e90d7ed0 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -174,7 +174,7 @@ 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(struct Main *bmain) ATTR_NONNULL();
+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);
diff --git a/source/blender/blenkernel/BKE_movieclip.h b/source/blender/blenkernel/BKE_movieclip.h
index 818f79ad8ac..b79f37fd040 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 6b31c8c96f9..c3306b16041 100644
--- a/source/blender/blenkernel/intern/blender_undo.c
+++ b/source/blender/blenkernel/intern/blender_undo.c
@@ -66,10 +66,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;
@@ -82,7 +83,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 cc992a4a520..935000e3b8e 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -113,6 +113,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;
@@ -167,8 +168,8 @@ 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->screen, bfd->main->screen);
+ SWAP(ListBase, bmain->wm, bfd->main->wm);
+ SWAP(ListBase, bmain->screen, bfd->main->screen);
/* we re-use current screen */
curscreen = CTX_wm_screen(C);
@@ -221,9 +222,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) {
/* only here free userdef themes... */
@@ -250,7 +251,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);
@@ -262,10 +263,10 @@ static void setup_app_data(
/* this can happen when active scene was lib-linked, and doesn't exist anymore */
if (CTX_data_scene(C) == NULL) {
/* 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);
CTX_wm_screen(C)->scene = CTX_data_scene(C);
curscene = CTX_data_scene(C);
}
@@ -289,30 +290,30 @@ 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) {
wmWindow *win;
@@ -320,15 +321,15 @@ static void setup_app_data(
for (win = wm->windows.first; win; win = win->next) {
if (win->screen && win->screen->scene) /* zealous check... */
if (win->screen->scene != curscene)
- BKE_scene_set_background(G.main, win->screen->scene);
+ BKE_scene_set_background(bmain, win->screen->scene);
}
}
}
- BKE_scene_set_background(G.main, curscene);
+ BKE_scene_set_background(bmain, curscene);
if (mode != LOAD_UNDO) {
RE_FreeAllPersistentData();
- IMB_colormanagement_check_file_config(G.main);
+ IMB_colormanagement_check_file_config(bmain);
}
MEM_freeN(bfd);
@@ -406,9 +407,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 2e8c369451b..e6be42088db 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 954bfc90eda..87fd10c7e7d 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -3232,7 +3232,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 5545eba8764..39be0f67c93 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 8fd672963c7..1d909ba1a76 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -594,7 +594,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);
@@ -623,7 +623,7 @@ Image *BKE_image_load_exists_ex
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list