startup.blend: add a function BLO_update_defaults_startup_blend to change
default settings in the startup.blend without having to actually save and embed the file, which can be a tricky process and is problematic in branches and patches. This function can be emptied each time a new startup.blend is committed.
This commit is contained in:
@@ -69,8 +69,10 @@ int BKE_read_file(struct bContext *C, const char *filepath, struct ReportList *r
|
|||||||
#define BKE_READ_FILE_OK 1 /* OK */
|
#define BKE_READ_FILE_OK 1 /* OK */
|
||||||
#define BKE_READ_FILE_OK_USERPREFS 2 /* OK, and with new user settings */
|
#define BKE_READ_FILE_OK_USERPREFS 2 /* OK, and with new user settings */
|
||||||
|
|
||||||
int BKE_read_file_from_memory(struct bContext *C, const void *filebuf, int filelength, struct ReportList *reports);
|
int BKE_read_file_from_memory(struct bContext *C, const void *filebuf,
|
||||||
int BKE_read_file_from_memfile(struct bContext *C, struct MemFile *memfile, struct ReportList *reports);
|
int filelength, struct ReportList *reports, int update_defaults);
|
||||||
|
int BKE_read_file_from_memfile(struct bContext *C, struct MemFile *memfile,
|
||||||
|
struct ReportList *reports);
|
||||||
|
|
||||||
int BKE_read_file_userdef(const char *filepath, struct ReportList *reports);
|
int BKE_read_file_userdef(const char *filepath, struct ReportList *reports);
|
||||||
int BKE_write_file_userdef(const char *filepath, struct ReportList *reports);
|
int BKE_write_file_userdef(const char *filepath, struct ReportList *reports);
|
||||||
@@ -100,11 +102,11 @@ extern const char *BKE_undo_get_name(int nr, int *active);
|
|||||||
extern int BKE_undo_save_file(const char *filename);
|
extern int BKE_undo_save_file(const char *filename);
|
||||||
extern struct Main *BKE_undo_get_main(struct Scene **scene);
|
extern struct Main *BKE_undo_get_main(struct Scene **scene);
|
||||||
|
|
||||||
/* copybuffer */
|
/* copybuffer */
|
||||||
void BKE_copybuffer_begin(void);
|
void BKE_copybuffer_begin(void);
|
||||||
void BKE_copybuffer_tag_ID(struct ID *id);
|
void BKE_copybuffer_tag_ID(struct ID *id);
|
||||||
int BKE_copybuffer_save(const char *filename, struct ReportList *reports);
|
int BKE_copybuffer_save(const char *filename, struct ReportList *reports);
|
||||||
int BKE_copybuffer_paste(struct bContext *C, const char *libname, struct ReportList *reports);
|
int BKE_copybuffer_paste(struct bContext *C, const char *libname, struct ReportList *reports);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@@ -462,13 +462,16 @@ int BKE_read_file(bContext *C, const char *filepath, ReportList *reports)
|
|||||||
return (bfd ? retval : BKE_READ_FILE_FAIL);
|
return (bfd ? retval : BKE_READ_FILE_FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int BKE_read_file_from_memory(bContext *C, const void *filebuf, int filelength, ReportList *reports)
|
int BKE_read_file_from_memory(bContext *C, const void *filebuf, int filelength, ReportList *reports, int update_defaults)
|
||||||
{
|
{
|
||||||
BlendFileData *bfd;
|
BlendFileData *bfd;
|
||||||
|
|
||||||
bfd = BLO_read_from_memory(filebuf, filelength, reports);
|
bfd = BLO_read_from_memory(filebuf, filelength, reports);
|
||||||
if (bfd)
|
if (bfd) {
|
||||||
|
if (update_defaults)
|
||||||
|
BLO_update_defaults_startup_blend(bfd->main);
|
||||||
setup_app_data(C, bfd, "<memory2>");
|
setup_app_data(C, bfd, "<memory2>");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
BKE_reports_prepend(reports, "Loading failed: ");
|
BKE_reports_prepend(reports, "Loading failed: ");
|
||||||
|
|
||||||
|
@@ -265,7 +265,10 @@ void BLO_main_expander(void (*expand_doit_func)(void *, struct Main *, void *));
|
|||||||
* \param mainvar the Main database to expand
|
* \param mainvar the Main database to expand
|
||||||
*/
|
*/
|
||||||
void BLO_expand_main(void *fdhandle, struct Main *mainvar);
|
void BLO_expand_main(void *fdhandle, struct Main *mainvar);
|
||||||
|
|
||||||
|
/* Update defaults in startup.blend, without having to save and embed it */
|
||||||
|
void BLO_update_defaults_startup_blend(struct Main *mainvar);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -46,6 +46,7 @@ set(SRC
|
|||||||
intern/runtime.c
|
intern/runtime.c
|
||||||
intern/undofile.c
|
intern/undofile.c
|
||||||
intern/versioning_250.c
|
intern/versioning_250.c
|
||||||
|
intern/versioning_defaults.c
|
||||||
intern/versioning_legacy.c
|
intern/versioning_legacy.c
|
||||||
intern/writefile.c
|
intern/writefile.c
|
||||||
|
|
||||||
|
42
source/blender/blenloader/intern/versioning_defaults.c
Normal file
42
source/blender/blenloader/intern/versioning_defaults.c
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Contributor(s): Blender Foundation
|
||||||
|
*
|
||||||
|
* ***** END GPL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file blender/blenloader/intern/versioning_defaults.c
|
||||||
|
* \ingroup blenloader
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "BLI_utildefines.h"
|
||||||
|
|
||||||
|
#include "DNA_scene_types.h"
|
||||||
|
#include "DNA_userdef_types.h"
|
||||||
|
|
||||||
|
#include "BKE_main.h"
|
||||||
|
|
||||||
|
#include "BLO_readfile.h"
|
||||||
|
|
||||||
|
/* Update defaults in startup.blend, without having to save and embed the file.
|
||||||
|
* This function can be emptied each time the startup.blend is updated. */
|
||||||
|
void BLO_update_defaults_startup_blend(Main *main)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
@@ -554,7 +554,7 @@ int wm_homefile_read(bContext *C, ReportList *UNUSED(reports), short from_memory
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (success == 0) {
|
if (success == 0) {
|
||||||
success = BKE_read_file_from_memory(C, datatoc_startup_blend, datatoc_startup_blend_size, NULL);
|
success = BKE_read_file_from_memory(C, datatoc_startup_blend, datatoc_startup_blend_size, NULL, true);
|
||||||
if (wmbase.first == NULL) wm_clear_default_size(C);
|
if (wmbase.first == NULL) wm_clear_default_size(C);
|
||||||
BLI_init_temporary_dir(U.tempdir);
|
BLI_init_temporary_dir(U.tempdir);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user