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.c78
1 files changed, 68 insertions, 10 deletions
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index afbd2627a2a..0d94fbe648f 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -32,25 +32,30 @@
#include "BLI_listbase.h"
#include "BLI_string.h"
+#include "BLI_system.h"
#include "BLI_path_util.h"
#include "BLI_utildefines.h"
#include "IMB_colormanagement.h"
+#include "BKE_addon.h"
#include "BKE_appdir.h"
#include "BKE_blender.h"
#include "BKE_blender_version.h"
#include "BKE_blendfile.h"
#include "BKE_bpath.h"
+#include "BKE_colorband.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_ipo.h"
+#include "BKE_keyconfig.h"
#include "BKE_layer.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
+#include "BKE_studiolight.h"
#include "BKE_workspace.h"
#include "BLO_readfile.h"
@@ -367,7 +372,7 @@ static void setup_app_data(bContext *C,
* lib_link on local IDs using linked ones.
* There is no real way to predict amount of changes here, so we have to fully redo
* refcounting . */
- BLE_main_id_refcount_recompute(bmain, true);
+ BKE_main_id_refcount_recompute(bmain, true);
}
}
@@ -405,35 +410,31 @@ int BKE_blendfile_read(bContext *C,
ReportList *reports)
{
BlendFileData *bfd;
- int retval = BKE_BLENDFILE_READ_OK;
+ bool success = false;
- /* don't print user-pref loading */
- if (strstr(filepath, BLENDER_STARTUP_FILE) == NULL) {
+ /* 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);
if (bfd) {
- if (bfd->user) {
- retval = BKE_BLENDFILE_READ_OK_USERPREFS;
- }
-
if (0 == handle_subversion_warning(bfd->main, reports)) {
BKE_main_free(bfd->main);
MEM_freeN(bfd);
bfd = NULL;
- retval = BKE_BLENDFILE_READ_FAIL;
}
else {
setup_app_blend_file_data(C, bfd, filepath, params, reports);
BLO_blendfiledata_free(bfd);
+ success = true;
}
}
else {
BKE_reports_prependf(reports, "Loading '%s' failed: ", filepath);
}
- return (bfd ? retval : BKE_BLENDFILE_READ_FAIL);
+ return success;
}
bool BKE_blendfile_read_from_memory(bContext *C,
@@ -556,6 +557,63 @@ UserDef *BKE_blendfile_userdef_read_from_memory(const void *filebuf,
return userdef;
}
+UserDef *BKE_blendfile_userdef_from_defaults(void)
+{
+ UserDef *userdef = MEM_mallocN(sizeof(*userdef), __func__);
+ memcpy(userdef, &U_default, sizeof(*userdef));
+
+ /* Add-ons. */
+ {
+ const char *addons[] = {
+ "io_anim_bvh",
+ "io_curve_svg",
+ "io_mesh_ply",
+ "io_mesh_stl",
+ "io_mesh_uv_layout",
+ "io_scene_fbx",
+ "io_scene_gltf2",
+ "io_scene_obj",
+ "io_scene_x3d",
+ "cycles",
+ };
+ for (int i = 0; i < ARRAY_SIZE(addons); i++) {
+ bAddon *addon = BKE_addon_new();
+ STRNCPY(addon->module, addons[i]);
+ BLI_addtail(&userdef->addons, addon);
+ }
+ }
+
+ /* Theme. */
+ {
+ bTheme *btheme = MEM_mallocN(sizeof(*btheme), __func__);
+ memcpy(btheme, &U_theme_default, sizeof(*btheme));
+
+ BLI_addtail(&userdef->themes, btheme);
+ }
+
+#ifdef WITH_PYTHON_SECURITY
+ /* use alternative setting for security nuts
+ * otherwise we'd need to patch the binary blob - startup.blend.c */
+ userdef->flag |= USER_SCRIPT_AUTOEXEC_DISABLE;
+#else
+ userdef->flag &= ~USER_SCRIPT_AUTOEXEC_DISABLE;
+#endif
+
+ /* System-specific fonts directory. */
+ BKE_appdir_font_folder_default(userdef->fontdir);
+
+ userdef->memcachelimit = min_ii(BLI_system_memory_max_in_megabytes_int() / 2,
+ userdef->memcachelimit);
+
+ /* Init weight paint range. */
+ BKE_colorband_init(&userdef->coba_weight, true);
+
+ /* Default studio light. */
+ BKE_studiolight_default(userdef->light_param, userdef->light_ambient);
+
+ return userdef;
+}
+
/**
* Only write the userdef in a .blend
* \return success