[Bf-blender-cvs] [c9abb0fe269] blender2.8: Workspaces: replace bundled workspace.blend with embedded startup.blend.

Brecht Van Lommel noreply at git.blender.org
Mon Aug 20 16:29:31 CEST 2018


Commit: c9abb0fe2699478d1027667e6f527c8d60df5786
Author: Brecht Van Lommel
Date:   Mon Aug 20 13:52:50 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBc9abb0fe2699478d1027667e6f527c8d60df5786

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.

===================================================================

D	release/datafiles/workspaces.blend
M	source/blender/blenkernel/BKE_blendfile.h
M	source/blender/blenkernel/intern/blendfile.c
M	source/blender/blenloader/BLO_readfile.h
M	source/blender/blenloader/intern/readfile.c
M	source/blender/editors/screen/workspace_edit.c
M	source/blender/windowmanager/intern/wm_files_link.c
M	source/creator/CMakeLists.txt

===================================================================

diff --git a/release/datafiles/workspaces.blend b/release/datafiles/workspaces.blend
deleted file mode 100644
index e9a9a4e4770..00000000000
Binary files a/release/datafiles/workspaces.blend and /dev/null differ
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
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index b98b917815b..72411bcbbc6 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -422,13 +422,6 @@ if(WITH_OPENCOLORIO)
 	)
 endif()
 
-# Add default workspaces.blend to build (under [version]/datafiles
-install(
-	FILES ${CMAKE_SOURCE_DIR}/release/datafiles/workspaces.blend
-	DESTINATION ${TARGETDIR_VER}/datafiles
-)
-
-
 # helpful tip when using make
 if("${CMAKE_GENERATOR}" MATCHES ".*Makefiles.*")
 	# message after building.



More information about the Bf-blender-cvs mailing list