Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/blendfile.c')
-rw-r--r--source/blender/blenkernel/intern/blendfile.c87
1 files changed, 49 insertions, 38 deletions
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index 4ea8ae555e3..567773507cf 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -330,7 +330,9 @@ static void setup_app_data(bContext *C,
#ifdef WITH_PYTHON
/* let python know about new main */
- BPY_context_update(C);
+ if (CTX_py_init_get(C)) {
+ BPY_context_update(C);
+ }
#endif
/* FIXME: this version patching should really be part of the file-reading code,
@@ -413,7 +415,7 @@ static void setup_app_blend_file_data(bContext *C,
}
}
-static bool handle_subversion_warning(Main *main, ReportList *reports)
+static void handle_subversion_warning(Main *main, ReportList *reports)
{
if (main->minversionfile > BLENDER_FILE_VERSION ||
(main->minversionfile == BLENDER_FILE_VERSION &&
@@ -424,70 +426,81 @@ static bool handle_subversion_warning(Main *main, ReportList *reports)
main->minversionfile,
main->minsubversionfile);
}
-
- return true;
}
-int BKE_blendfile_read(bContext *C,
- const char *filepath,
- const struct BlendFileReadParams *params,
- ReportList *reports)
+bool BKE_blendfile_read_ex(bContext *C,
+ const char *filepath,
+ const struct BlendFileReadParams *params,
+ ReportList *reports,
+ /* Extra args. */
+ const bool startup_update_defaults,
+ const char *startup_app_template)
{
- BlendFileData *bfd;
- bool success = false;
/* Don't print startup file loading. */
if (params->is_startup == false) {
printf("Read blend: %s\n", filepath);
}
- bfd = BLO_read_from_file(filepath, params->skip_flags, reports);
+ BlendFileData *bfd = BLO_read_from_file(filepath, params->skip_flags, reports);
if (bfd) {
- if (!handle_subversion_warning(bfd->main, reports)) {
- BKE_main_free(bfd->main);
- MEM_freeN(bfd);
- bfd = NULL;
- }
- else {
- setup_app_blend_file_data(C, bfd, filepath, params, reports);
- BLO_blendfiledata_free(bfd);
- success = true;
+ handle_subversion_warning(bfd->main, reports);
+ if (startup_update_defaults) {
+ if ((params->skip_flags & BLO_READ_SKIP_DATA) == 0) {
+ BLO_update_defaults_startup_blend(bfd->main, startup_app_template);
+ }
}
+ setup_app_blend_file_data(C, bfd, filepath, params, reports);
+ BLO_blendfiledata_free(bfd);
}
else {
BKE_reports_prependf(reports, "Loading '%s' failed: ", filepath);
}
-
- return success;
+ return (bfd != NULL);
}
-bool BKE_blendfile_read_from_memory(bContext *C,
- const void *filebuf,
- int filelength,
- bool update_defaults,
- const struct BlendFileReadParams *params,
- ReportList *reports)
+bool BKE_blendfile_read(bContext *C,
+ const char *filepath,
+ const struct BlendFileReadParams *params,
+ ReportList *reports)
{
- BlendFileData *bfd;
+ return BKE_blendfile_read_ex(C, filepath, params, reports, false, NULL);
+}
- bfd = BLO_read_from_memory(filebuf, filelength, params->skip_flags, reports);
+bool BKE_blendfile_read_from_memory_ex(bContext *C,
+ const void *filebuf,
+ int filelength,
+ const struct BlendFileReadParams *params,
+ ReportList *reports,
+ /* Extra args. */
+ const bool startup_update_defaults,
+ const char *startup_app_template)
+{
+ BlendFileData *bfd = BLO_read_from_memory(filebuf, filelength, params->skip_flags, reports);
if (bfd) {
- if (update_defaults) {
+ if (startup_update_defaults) {
if ((params->skip_flags & BLO_READ_SKIP_DATA) == 0) {
- BLO_update_defaults_startup_blend(bfd->main, NULL);
+ BLO_update_defaults_startup_blend(bfd->main, startup_app_template);
}
}
-
setup_app_blend_file_data(C, bfd, "<memory2>", params, reports);
BLO_blendfiledata_free(bfd);
}
else {
BKE_reports_prepend(reports, "Loading failed: ");
}
-
return (bfd != NULL);
}
+bool BKE_blendfile_read_from_memory(bContext *C,
+ const void *filebuf,
+ int filelength,
+ const struct BlendFileReadParams *params,
+ ReportList *reports)
+{
+ return BKE_blendfile_read_from_memory_ex(C, filebuf, filelength, params, reports, false, NULL);
+}
+
/* memfile is the undo buffer */
bool BKE_blendfile_read_from_memfile(bContext *C,
struct MemFile *memfile,
@@ -495,9 +508,8 @@ bool BKE_blendfile_read_from_memfile(bContext *C,
ReportList *reports)
{
Main *bmain = CTX_data_main(C);
- BlendFileData *bfd;
-
- bfd = BLO_read_from_memfile(bmain, BKE_main_blendfile_path(bmain), memfile, params, reports);
+ BlendFileData *bfd = BLO_read_from_memfile(
+ bmain, BKE_main_blendfile_path(bmain), memfile, params, reports);
if (bfd) {
/* Removing the unused workspaces, screens and wm is useless here, setup_app_data will switch
* those lists with the ones from old bmain, which freeing is much more efficient than
@@ -513,7 +525,6 @@ bool BKE_blendfile_read_from_memfile(bContext *C,
else {
BKE_reports_prepend(reports, "Loading failed: ");
}
-
return (bfd != NULL);
}