readfile: always run setup_app_data after updating defaults
When blend files were loaded with app-templates, setup_app_data was running before defaults were updated. This is likely to cause problems with order of initialization so always update the startup file beforehand.
This commit is contained in:
parent
b13459f9e5
commit
8cd8b3e9bd
|
@ -31,16 +31,32 @@ struct ReportList;
|
|||
struct UserDef;
|
||||
struct bContext;
|
||||
|
||||
int BKE_blendfile_read(struct bContext *C,
|
||||
const char *filepath,
|
||||
const struct BlendFileReadParams *params,
|
||||
struct ReportList *reports);
|
||||
bool BKE_blendfile_read_ex(struct bContext *C,
|
||||
const char *filepath,
|
||||
const struct BlendFileReadParams *params,
|
||||
struct ReportList *reports,
|
||||
/* Extra args. */
|
||||
const bool startup_update_defaults,
|
||||
const char *startup_app_template);
|
||||
bool BKE_blendfile_read(struct bContext *C,
|
||||
const char *filepath,
|
||||
const struct BlendFileReadParams *params,
|
||||
struct ReportList *reports);
|
||||
|
||||
bool BKE_blendfile_read_from_memory_ex(struct bContext *C,
|
||||
const void *filebuf,
|
||||
int filelength,
|
||||
const struct BlendFileReadParams *params,
|
||||
struct ReportList *reports,
|
||||
/* Extra args. */
|
||||
const bool startup_update_defaults,
|
||||
const char *startup_app_template);
|
||||
bool BKE_blendfile_read_from_memory(struct bContext *C,
|
||||
const void *filebuf,
|
||||
int filelength,
|
||||
bool update_defaults,
|
||||
const struct BlendFileReadParams *params,
|
||||
struct ReportList *reports);
|
||||
|
||||
bool BKE_blendfile_read_from_memfile(struct bContext *C,
|
||||
struct MemFile *memfile,
|
||||
const struct BlendFileReadParams *params,
|
||||
|
|
|
@ -428,10 +428,13 @@ static bool handle_subversion_warning(Main *main, ReportList *reports)
|
|||
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;
|
||||
|
@ -449,6 +452,11 @@ int BKE_blendfile_read(bContext *C,
|
|||
bfd = NULL;
|
||||
}
|
||||
else {
|
||||
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);
|
||||
success = true;
|
||||
|
@ -461,23 +469,32 @@ int BKE_blendfile_read(bContext *C,
|
|||
return success;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return BKE_blendfile_read_ex(C, filepath, params, reports, false, NULL);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -488,6 +505,15 @@ bool BKE_blendfile_read_from_memory(bContext *C,
|
|||
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,
|
||||
|
|
|
@ -1034,20 +1034,17 @@ void wm_homefile_read(bContext *C,
|
|||
|
||||
if (!use_factory_settings || (filepath_startup[0] != '\0')) {
|
||||
if (BLI_access(filepath_startup, R_OK) == 0) {
|
||||
success = BKE_blendfile_read(C,
|
||||
filepath_startup,
|
||||
&(const struct BlendFileReadParams){
|
||||
.is_startup = true,
|
||||
.skip_flags = skip_flags | BLO_READ_SKIP_USERDEF,
|
||||
},
|
||||
NULL);
|
||||
success = BKE_blendfile_read_ex(C,
|
||||
filepath_startup,
|
||||
&(const struct BlendFileReadParams){
|
||||
.is_startup = true,
|
||||
.skip_flags = skip_flags | BLO_READ_SKIP_USERDEF,
|
||||
},
|
||||
NULL,
|
||||
update_defaults && use_data,
|
||||
app_template);
|
||||
}
|
||||
if (success) {
|
||||
if (update_defaults) {
|
||||
if (use_data) {
|
||||
BLO_update_defaults_startup_blend(CTX_data_main(C), app_template);
|
||||
}
|
||||
}
|
||||
is_factory_startup = filepath_startup_is_factory;
|
||||
}
|
||||
}
|
||||
|
@ -1066,15 +1063,16 @@ void wm_homefile_read(bContext *C,
|
|||
}
|
||||
|
||||
if (success == false) {
|
||||
success = BKE_blendfile_read_from_memory(C,
|
||||
datatoc_startup_blend,
|
||||
datatoc_startup_blend_size,
|
||||
true,
|
||||
&(const struct BlendFileReadParams){
|
||||
.is_startup = true,
|
||||
.skip_flags = skip_flags,
|
||||
},
|
||||
NULL);
|
||||
success = BKE_blendfile_read_from_memory_ex(C,
|
||||
datatoc_startup_blend,
|
||||
datatoc_startup_blend_size,
|
||||
&(const struct BlendFileReadParams){
|
||||
.is_startup = true,
|
||||
.skip_flags = skip_flags,
|
||||
},
|
||||
NULL,
|
||||
true,
|
||||
NULL);
|
||||
|
||||
if (use_data && BLI_listbase_is_empty(&wmbase)) {
|
||||
wm_clear_default_size(C);
|
||||
|
|
Loading…
Reference in New Issue