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:
authorCampbell Barton <ideasman42@gmail.com>2019-07-30 04:04:02 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-07-31 14:36:12 +0300
commit07499c04f6126b325e1d6db68e430f36b514b355 (patch)
tree5c07ee1906eb4b4f2d11187ea36eee742fbe25cd
parent86029b507194fb88a8eb9c86c83255d76adbafed (diff)
Preferences: don't store preferences in the startup
Simplify preferences by removing the ability to load them from either the startup.blend or userpref.blend. Also simplifies updating default preferences by moving them to a struct definition.
-rw-r--r--release/datafiles/userdef/userdef_default.c188
-rw-r--r--source/blender/blenkernel/BKE_blendfile.h1
-rw-r--r--source/blender/blenkernel/CMakeLists.txt1
-rw-r--r--source/blender/blenkernel/intern/blendfile.c30
-rw-r--r--source/blender/blenloader/BLO_readfile.h1
-rw-r--r--source/blender/blenloader/intern/versioning_defaults.c39
-rw-r--r--source/blender/windowmanager/intern/wm_files.c26
7 files changed, 236 insertions, 50 deletions
diff --git a/release/datafiles/userdef/userdef_default.c b/release/datafiles/userdef/userdef_default.c
new file mode 100644
index 00000000000..053b8e75153
--- /dev/null
+++ b/release/datafiles/userdef/userdef_default.c
@@ -0,0 +1,188 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/* Preferences Data File 'U_default'. */
+
+#include "DNA_userdef_types.h"
+#include "DNA_curve_types.h"
+
+#include "BKE_blender_version.h"
+
+const UserDef U_default = {
+ .versionfile = BLENDER_VERSION,
+ .subversionfile = BLENDER_SUBVERSION,
+ .flag = (USER_AUTOSAVE | USER_TOOLTIPS | USER_SAVE_PREVIEWS | USER_RELPATHS |
+ USER_RELEASECONFIRM | USER_SCRIPT_AUTOEXEC_DISABLE | USER_NONEGFRAMES),
+ .dupflag = USER_DUP_MESH | USER_DUP_CURVE | USER_DUP_SURF | USER_DUP_FONT | USER_DUP_MBALL |
+ USER_DUP_LAMP | USER_DUP_ARM | USER_DUP_ACT | USER_DUP_LIGHTPROBE |
+ USER_DUP_GPENCIL,
+ .pref_flag = USER_PREF_FLAG_SAVE,
+ .savetime = 2,
+ .tempdir = "",
+ .fontdir = "//",
+ .renderdir = "//",
+ .render_cachedir = "",
+ .textudir = "//",
+ .pythondir = "",
+ .sounddir = "//",
+ .i18ndir = "",
+ .image_editor = "",
+ .anim_player = "",
+ .anim_player_preset = 0,
+ .v2d_min_gridsize = 45,
+ .timecode_style = USER_TIMECODE_MINIMAL,
+ .versions = 1,
+ .dbl_click_time = 350,
+ .wheellinescroll = 3,
+ .mini_axis_type = USER_MINI_AXIS_TYPE_GIZMO,
+ .uiflag = (USER_FILTERFILEEXTS | USER_DRAWVIEWINFO | USER_PLAINMENUS |
+ USER_LOCK_CURSOR_ADJUST | USER_DEPTH_CURSOR | USER_AUTOPERSP | USER_GLOBALUNDO |
+ USER_HIDE_DOT | USER_SHOW_GIZMO_NAVIGATE | USER_SHOW_VIEWPORTNAME | USER_SHOW_FPS |
+ USER_CONTINUOUS_MOUSE | USER_SAVE_PROMPT),
+ .uiflag2 = USER_REGION_OVERLAP,
+ .gpu_flag = 0,
+ .app_flag = 0,
+ .language = 0,
+ .userpref = USER_SECTION_INTERFACE,
+ .userpref_flag = 0,
+ .viewzoom = USER_ZOOM_DOLLY,
+ .mixbufsize = 2048,
+ .audiodevice = 0,
+ .audiorate = 48000,
+ .audioformat = 0x24,
+ .audiochannels = 2,
+ .ui_scale = 1,
+ .ui_line_width = 0,
+ .dpi = 75,
+ .dpi_fac = 0.0, /* run-time. */
+ .inv_dpi_fac = 0.0, /* run-time. */
+ .pixelsize = 1,
+ .virtual_pixel = 0,
+ .scrollback = 256,
+ .node_margin = 80,
+ .transopts = USER_TR_TOOLTIPS,
+ .menuthreshold1 = 5,
+ .menuthreshold2 = 2,
+ .app_template = "",
+
+ /** Initialized by #UI_theme_init_default. */
+ .themes = (ListBase){NULL},
+
+ /** Initialized by #uiStyleInit. */
+ .uifonts = (ListBase){NULL},
+ .uistyles = (ListBase){NULL},
+
+ .user_keymaps = (ListBase){NULL},
+ .user_keyconfig_prefs = (ListBase){NULL},
+
+ /** Initialized by #BKE_blendfile_userdef_from_defaults. */
+ .addons = (ListBase){NULL},
+
+ .autoexec_paths = (ListBase){NULL},
+ .user_menus = (ListBase){NULL},
+
+ .keyconfigstr = "blender",
+ .undosteps = 32,
+ .undomemory = 0,
+ .gpu_viewport_quality = 0.6,
+ .gp_manhattendist = 1,
+ .gp_euclideandist = 2,
+ .gp_eraser = 25,
+ .gp_settings = 0,
+
+ /** Initialized by: #BKE_studiolight_default . */
+ .light_param = {{0}},
+ .light_ambient = {0, 0, 0},
+
+ .gizmo_flag = USER_GIZMO_DRAW,
+ .gizmo_size = 75,
+ .edit_studio_light = 0,
+ .lookdev_sphere_size = 150,
+ .vbotimeout = 120,
+ .vbocollectrate = 60,
+ .textimeout = 120,
+ .texcollectrate = 60,
+ .memcachelimit = 4096,
+ .prefetchframes = 0,
+ .pad_rot_angle = 15,
+ .rvisize = 25,
+ .rvibright = 8,
+ .recent_files = 10,
+ .smooth_viewtx = 200,
+ .glreslimit = 0,
+ .curssize = 0,
+ .color_picker_type = USER_CP_CIRCLE_HSV,
+ .ipo_new = BEZT_IPO_BEZ,
+ .keyhandles_new = HD_AUTO_ANIM,
+ .view_frame_type = ZOOM_FRAME_MODE_KEEP_RANGE,
+ .view_frame_keyframes = 0,
+ .view_frame_seconds = 0.0,
+ .widget_unit = 0, /* run-time initialized. */
+ .anisotropic_filter = 2,
+ .tablet_api = USER_TABLET_AUTOMATIC,
+ .pressure_threshold_max = 1.0,
+ .pressure_softness = 0.0,
+ .ndof_sensitivity = 1.0,
+ .ndof_orbit_sensitivity = 1.0,
+ .ndof_deadzone = 0.1,
+ .ndof_flag = (NDOF_LOCK_HORIZON | NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE),
+ .ogl_multisamples = 0,
+ .image_draw_method = IMAGE_DRAW_METHOD_AUTO,
+ .glalphaclip = 0.004,
+ .autokey_mode = (AUTOKEY_MODE_NORMAL & ~AUTOKEY_ON),
+ .autokey_flag = AUTOKEY_FLAG_XYZ2RGB,
+ .text_render = 0,
+ .navigation_mode = VIEW_NAVIGATION_WALK,
+
+ /** Initialized by #BKE_colorband_init. */
+ .coba_weight = {0},
+
+ .sculpt_paint_overlay_col = {0, 0, 0},
+ .gpencil_new_layer_col = {0.38, 0.61, 0.78, 0.9},
+ .drag_threshold_mouse = 3,
+ .drag_threshold_tablet = 10,
+ .drag_threshold = 30,
+ .move_threshold = 2,
+ .font_path_ui = "",
+ .font_path_ui_mono = "",
+ .compute_device_type = 0,
+ .compute_device_id = 0,
+ .fcu_inactive_alpha = 0.25,
+ .pie_tap_timeout = 20,
+ .pie_initial_timeout = 0,
+ .pie_animation_timeout = 6,
+ .pie_menu_confirm = 0,
+ .pie_menu_radius = 100,
+ .pie_menu_threshold = 12,
+ .walk_navigation =
+ {
+ .mouse_speed = 1,
+ .walk_speed = 2.5,
+ .walk_speed_factor = 5,
+ .view_height = 1.6,
+ .jump_height = 0.4,
+ .teleport_time = 0.2,
+ .flag = 0,
+ },
+ .opensubdiv_compute_type = 0,
+ .gpencil_multisamples = 4,
+ .factor_display_type = USER_FACTOR_AS_FACTOR,
+ .viewport_aa = 8,
+ .runtime =
+ {
+ .is_dirty = 0,
+ },
+};
diff --git a/source/blender/blenkernel/BKE_blendfile.h b/source/blender/blenkernel/BKE_blendfile.h
index 7fc27321fc7..2bff684948d 100644
--- a/source/blender/blenkernel/BKE_blendfile.h
+++ b/source/blender/blenkernel/BKE_blendfile.h
@@ -52,6 +52,7 @@ struct UserDef *BKE_blendfile_userdef_read(const char *filepath, struct ReportLi
struct UserDef *BKE_blendfile_userdef_read_from_memory(const void *filebuf,
int filelength,
struct ReportList *reports);
+struct UserDef *BKE_blendfile_userdef_from_defaults(void);
bool BKE_blendfile_userdef_write(const char *filepath, struct ReportList *reports);
bool BKE_blendfile_userdef_write_app_template(const char *filepath, struct ReportList *reports);
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index e564e91749c..d9bd87d97b5 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -58,6 +58,7 @@ set(INC_SYS
)
set(SRC
+ ${CMAKE_SOURCE_DIR}/release/datafiles/userdef/userdef_default.c
intern/CCGSubSurf.c
intern/CCGSubSurf_legacy.c
intern/CCGSubSurf_opensubdiv.c
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index e31494ecb4e..813275e097d 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -37,6 +37,7 @@
#include "IMB_colormanagement.h"
+#include "BKE_addon.h"
#include "BKE_appdir.h"
#include "BKE_blender.h"
#include "BKE_blender_version.h"
@@ -552,6 +553,35 @@ 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",
+ };
+ for (int i; i < ARRAY_SIZE(addons); i++) {
+ bAddon *addon = BKE_addon_new();
+ STRNCPY(addon->module, addons[i]);
+ BLI_addtail(&userdef->addons, addon);
+ }
+ }
+
+ return userdef;
+}
+
/**
* Only write the userdef in a .blend
* \return success
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index 8769ed37d16..cc3ea3f2122 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -176,6 +176,7 @@ struct BlendThumbnail *BLO_thumbnail_from_file(const char *filepath);
/* datafiles (generated theme) */
extern const struct bTheme U_theme_default;
+extern const struct UserDef U_default;
#ifdef __cplusplus
}
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index 1cbafc7a707..2a7a7eddb79 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -57,7 +57,7 @@
#include "BLO_readfile.h"
/**
- * Override values in in-memory startup.blend, avoids re-saving for small changes.
+ * Update in-memory preferences with system specific values.
*/
void BLO_update_defaults_userpref_blend(void)
{
@@ -73,54 +73,17 @@ void BLO_update_defaults_userpref_blend(void)
U.flag &= ~USER_SCRIPT_AUTOEXEC_DISABLE;
#endif
- /* Transform tweak with single click and drag. */
- U.flag |= USER_RELEASECONFIRM;
-
- U.flag &= ~(USER_DEVELOPER_UI | USER_TOOLTIPS_PYTHON);
-
- /* Clear addon preferences. */
- for (bAddon *addon = U.addons.first, *addon_next; addon != NULL; addon = addon_next) {
- addon_next = addon->next;
-
- if (addon->prop) {
- IDP_FreeProperty(addon->prop);
- addon->prop = NULL;
- }
- }
-
- /* Ignore the theme saved in the blend file,
- * instead use the theme from 'userdef_default_theme.c' */
- {
- bTheme *theme = U.themes.first;
- memcpy(theme, &U_theme_default, sizeof(bTheme));
- }
-
- /* Leave temp directory empty, will then get appropriate value per OS. */
- U.tempdir[0] = '\0';
-
/* System-specific fonts directory. */
BKE_appdir_font_folder_default(U.fontdir);
- /* Only enable tooltips translation by default,
- * without actually enabling translation itself, for now. */
- U.transopts = USER_TR_TOOLTIPS;
U.memcachelimit = min_ii(BLI_system_memory_max_in_megabytes_int() / 2, 4096);
- /* Auto perspective. */
- U.uiflag |= USER_AUTOPERSP;
-
/* Init weight paint range. */
BKE_colorband_init(&U.coba_weight, true);
- /* Default visible section. */
- U.userpref = USER_SECTION_INTERFACE;
-
/* Default to left click select. */
BKE_keyconfig_pref_set_select_mouse(&U, 0, true);
- /* Increase a little for new scrubbing area. */
- U.v2d_min_gridsize = 45;
-
/* Default studio light. */
BKE_studiolight_default(U.light_param, U.light_ambient);
}
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 3e965fc2f55..587905bab0d 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -936,7 +936,7 @@ void wm_homefile_read(bContext *C,
filepath_startup,
&(const struct BlendFileReadParams){
.is_startup = true,
- .skip_flags = skip_flags,
+ .skip_flags = skip_flags | BLO_READ_SKIP_USERDEF,
},
NULL);
}
@@ -963,6 +963,15 @@ void wm_homefile_read(bContext *C,
}
if (success == false) {
+ if (use_userdef) {
+ if ((skip_flags & BLO_READ_SKIP_USERDEF) == 0) {
+ UserDef *userdef_default = BKE_blendfile_userdef_from_defaults();
+ BKE_blender_userdef_app_template_data_set_and_free(userdef_default);
+ skip_flags &= ~BLO_READ_SKIP_USERDEF;
+ read_userdef_from_memory = true;
+ }
+ }
+
success = BKE_blendfile_read_from_memory(C,
datatoc_startup_blend,
datatoc_startup_blend_size,
@@ -972,13 +981,7 @@ void wm_homefile_read(bContext *C,
.skip_flags = skip_flags,
},
NULL);
- if (success) {
- if (use_userdef) {
- if ((skip_flags & BLO_READ_SKIP_USERDEF) == 0) {
- read_userdef_from_memory = true;
- }
- }
- }
+
if (use_data && BLI_listbase_is_empty(&wmbase)) {
wm_clear_default_size(C);
}
@@ -1015,8 +1018,7 @@ void wm_homefile_read(bContext *C,
}
if (userdef_template == NULL) {
/* we need to have preferences load to overwrite preferences from previous template */
- userdef_template = BKE_blendfile_userdef_read_from_memory(
- datatoc_startup_blend, datatoc_startup_blend_size, NULL);
+ userdef_template = BKE_blendfile_userdef_from_defaults();
read_userdef_from_memory = true;
}
if (userdef_template) {
@@ -1650,7 +1652,7 @@ static int wm_homefile_write_exec(bContext *C, wmOperator *op)
/* force save as regular blend file */
fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_HISTORY);
- if (BLO_write_file(bmain, filepath, fileflags | G_FILE_USERPREFS, op->reports, NULL) == 0) {
+ if (BLO_write_file(bmain, filepath, fileflags, op->reports, NULL) == 0) {
printf("fail\n");
return OPERATOR_CANCELLED;
}
@@ -1734,7 +1736,7 @@ void WM_OT_save_userpref(wmOperatorType *ot)
{
ot->name = "Save Preferences";
ot->idname = "WM_OT_save_userpref";
- ot->description = "Save preferences separately, overrides startup file preferences";
+ ot->description = "Make the current preferences default";
ot->invoke = WM_operator_confirm;
ot->exec = wm_userpref_write_exec;