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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-08-20 14:52:50 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-08-20 17:23:22 +0300
commitc9abb0fe2699478d1027667e6f527c8d60df5786 (patch)
treece6c8e5c803db6a8fc36ec998ddd416b52fa162f /source/blender
parentf1ab36d15455e18d328923d7aedfa1472842cb98 (diff)
Workspaces: replace bundled workspace.blend with embedded startup.blend.
We want these to have the same workspaces in both, so there is no reason to have two files that are identical.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_blendfile.h5
-rw-r--r--source/blender/blenkernel/intern/blendfile.c10
-rw-r--r--source/blender/blenloader/BLO_readfile.h1
-rw-r--r--source/blender/blenloader/intern/readfile.c3
-rw-r--r--source/blender/editors/screen/workspace_edit.c23
-rw-r--r--source/blender/windowmanager/intern/wm_files_link.c8
6 files changed, 38 insertions, 12 deletions
diff --git a/source/blender/blenkernel/BKE_blendfile.h b/source/blender/blenkernel/BKE_blendfile.h
index a9a7e2045f0..305b7d07e4d 100644
--- a/source/blender/blenkernel/BKE_blendfile.h
+++ b/source/blender/blenkernel/BKE_blendfile.h
@@ -61,7 +61,10 @@ struct UserDef *BKE_blendfile_userdef_read_from_memory(
bool BKE_blendfile_userdef_write(const char *filepath, struct ReportList *reports);
bool BKE_blendfile_userdef_write_app_template(const char *filepath, struct ReportList *reports);
-struct WorkspaceConfigFileData *BKE_blendfile_workspace_config_read(const char *filepath, struct ReportList *reports);
+struct WorkspaceConfigFileData *BKE_blendfile_workspace_config_read(
+ const char *filepath,
+ const void *filebuf, int filelength,
+ struct ReportList *reports);
bool BKE_blendfile_workspace_config_write(struct Main *bmain, const char *filepath, struct ReportList *reports);
void BKE_blendfile_workspace_config_data_free(struct WorkspaceConfigFileData *workspace_config);
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index b16648fd73f..abefff5e72b 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -561,12 +561,18 @@ bool BKE_blendfile_userdef_write_app_template(const char *filepath, ReportList *
return ok;
}
-WorkspaceConfigFileData *BKE_blendfile_workspace_config_read(const char *filepath, ReportList *reports)
+WorkspaceConfigFileData *BKE_blendfile_workspace_config_read(const char *filepath, const void *filebuf, int filelength, ReportList *reports)
{
BlendFileData *bfd;
WorkspaceConfigFileData *workspace_config = NULL;
- bfd = BLO_read_from_file(filepath, reports, BLO_READ_SKIP_USERDEF);
+ if (filepath) {
+ bfd = BLO_read_from_file(filepath, reports, BLO_READ_SKIP_USERDEF);
+ }
+ else {
+ bfd = BLO_read_from_memory(filebuf, filelength, reports, BLO_READ_SKIP_USERDEF);
+ }
+
if (bfd) {
workspace_config = MEM_mallocN(sizeof(*workspace_config), __func__);
workspace_config->main = bfd->main;
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index 9040405e537..9758ec8b560 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -115,6 +115,7 @@ void BLO_blendhandle_close(BlendHandle *bh);
/***/
#define BLO_GROUP_MAX 32
+#define BLO_EMBEDDED_STARTUP_BLEND "<startup.blend>"
bool BLO_has_bfile_extension(const char *str);
bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, char **r_name);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 26938158c73..2e2e52058b5 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -1412,6 +1412,9 @@ bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, cha
if (BLO_has_bfile_extension(r_dir) && BLI_is_file(r_dir)) {
break;
}
+ else if (STREQ(r_dir, BLO_EMBEDDED_STARTUP_BLEND)) {
+ break;
+ }
if (prev_slash) {
*prev_slash = c;
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index 16587792c87..267dce87e26 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -50,6 +50,7 @@
#include "DNA_windowmanager_types.h"
#include "DNA_workspace_types.h"
+#include "ED_datafiles.h"
#include "ED_object.h"
#include "ED_screen.h"
@@ -388,14 +389,13 @@ static WorkspaceConfigFileData *workspace_config_file_read(
if (BLI_exists(workspace_config_path)) {
has_path = true;
}
+
+ if (has_path) {
+ return BKE_blendfile_workspace_config_read(workspace_config_path, NULL, 0, reports);
+ }
else {
- workspace_config_file_path_from_folder_id(bmain, BLENDER_SYSTEM_DATAFILES, workspace_config_path);
- if (BLI_exists(workspace_config_path)) {
- has_path = true;
- }
+ return BKE_blendfile_workspace_config_read(NULL, datatoc_startup_blend, datatoc_startup_blend_size, reports);
}
-
- return has_path ? BKE_blendfile_workspace_config_read(workspace_config_path, reports) : NULL;
}
static void workspace_append_button(
@@ -404,9 +404,14 @@ static void workspace_append_button(
const ID *id = (ID *)workspace;
PointerRNA opptr;
char lib_path[FILE_MAX_LIBEXTRA];
+ const char *filepath = from_main->name;
+
+ if (strlen(filepath) == 0) {
+ filepath = BLO_EMBEDDED_STARTUP_BLEND;
+ }
BLI_path_join(
- lib_path, sizeof(lib_path), from_main->name, BKE_idcode_to_name(GS(id->name)), NULL);
+ lib_path, sizeof(lib_path), filepath, BKE_idcode_to_name(GS(id->name)), NULL);
BLI_assert(STREQ(ot_append->idname, "WORKSPACE_OT_append_activate"));
uiItemFullO_ptr(
@@ -426,7 +431,9 @@ static void workspace_config_file_append_buttons(
wmOperatorType *ot_append = WM_operatortype_find("WORKSPACE_OT_append_activate", true);
for (WorkSpace *workspace = workspace_config->workspaces.first; workspace; workspace = workspace->id.next) {
- workspace_append_button(layout, ot_append, workspace, workspace_config->main);
+ if (BLI_findstring(&bmain->workspaces, workspace->id.name, offsetof(ID, name)) == NULL) {
+ workspace_append_button(layout, ot_append, workspace, workspace_config->main);
+ }
}
BKE_blendfile_workspace_config_data_free(workspace_config);
diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c
index 903795d6943..fb17de26703 100644
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@ -74,6 +74,7 @@
#include "IMB_colormanagement.h"
+#include "ED_datafiles.h"
#include "ED_screen.h"
#include "RNA_access.h"
@@ -228,7 +229,12 @@ static void wm_link_do(
for (lib_idx = 0, liblink = lapp_data->libraries.list; liblink; lib_idx++, liblink = liblink->next) {
char *libname = liblink->link;
- bh = BLO_blendhandle_from_file(libname, reports);
+ if (STREQ(libname, BLO_EMBEDDED_STARTUP_BLEND)) {
+ bh = BLO_blendhandle_from_memory(datatoc_startup_blend, datatoc_startup_blend_size);
+ }
+ else {
+ bh = BLO_blendhandle_from_file(libname, reports);
+ }
if (bh == NULL) {
/* Unlikely since we just browsed it, but possible