Cleanup: match logic for merging G.f & G.fileflags on load
This commit is contained in:
@@ -116,6 +116,10 @@ enum {
|
||||
G_FLAG_SCRIPT_AUTOEXEC_FAIL_QUIET = (1 << 16),
|
||||
};
|
||||
|
||||
/** Don't overwrite these flags when reading a file. */
|
||||
#define G_FLAG_ALL_RUNTIME \
|
||||
(G_FLAG_SCRIPT_AUTOEXEC | G_FLAG_SCRIPT_OVERRIDE_PREF)
|
||||
|
||||
/** #Global.debug */
|
||||
enum {
|
||||
G_DEBUG = (1 << 0), /* general debug flag, print more info in unexpected cases */
|
||||
@@ -173,7 +177,9 @@ enum {
|
||||
/* #define G_FILE_GLSL_NO_ENV_LIGHTING (1 << 28) */ /* deprecated */
|
||||
};
|
||||
|
||||
#define G_FILE_FLAGS_RUNTIME (G_FILE_NO_UI | G_FILE_RELATIVE_REMAP | G_FILE_SAVE_COPY)
|
||||
/** Don't overwrite these flags when reading a file. */
|
||||
#define G_FILE_FLAG_ALL_RUNTIME \
|
||||
(G_FILE_NO_UI | G_FILE_RELATIVE_REMAP | G_FILE_SAVE_COPY)
|
||||
|
||||
/** ENDIAN_ORDER: indicates what endianness the platform where the file was written had. */
|
||||
#if !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
|
||||
|
||||
@@ -270,8 +270,8 @@ 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);
|
||||
const int fileflags_keep = G_FILE_FLAG_ALL_RUNTIME;
|
||||
G.fileflags = (G.fileflags & fileflags_keep) | (bfd->fileflags & ~fileflags_keep);
|
||||
|
||||
/* this can happen when active scene was lib-linked, and doesn't exist anymore */
|
||||
if (CTX_data_scene(C) == NULL) {
|
||||
@@ -291,7 +291,7 @@ static void setup_app_data(
|
||||
|
||||
/* special cases, override loaded flags: */
|
||||
if (G.f != bfd->globalf) {
|
||||
const int flags_keep = (G_FLAG_SCRIPT_AUTOEXEC | G_FLAG_SCRIPT_OVERRIDE_PREF);
|
||||
const int flags_keep = G_FLAG_ALL_RUNTIME;
|
||||
bfd->globalf = (bfd->globalf & ~flags_keep) | (G.f & flags_keep);
|
||||
}
|
||||
|
||||
|
||||
@@ -3782,7 +3782,7 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar)
|
||||
fg.cur_view_layer = view_layer;
|
||||
|
||||
/* prevent to save this, is not good convention, and feature with concerns... */
|
||||
fg.fileflags = (fileflags & ~G_FILE_FLAGS_RUNTIME);
|
||||
fg.fileflags = (fileflags & ~G_FILE_FLAG_ALL_RUNTIME);
|
||||
|
||||
fg.globalf = G.f;
|
||||
BLI_strncpy(fg.filename, mainvar->name, sizeof(fg.filename));
|
||||
|
||||
@@ -586,7 +586,7 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
|
||||
|
||||
/* we didn't succeed, now try to read Blender file */
|
||||
if (retval == BKE_READ_EXOTIC_OK_BLEND) {
|
||||
int G_f = G.f;
|
||||
const int G_f_orig = G.f;
|
||||
ListBase wmbase;
|
||||
|
||||
/* put aside screens to match with persistent windows later */
|
||||
@@ -614,9 +614,9 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
|
||||
|
||||
/* this flag is initialized by the operator but overwritten on read.
|
||||
* need to re-enable it here else drivers + registered scripts wont work. */
|
||||
if (G.f != G_f) {
|
||||
const int flags_keep = (G_FLAG_SCRIPT_AUTOEXEC | G_FLAG_SCRIPT_OVERRIDE_PREF);
|
||||
G.f = (G.f & ~flags_keep) | (G_f & flags_keep);
|
||||
if (G.f != G_f_orig) {
|
||||
const int flags_keep = G_FLAG_ALL_RUNTIME;
|
||||
G.f = (G.f & ~flags_keep) | (G_f_orig & flags_keep);
|
||||
}
|
||||
|
||||
/* match the read WM with current WM */
|
||||
|
||||
Reference in New Issue
Block a user